From 3b63e032cfd3b98adae97be4d262845eaa7d2bb9 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 12 Nov 2024 18:16:20 -0800 Subject: [PATCH] LU-16639 misc: cleanup concole messages The lprocfs_job_cleanup() was not properly dropping all jobstats from the hash table and printing errors from job_stat_exit() at unmount. Ensure all stats are "old enough" when @clear is set. Change early libcfs cfs_cpu_init() messages from CERROR() to pr_err() to avoid circular dependencies on libcfs setup before printing an error message to the console during module init. Lustre-commit: 8f40a3d7110da1af8e310a4b7f40b86f13080938 Lustre-change: https://review.whamcloud.com/50283 Test-Parameters: trivial Fixes: ea2cd3af7b ("LU-11407 obdclass: add start time to stats files") Signed-off-by: Andreas Dilger Change-Id: Ide3f502103392a79419cc1836200bf5a1a3ebbe5 Reviewed-by: Alex Zhuravlev Reviewed-by: Feng Lei Signed-off-by: Eric Carbonneau Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56727 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lnet/lnet/lib-cpt.c | 15 +++++++-------- lustre/obdclass/lprocfs_jobstats.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lnet/lnet/lib-cpt.c b/lnet/lnet/lib-cpt.c index 3eceaac..a8ae50e 100644 --- a/lnet/lnet/lib-cpt.c +++ b/lnet/lnet/lib-cpt.c @@ -1304,27 +1304,26 @@ int cfs_cpu_init(void) if (*cpu_pattern) { cfs_cpt_tab = cfs_cpt_table_create_pattern(cpu_pattern); if (IS_ERR(cfs_cpt_tab)) { - CERROR("Failed to create cptab from pattern '%s'\n", - cpu_pattern); ret = PTR_ERR(cfs_cpt_tab); + pr_err("libcfs: failed to create cptab from pattern '%s': rc = %d\n", + cpu_pattern, ret); goto failed_alloc_table; } - } else { cfs_cpt_tab = cfs_cpt_table_create(cpu_npartitions); if (IS_ERR(cfs_cpt_tab)) { - CERROR("Failed to create cptab with npartitions %d\n", - cpu_npartitions); ret = PTR_ERR(cfs_cpt_tab); + pr_err("libcfs: failed to create cptab with npartitions=%d: rc = %d\n", + cpu_npartitions, ret); goto failed_alloc_table; } } cpus_read_unlock(); - LCONSOLE(0, "HW NUMA nodes: %d, HW CPU cores: %d, npartitions: %d\n", - num_online_nodes(), num_online_cpus(), - cfs_cpt_number(cfs_cpt_tab)); + pr_notice("libcfs: HW NUMA nodes: %d, HW CPU cores: %d, npartitions: %d\n", + num_online_nodes(), num_online_cpus(), + cfs_cpt_number(cfs_cpt_tab)); return 0; failed_alloc_table: diff --git a/lustre/obdclass/lprocfs_jobstats.c b/lustre/obdclass/lprocfs_jobstats.c index 4202f44..c18e1dd 100644 --- a/lustre/obdclass/lprocfs_jobstats.c +++ b/lustre/obdclass/lprocfs_jobstats.c @@ -128,6 +128,7 @@ static void job_putref(struct job_stat *job) static void job_stat_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) { struct job_stat *job; + job = hlist_entry(hnode, struct job_stat, js_hash); job_putref(job); } @@ -234,9 +235,14 @@ static void lprocfs_job_cleanup(struct obd_job_stats *stats, bool clear) * since locking of the hash is handled internally, but there isn't * any benefit to having multiple threads doing cleanup at one time. * - * Subtract twice the cleanup_interval, since it is 1/2 the maximum age. + * Subtract or add twice the cleanup_interval, since it is 1/2 the + * maximum age. When clearing all stats, push oldest into the future. */ - oldest = ktime_sub(now, ktime_add(cleanup_interval, cleanup_interval)); + cleanup_interval = ktime_add(cleanup_interval, cleanup_interval); + if (likely(!clear)) + oldest = ktime_sub(now, cleanup_interval); + else + oldest = ktime_add(now, cleanup_interval); cfs_hash_for_each_safe(stats->ojs_hash, job_cleanup_iter_callback, &oldest); -- 1.8.3.1