Re: [PATCH v6 5/7] locking: Add contended_release tracepoint to qspinlock

From: Dmitry Ilvokhin

Date: Tue Jul 28 2026 - 07:17:12 EST


On Wed, Jun 03, 2026 at 04:26:59PM +0200, Peter Zijlstra wrote:
> On Wed, Jun 03, 2026 at 02:17:27PM +0000, Dmitry Ilvokhin wrote:
>
> > > Something a little like so, which is completely untested, except to
> > > build kernel/locking/spinlock.o (with clang-23).
> >
> > Thanks a lot for taking a look, Peter.
> >
> > I like the static_call idea. It's truly zero cost on x86 (and, as you
> > note, even a byte smaller). The one caveat is that it relies on
> > HAVE_STATIC_CALL_INLINE to stay free.
> >
> > So my plan would be: static_call where HAVE_STATIC_CALL_INLINE is
> > available (x86), and a static branch fallback elsewhere, gated behind a
> > default-off config so it imposes nothing on arches/kernels that don't
> > opt in. I'm mostly interested in x86, but would like arm64 to work too,
> > which would use the fallback.
>
> (i386 doesn't have STATIC_CALL_INLINE, but nobody cares about the
> performance on that target, so anything goes really ;-)
>
> >
> > Concretely:
> >
> > 1. Split the sleepable-lock patches out and send them separately.
> > They're independent of the static call work and look far less
> > controversial.
> >
> > 2. Convert the paravirt spinlock unlock to a static_call, as the
> > foundation for the unlock tracepoint. I'm happy to take a stab at it.
> > Let me know if you'd rather do it yourself.
>
> Yeah, I think that patch as-is *should* work, but like said, I haven't
> even tried it, so it could be terribly broken :-)

Hello Peter,

I picked up your static_call() paravirt-spinlock draft and fixed it up
to where it boots. I think it stands on its own as a cleanup,
independent of the contended_release tracepoint it was meant to enable,
so I'd like to submit it for wider review.

On top of your draft:

- Fix the CONFIG_PARAVIRT_SPINLOCKS=n build.

- Pass @lock to the callee-save unlock. Without it the boot hungs under
CONFIG_CALL_DEPTH_TRACKING.

- Teach __static_call_validate() about the inline unlock insn so the
site can be re-validated after it's patched to the movb.

- Make the slowpath site module-safe: static_call_mod() +
EXPORT_STATIC_CALL_TRAMP().

Boot tested native and as a KVM PV guest.

One important thing missing is your Signed-off-by. Is there any chance
you could provide one if you're happy with the result?

Let me know if you'd like to submit this patch yourself.