[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <170873668101.1860949.4100731238233533238.stgit@frogsfrogsfrogs>
Date: Fri, 23 Feb 2024 17:12:42 -0800
From: "Darrick J. Wong" <djwong@...nel.org>
To: akpm@...ux-foundation.org, daniel@...o.nz, kent.overstreet@...ux.dev,
djwong@...nel.org
Cc: linux-xfs@...r.kernel.org, linux-bcachefs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 10/10] time_stats: Kill TIME_STATS_HAVE_QUANTILES
From: Kent Overstreet <kent.overstreet@...ux.dev>
We have 4 spare bytes next to the spinlock, no need for bit stuffing
Signed-off-by: Kent Overstreet <kent.overstreet@...ux.dev>
Reviewed-by: Darrick J. Wong <djwong@...nel.org>
Signed-off-by: Darrick J. Wong <djwong@...nel.org>
---
include/linux/time_stats.h | 19 +++++--------------
lib/time_stats.c | 4 ++--
2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/include/linux/time_stats.h b/include/linux/time_stats.h
index 4e1f5485ed039..6df2b34aa274b 100644
--- a/include/linux/time_stats.h
+++ b/include/linux/time_stats.h
@@ -68,6 +68,7 @@ struct time_stat_buffer {
struct time_stats {
spinlock_t lock;
+ bool have_quantiles;
/* all fields are in nanoseconds */
u64 min_duration;
u64 max_duration;
@@ -87,12 +88,6 @@ struct time_stats {
struct mean_and_variance_weighted freq_stats_weighted;
struct time_stat_buffer __percpu *buffer;
-/*
- * Is this really a struct time_stats_quantiled? Hide this flag in the least
- * significant bit of the start time to avoid blowing up the structure size.
- */
-#define TIME_STATS_HAVE_QUANTILES (1ULL << 0)
-
u64 start_time;
};
@@ -103,13 +98,9 @@ struct time_stats_quantiles {
static inline struct quantiles *time_stats_to_quantiles(struct time_stats *stats)
{
- struct time_stats_quantiles *statq;
-
- if (!(stats->start_time & TIME_STATS_HAVE_QUANTILES))
- return NULL;
-
- statq = container_of(stats, struct time_stats_quantiles, stats);
- return &statq->quantiles;
+ return stats->have_quantiles
+ ? &container_of(stats, struct time_stats_quantiles, stats)->quantiles
+ : NULL;
}
void __time_stats_clear_buffer(struct time_stats *, struct time_stat_buffer *);
@@ -169,7 +160,7 @@ static inline void time_stats_quantiles_exit(struct time_stats_quantiles *statq)
static inline void time_stats_quantiles_init(struct time_stats_quantiles *statq)
{
time_stats_init(&statq->stats);
- statq->stats.start_time |= TIME_STATS_HAVE_QUANTILES;
+ statq->stats.have_quantiles = true;
memset(&statq->quantiles, 0, sizeof(statq->quantiles));
}
diff --git a/lib/time_stats.c b/lib/time_stats.c
index c0f209dd9f6dd..0b90c80cba9f1 100644
--- a/lib/time_stats.c
+++ b/lib/time_stats.c
@@ -164,7 +164,7 @@ static void seq_buf_time_units_aligned(struct seq_buf *out, u64 ns)
static inline u64 time_stats_lifetime(const struct time_stats *stats)
{
- return local_clock() - (stats->start_time & ~TIME_STATS_HAVE_QUANTILES);
+ return local_clock() - stats->start_time;
}
void time_stats_to_seq_buf(struct seq_buf *out, struct time_stats *stats,
@@ -364,7 +364,7 @@ void time_stats_init(struct time_stats *stats)
memset(stats, 0, sizeof(*stats));
stats->min_duration = U64_MAX;
stats->min_freq = U64_MAX;
- stats->start_time = local_clock() & ~TIME_STATS_HAVE_QUANTILES;
+ stats->start_time = local_clock();
spin_lock_init(&stats->lock);
}
EXPORT_SYMBOL_GPL(time_stats_init);
Powered by blists - more mailing lists