summaryrefslogtreecommitdiff
path: root/fs/bcachefs/time_stats.h
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-02-01 12:41:42 -0800
committerKent Overstreet <kent.overstreet@linux.dev>2024-03-13 21:38:01 -0400
commit273960b8f374b95ebd234a99607b7887f515c791 (patch)
treeb50ec6f9658860cb3930b675b4b8cf5a9937bf2b /fs/bcachefs/time_stats.h
parent4b4f0876ab74167cc402ccd5ce9154e7dc666829 (diff)
bcachefs: time_stats: split stats-with-quantiles into a separate structure
Currently, struct time_stats has the optional ability to quantize the information that it collects. This is /probably/ useful for callers who want to see quantized information, but it more than doubles the size of the structure from 224 bytes to 464. For users who don't care about that (e.g. upcoming xfs patches) and want to avoid wasting 240 bytes per counter, split the two into separate pieces. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/time_stats.h')
-rw-r--r--fs/bcachefs/time_stats.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/fs/bcachefs/time_stats.h b/fs/bcachefs/time_stats.h
index fd6e442443f9..ed6c03c436c0 100644
--- a/fs/bcachefs/time_stats.h
+++ b/fs/bcachefs/time_stats.h
@@ -26,6 +26,7 @@
#include <linux/sched/clock.h>
#include <linux/spinlock_types.h>
+#include <linux/string.h>
#include "mean_and_variance.h"
@@ -68,7 +69,7 @@ struct time_stat_buffer {
struct bch2_time_stats {
spinlock_t lock;
- bool quantiles_enabled;
+ bool have_quantiles;
/* all fields are in nanoseconds */
u64 min_duration;
u64 max_duration;
@@ -77,7 +78,6 @@ struct bch2_time_stats {
u64 min_freq;
u64 last_event;
u64 last_event_start;
- struct quantiles quantiles;
struct mean_and_variance duration_stats;
struct mean_and_variance freq_stats;
@@ -90,6 +90,18 @@ struct bch2_time_stats {
struct time_stat_buffer __percpu *buffer;
};
+struct bch2_time_stats_quantiles {
+ struct bch2_time_stats stats;
+ struct quantiles quantiles;
+};
+
+static inline struct quantiles *time_stats_to_quantiles(struct bch2_time_stats *stats)
+{
+ return stats->have_quantiles
+ ? &container_of(stats, struct bch2_time_stats_quantiles, stats)->quantiles
+ : NULL;
+}
+
void __bch2_time_stats_clear_buffer(struct bch2_time_stats *, struct time_stat_buffer *);
void __bch2_time_stats_update(struct bch2_time_stats *stats, u64, u64);
@@ -133,4 +145,15 @@ static inline bool track_event_change(struct bch2_time_stats *stats, bool v)
void bch2_time_stats_exit(struct bch2_time_stats *);
void bch2_time_stats_init(struct bch2_time_stats *);
+static inline void bch2_time_stats_quantiles_exit(struct bch2_time_stats_quantiles *statq)
+{
+ bch2_time_stats_exit(&statq->stats);
+}
+static inline void bch2_time_stats_quantiles_init(struct bch2_time_stats_quantiles *statq)
+{
+ bch2_time_stats_init(&statq->stats);
+ statq->stats.have_quantiles = true;
+ memset(&statq->quantiles, 0, sizeof(statq->quantiles));
+}
+
#endif /* _BCACHEFS_TIME_STATS_H */