mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/8] perf bench futex: Fix several bugs and bad inputs
@ 2026-09-26 19:03 Michal Pluta
  2026-09-26 19:04 ` [PATCH 1/8] perf bench futex: Retry futex_wait() when interrupted by a signal Michal Pluta
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Michal Pluta @ 2026-09-26 19:03 UTC (permalink / raw)
  To: acme, namhyung
  Cc: Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
	Davidlohr Bueso, André Almeida, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Sebastian Andrzej Siewior, linux-kernel,
	linux-perf-users

This series fixes several bugs in the futex benchmarks of 'perf bench'.
I found them by running the benchmarks and reading the code, and then
trying edge-case inputs. They include hangs, wrong timing and throughput
numbers, and inputs that were silently ignored.

I used an LLM to check whether what I suspected were actually bugs, and
later to look for more edge cases. I reproduced and reviewed each one
myself.

This is my first patch submission, so I am happy to reword, reorder or
split any of the patches.

How I checked each problem, before the patch:

1. futex_wait() never returns EINTR, so the signal check never worked.
   I confirmed the hang by sending SIGINT to one worker thread with
   tgkill(2) while 'perf bench futex wake -t 8' was waiting: it hung.
2. 'perf bench futex wake -b 128' fails with an error from
   futex_print_nbuckets().
3. Run 'perf bench futex hash -t 2 -r 30 -s' and send it SIGINT after
   about 3 s: the throughput is much higher than in a full '-r 3' run.
   The timing problem in the other benchmarks I confirmed by making
   gettimeofday() advance by 1.5 s per call with an LD_PRELOAD shim.
4. 'perf bench futex requeue -q 0' and 'perf bench futex hash -f 0'
   hang, and 'perf bench futex wake -b -128' silently ignores the -b.
5. I confirmed the hang by making FUTEX_WAKE fail with an LD_PRELOAD
   shim.
6. Only affects 32-bit builds, see below.

I can share the small test programs for items 1, 3 and 5 if they are
useful.

Not tested:
- Patch 6 (64-bit counter) was built and run only on x86-64, as I have
  no 32-bit setup.
- Patch 5 was tested with an injected failure, not with a real failing
  system call.
- Everything else was run on x86-64 with a 7.0 kernel.

Patches 7 and 8 are optional cleanups.

The series is based on perf-tools-next, commit 528b1475f9cf ("perf mem
record: Use the IBS swfilt filter when available").

Thank you!

Michal Pluta (8):
  perf bench futex: Retry futex_wait() when interrupted by a signal
  perf bench futex: Set the number of hash buckets in futex wake
  perf bench futex: Use the whole timeval for elapsed times
  perf bench futex: Reject invalid -q, -f and -b values
  perf bench futex: Stop when futex_wake() fails in futex wake
  perf bench futex: Use a 64-bit operation counter in hash and lock-pi
  perf bench futex: Clean up two nits in futex hash
  perf bench futex: Fix wording in futex bench messages

 tools/perf/bench/futex-hash.c          | 23 +++++++++++++-------
 tools/perf/bench/futex-lock-pi.c       | 16 ++++++++------
 tools/perf/bench/futex-requeue.c       | 12 ++++++++---
 tools/perf/bench/futex-wake-parallel.c | 15 +++++++------
 tools/perf/bench/futex-wake.c          | 30 ++++++++++++++++----------
 tools/perf/bench/futex.c               |  9 +++++---
 6 files changed, 68 insertions(+), 37 deletions(-)


base-commit: 528b1475f9cffbaffb37f490e86780662471ef3f
-- 
2.43.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-09-26 19:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-26 19:03 [PATCH 0/8] perf bench futex: Fix several bugs and bad inputs Michal Pluta
2026-09-26 19:04 ` [PATCH 1/8] perf bench futex: Retry futex_wait() when interrupted by a signal Michal Pluta
2026-09-26 19:04 ` [PATCH 2/8] perf bench futex: Set the number of hash buckets in futex wake Michal Pluta
2026-09-26 19:04 ` [PATCH 3/8] perf bench futex: Use the whole timeval for elapsed times Michal Pluta
2026-09-26 19:04 ` [PATCH 4/8] perf bench futex: Reject invalid -q, -f and -b values Michal Pluta
2026-09-26 19:04 ` [PATCH 5/8] perf bench futex: Stop when futex_wake() fails in futex wake Michal Pluta
2026-09-26 19:04 ` [PATCH 6/8] perf bench futex: Use a 64-bit operation counter in hash and lock-pi Michal Pluta
2026-09-26 19:04 ` [PATCH 7/8] perf bench futex: Clean up two nits in futex hash Michal Pluta
2026-09-26 19:04 ` [PATCH 8/8] perf bench futex: Fix wording in futex bench messages Michal Pluta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®