[PATCH 6/8] perf bench futex: Use a 64-bit operation counter in hash and lock-pi
From: Michal Pluta
Date: Sat Sep 26 2026 - 15:07:34 EST
The per-thread operation counters in 'futex hash' and 'futex lock-pi'
are unsigned longs, which could overflow on 32-bit systems. Use u64
instead.
Assisted-by: LLM
Signed-off-by: Michal Pluta <michalpl2003@xxxxxxxxx>
---
tools/perf/bench/futex-hash.c | 6 +++---
tools/perf/bench/futex-lock-pi.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
index 710c253cfe17..e18d98664d27 100644
--- a/tools/perf/bench/futex-hash.c
+++ b/tools/perf/bench/futex-hash.c
@@ -46,7 +46,7 @@ struct worker {
int tid;
u_int32_t *futex;
pthread_t thread;
- unsigned long ops;
+ u64 ops;
};
static struct bench_futex_parameters params = {
@@ -76,7 +76,7 @@ static void *workerfn(void *arg)
int ret;
struct worker *w = (struct worker *) arg;
unsigned int i;
- unsigned long ops = w->ops; /* avoid cacheline bouncing */
+ u64 ops = w->ops; /* avoid cacheline bouncing */
mutex_lock(&thread_lock);
threads_starting--;
@@ -238,7 +238,7 @@ int bench_futex_hash(int argc, const char **argv)
for (i = 0; i < params.nthreads; i++) {
unsigned long t = runtime_us ?
- (u64)worker[i].ops * USEC_PER_SEC / runtime_us : 0;
+ worker[i].ops * USEC_PER_SEC / runtime_us : 0;
update_stats(&throughput_stats, t);
if (!params.silent) {
if (params.nfutexes == 1)
diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c
index 7190f5102e09..8016a31b198d 100644
--- a/tools/perf/bench/futex-lock-pi.c
+++ b/tools/perf/bench/futex-lock-pi.c
@@ -29,7 +29,7 @@ struct worker {
int tid;
u_int32_t *futex;
pthread_t thread;
- unsigned long ops;
+ u64 ops;
};
static u_int32_t global_futex = 0;
@@ -86,7 +86,7 @@ static void toggle_done(int sig __maybe_unused,
static void *workerfn(void *arg)
{
struct worker *w = (struct worker *) arg;
- unsigned long ops = w->ops;
+ u64 ops = w->ops;
mutex_lock(&thread_lock);
threads_starting--;
@@ -239,7 +239,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
for (i = 0; i < params.nthreads; i++) {
unsigned long t = runtime_us ?
- (u64)worker[i].ops * USEC_PER_SEC / runtime_us : 0;
+ worker[i].ops * USEC_PER_SEC / runtime_us : 0;
update_stats(&throughput_stats, t);
if (!params.silent)
--
2.43.0