mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 0/3] perf bench: Add ticket spinlock benchmark
@ 2025-07-29  8:12 Yuzhuo Jing
  2025-07-29  8:12 ` [PATCH v1 1/3] tools: Import atomic_fetch_{and,add,sub} Yuzhuo Jing
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yuzhuo Jing @ 2025-07-29  8:12 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang Kan, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Yuzhuo Jing,
	Yuzhuo Jing, Guo Ren, Andrea Parri, Leonardo Bras, linux-kernel,
	linux-perf-users, linux-riscv

This patch series adds benchmark for the kernel's ticket spinlock
implementation.

This series depends on a preceding patch series that introduces the
'perf bench sync' benchmark infrastructure.
Link: https://lore.kernel.org/lkml/20250729022640.3134066-1-yuzhuo@google.com/

In a quick test, on a 48C 96T x86 VM, ticket spinlock performs better on
2-6 threads, and qspinlock performs better on 1 thread or >=8 threads.

$ # set 't' variable, and then
$ ./perf bench sync qspinlock -t$t; sleep 1; ./perf bench sync ticket -t$t

'sync/qspinlock' benchmarks:
Lock-unlock latency of 1 threads: 8.5779 ns.
Lock-unlock latency of 2 threads: 187.1022 ns.
...
Lock-unlock latency of 6 threads: 1202.8312 ns.
...
Lock-unlock latency of 8 threads: 1541.566 ns.
Lock-unlock latency of 96 threads: 44140.8765 ns.

'sync/ticket' benchmarks:
Lock-unlock latency of 1 threads: 12.1888 ns.
Lock-unlock latency of 2 threads: 168.1132 ns.
...
Lock-unlock latency of 6 threads: 1033.2760 ns.
....
Lock-unlock latency of 8 threads: 1667.1647 ns.
Lock-unlock latency of 96 threads: 66915.8949 ns.

Yuzhuo Jing (3):
  tools: Import atomic_fetch_{and,add,sub}
  perf bench: Import ticket_spinlock from kerne
  perf bench: Add 'bench sync ticket' subcommand

 tools/arch/x86/include/asm/atomic.h        |  17 ++++
 tools/arch/x86/include/asm/cmpxchg.h       |  11 +++
 tools/include/asm-generic/atomic-gcc.h     |  51 ++++++++++
 tools/perf/bench/bench.h                   |   1 +
 tools/perf/bench/include/ticket_spinlock.h | 107 +++++++++++++++++++++
 tools/perf/bench/sync.c                    |  17 ++++
 tools/perf/builtin-bench.c                 |   1 +
 tools/perf/check-headers.sh                |   3 +
 8 files changed, 208 insertions(+)
 create mode 100644 tools/perf/bench/include/ticket_spinlock.h

-- 
2.50.1.487.gc89ff58d15-goog


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

end of thread, other threads:[~2025-07-29  8:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-29  8:12 [PATCH v1 0/3] perf bench: Add ticket spinlock benchmark Yuzhuo Jing
2025-07-29  8:12 ` [PATCH v1 1/3] tools: Import atomic_fetch_{and,add,sub} Yuzhuo Jing
2025-07-29  8:12 ` [PATCH v1 2/3] perf bench: Import ticket_spinlock from kerne Yuzhuo Jing
2025-07-29  8:12 ` [PATCH v1 3/3] perf bench: Add 'bench sync ticket' subcommand Yuzhuo Jing

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®