Whamcloud - gitweb
LU-11407 obdclass: add start time to stats files
[fs/lustre-release.git] / lustre / obdclass / lprocfs_status.c
index 7f7446d..2872e89 100644 (file)
@@ -1360,6 +1360,24 @@ static void *lprocfs_stats_seq_next(struct seq_file *p, void *v, loff_t *pos)
        return lprocfs_stats_seq_start(p, pos);
 }
 
+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 *units = show_units ? " secs.nsecs" : "";
+       struct timespec64 ts;
+
+       ts = ktime_to_timespec64(now);
+       seq_printf(seq, "%-*s%s %llu.%09lu%s\n", width,
+                  "snapshot_time", colon, (s64)ts.tv_sec, ts.tv_nsec, units);
+       ts = ktime_to_timespec64(ts_init);
+       seq_printf(seq, "%-*s%s %llu.%09lu%s\n", width,
+                  "start_time", colon, (s64)ts.tv_sec, ts.tv_nsec, units);
+       ts = ktime_to_timespec64(ktime_sub(now, ts_init));
+       seq_printf(seq, "%-*s%s %llu.%09lu%s\n", width,
+                  "elapsed_time", colon, (s64)ts.tv_sec, ts.tv_nsec, units);
+}
+EXPORT_SYMBOL(lprocfs_stats_header);
+
 /* seq file export of one lprocfs counter */
 static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
 {
@@ -1368,13 +1386,8 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
        struct lprocfs_counter ctr;
        int idx = *(loff_t *)v;
 
-       if (idx == 0) {
-               struct timespec64 now;
-
-               ktime_get_real_ts64(&now);
-               seq_printf(p, "%-25s %llu.%09lu secs.nsecs\n",
-                          "snapshot_time", (s64)now.tv_sec, now.tv_nsec);
-       }
+       if (idx == 0)
+               lprocfs_stats_header(p, ktime_get(), stats->ls_init, 25, "", 1);
 
        hdr = &stats->ls_cnt_header[idx];
        lprocfs_stats_collect(stats, idx, &ctr);