From 2a498f06ccc975fb57214961db6e20a6c1cc2ec7 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 31 Jul 2023 13:34:22 -0600 Subject: [PATCH] LU-17005 obdclass: allow stats header to be disabled Add a global "enable_stats_header" tunable parameter that can be set to enable/disable the "start_time" and "elapsed_time" fields in the standard lprocfs "stats" files. Default to enabled, since this landed shortly after v2_14_0. Test-Parameters: trivial Fixes: 5efb892396e3 ("LU-11407 obdclass: add start time to stats files") Signed-off-by: Andreas Dilger Change-Id: I460b957447bfb83e6d4fd7395b79ce994f3ebbe5 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51823 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Feng Lei Reviewed-by: Nathaniel Clark Reviewed-by: Oleg Drokin --- lustre/include/lprocfs_status.h | 1 + lustre/obdclass/lprocfs_status.c | 6 ++++++ lustre/obdclass/obd_sysfs.c | 2 ++ lustre/tests/sanity.sh | 3 +++ 4 files changed, 12 insertions(+) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index c80e3da..df9d5f8 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -600,6 +600,7 @@ extern int lprocfs_obd_seq_create(struct obd_device *obd, const char *name, extern void lprocfs_stats_header(struct seq_file *seq, ktime_t now, ktime_t ts_init, int width, const char *colon, bool show_units, const char *prefix); +extern unsigned int obd_enable_stats_header; /* Generic callbacks */ extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 33f61c2..4f09a04 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -40,6 +40,9 @@ #ifdef CONFIG_PROC_FS +/* enable start/elapsed_time in stats headers by default */ +unsigned int obd_enable_stats_header = 1; + static int lprocfs_no_percpu_stats = 0; module_param(lprocfs_no_percpu_stats, int, 0644); MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats"); @@ -1407,6 +1410,9 @@ void lprocfs_stats_header(struct seq_file *seq, ktime_t now, ktime_t ts_init, seq_printf(seq, "%s%-*s %llu.%09lu%s\n", prefix, width, field, (s64)ts.tv_sec, ts.tv_nsec, units); + if (!obd_enable_stats_header) + return; + field = (colon && colon[0]) ? "start_time:" : "start_time"; ts = ktime_to_timespec64(ts_init); seq_printf(seq, "%s%-*s %llu.%09lu%s\n", prefix, width, field, diff --git a/lustre/obdclass/obd_sysfs.c b/lustre/obdclass/obd_sysfs.c index f86aadf..d6a9a51 100644 --- a/lustre/obdclass/obd_sysfs.c +++ b/lustre/obdclass/obd_sysfs.c @@ -120,6 +120,7 @@ LUSTRE_STATIC_UINT_ATTR(at_max, &at_max); LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra); LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin); LUSTRE_STATIC_UINT_ATTR(at_history, &at_history); +LUSTRE_STATIC_UINT_ATTR(enable_stats_header, &obd_enable_stats_header); LUSTRE_STATIC_UINT_ATTR(lbug_on_eviction, &obd_lbug_on_eviction); LUSTRE_STATIC_UINT_ATTR(ping_interval, &ping_interval); LUSTRE_STATIC_UINT_ATTR(evict_multiplier, &ping_evict_timeout_multiplier); @@ -428,6 +429,7 @@ LUSTRE_RW_ATTR(timeout); static struct attribute *lustre_attrs[] = { &lustre_attr_version.attr, &lustre_attr_pinger.attr, + &lustre_sattr_enable_stats_header.u.attr, &lustre_attr_health_check.attr, &lustre_attr_jobid_name.attr, &lustre_attr_jobid_var.attr, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 706de96..d5bbea5 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -14487,6 +14487,9 @@ test_127a() { # bug 15521 local name count samp unit min max sum sumsq local tmpfile=$TMP/$tfile.tmp + # enable stats header if it is disabled + $LCTL set_param enable_stats_header=1 + $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed" echo "stats before reset" stack_trap "rm -f $tmpfile" -- 1.8.3.1