[06/10] time_stats: allow custom epoch names

Message ID 170873668037.1860949.12345616435891382226.stgit@frogsfrogsfrogs
State New
Headers
Series [01/10] time_stats: report lifetime of the stats object |

Commit Message

Darrick J. Wong Feb. 24, 2024, 1:11 a.m. UTC
  From: Darrick J. Wong <djwong@kernel.org>

Let callers of time_stats_to_seq_buf define the epoch name; "mount"
doesn't make sense generally.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
 include/linux/time_stats.h |    2 +-
 lib/time_stats.c           |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/include/linux/time_stats.h b/include/linux/time_stats.h
index 994823c17bca9..b2f71e3862c0f 100644
--- a/include/linux/time_stats.h
+++ b/include/linux/time_stats.h
@@ -151,7 +151,7 @@  static inline bool track_event_change(struct time_stats *stats, bool v)
 #define TIME_STATS_PRINT_NO_ZEROES	(1U << 0)	/* print nothing if zero count */
 struct seq_buf;
 void time_stats_to_seq_buf(struct seq_buf *, struct time_stats *,
-		unsigned int flags);
+		const char *epoch_name, unsigned int flags);
 
 void time_stats_exit(struct time_stats *);
 void time_stats_init(struct time_stats *);
diff --git a/lib/time_stats.c b/lib/time_stats.c
index 382935979f8f7..f4a21409006bd 100644
--- a/lib/time_stats.c
+++ b/lib/time_stats.c
@@ -169,7 +169,7 @@  static inline u64 time_stats_lifetime(const struct time_stats *stats)
 }
 
 void time_stats_to_seq_buf(struct seq_buf *out, struct time_stats *stats,
-		unsigned int flags)
+		const char *epoch_name, unsigned int flags)
 {
 	struct quantiles *quantiles = time_stats_to_quantiles(stats);
 	s64 f_mean = 0, d_mean = 0;
@@ -201,7 +201,7 @@  void time_stats_to_seq_buf(struct seq_buf *out, struct time_stats *stats,
 	seq_buf_time_units_aligned(out, lifetime);
 	seq_buf_printf(out, "\n");
 
-	seq_buf_printf(out, "                       since mount        recent\n");
+	seq_buf_printf(out, "                       since %-12s recent\n", epoch_name);
 
 	seq_buf_printf(out, "duration of events\n");