diff options
author | Darrick J. Wong <djwong@kernel.org> | 2024-02-05 11:50:53 -0800 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-03-07 16:16:26 -0500 |
commit | 287c0f987da121ff2551d7551fdfbe6d645e064c (patch) | |
tree | 394c42beab6b28c73598624296ceb5704762006f | |
parent | 849dcc25a37c45c87580962bf5d53654b43ac03c (diff) |
time_stats: report lifetime of the stats object
Capture the initialization time of the time_stats object so that we can
report how long the counter has been observing data.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/time_stats.c | 10 | ||||
-rw-r--r-- | fs/bcachefs/time_stats.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/fs/bcachefs/time_stats.c b/fs/bcachefs/time_stats.c index 232da8488060..b6184cc4106d 100644 --- a/fs/bcachefs/time_stats.c +++ b/fs/bcachefs/time_stats.c @@ -174,11 +174,17 @@ static void seq_buf_time_units_aligned(struct seq_buf *out, u64 ns) seq_buf_printf(out, "%8llu %s", div64_u64(ns, u->nsecs), u->name); } +static inline u64 time_stats_lifetime(const struct bch2_time_stats *stats) +{ + return local_clock() - stats->start_time; +} + void bch2_time_stats_to_seq_buf(struct seq_buf *out, struct bch2_time_stats *stats) { struct quantiles *quantiles = time_stats_to_quantiles(stats); s64 f_mean = 0, d_mean = 0; u64 f_stddev = 0, d_stddev = 0; + u64 lifetime = time_stats_lifetime(stats); if (stats->buffer) { int cpu; @@ -200,6 +206,9 @@ void bch2_time_stats_to_seq_buf(struct seq_buf *out, struct bch2_time_stats *sta } seq_buf_printf(out, "count: %llu\n", stats->duration_stats.n); + seq_buf_printf(out, "lifetime: "); + seq_buf_time_units_aligned(out, lifetime); + seq_buf_printf(out, "\n"); seq_buf_printf(out, " since mount recent\n"); @@ -276,5 +285,6 @@ void bch2_time_stats_init(struct bch2_time_stats *stats) memset(stats, 0, sizeof(*stats)); stats->min_duration = U64_MAX; stats->min_freq = U64_MAX; + stats->start_time = local_clock(); spin_lock_init(&stats->lock); } diff --git a/fs/bcachefs/time_stats.h b/fs/bcachefs/time_stats.h index 51d7396d476b..3ef9c41128a2 100644 --- a/fs/bcachefs/time_stats.h +++ b/fs/bcachefs/time_stats.h @@ -79,6 +79,7 @@ struct bch2_time_stats { u64 min_freq; u64 last_event; u64 last_event_start; + u64 start_time; struct mean_and_variance duration_stats; struct mean_and_variance freq_stats; |