Re: [PATCH v1 0/7] perf bench: Add qspinlock benchmark

From: Peter Zijlstra
Date: Tue Sep 16 2025 - 10:29:30 EST


On Mon, Aug 04, 2025 at 03:28:12PM +0100, Mark Rutland wrote:
> On Mon, Jul 28, 2025 at 07:26:33PM -0700, Yuzhuo Jing wrote:
> > As an effort to improve the perf bench subcommand, this patch series
> > adds benchmark for the kernel's queued spinlock implementation.
> >
> > This series imports necessary kernel definitions such as atomics,
> > introduces userspace per-cpu adapter, and imports the qspinlock
> > implementation from the kernel tree to tools tree, with minimum
> > adaptions.
>
> Who is this intended to be useful for, and when would they use this?
>
> This doesn't serve as a benchmark of the host kernel, since it tests
> whatever stale copy of the qspinlock code was built into the perf
> binary.
>
> I can understand that being able to test the code in userspace may be
> helpful when making some changes, but why does this need to be built
> into the perf tool?

Right, I think most of us already have a userspace version of it. I have
a thingy that has TAS, TICKET and QSPINLOCK wrapped in a perf self
monitor that I can run on various x86_64 to see how it behaves.

IIRC it also has a pile of 'raw' atomic ops to see the contention
behaviour. This shows that eg. XADD is *waay* nicer than a CMPXCHG loop
when heavily contended.

Anyway, that lives as a random tar file on a random machine in my house,
I'm not sure it makes much sense to stick that in perf as such. Rather
specific.