Whamcloud - gitweb
LU-17005 obdclass: allow stats header to be disabled 23/51823/2
authorAndreas Dilger <adilger@whamcloud.com>
Mon, 31 Jul 2023 19:34:22 +0000 (13:34 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 24 Aug 2023 04:36:57 +0000 (04:36 +0000)
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 <adilger@whamcloud.com>
Change-Id: I460b957447bfb83e6d4fd7395b79ce994f3ebbe5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51823
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Feng Lei <flei@whamcloud.com>
Reviewed-by: Nathaniel Clark <nclark@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lprocfs_status.h
lustre/obdclass/lprocfs_status.c
lustre/obdclass/obd_sysfs.c
lustre/tests/sanity.sh

index c80e3da..df9d5f8 100644 (file)
@@ -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);
index 33f61c2..4f09a04 100644 (file)
@@ -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,
index f86aadf..d6a9a51 100644 (file)
@@ -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,
index 706de96..d5bbea5 100755 (executable)
@@ -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"