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)
{
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);