Linux-HyperV List
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Dmitry Ilvokhin <d@ilvokhin.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	Boqun Feng <boqun@kernel.org>, Waiman Long <longman@redhat.com>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
	Long Li <longli@microsoft.com>, Thomas Gleixner <tglx@kernel.org>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Ajay Kaher <ajay.kaher@broadcom.com>,
	Alexey Makhalov <alexey.makhalov@broadcom.com>,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Jason Baron <jbaron@akamai.com>,
	Alice Ryhl <aliceryhl@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org,
	linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev,
	kvm@vger.kernel.org, xen-devel@lists.xenproject.org,
	linux-arch@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH 0/5] locking/qspinlock: Add contended_release tracepoint
Date: Tue, 4 Aug 2026 09:57:23 +0200	[thread overview]
Message-ID: <627c59ee-54b1-4f37-b849-c331a9d01618@suse.com> (raw)
In-Reply-To: <cover.1785778551.git.d@ilvokhin.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 4614 bytes --]

On 04.08.26 09:15, Dmitry Ilvokhin wrote:
> The contended_release tracepoint landed in v7.2-rc2 for sleeping locks
> (4f070ccb4dc4 "locking: Add contended_release tracepoint to sleepable
> locks"). Spinlock support was dropped from that series. This one adds it
> for queued spinlocks.
> 
> The existing contention_begin/contention_end tracepoints fire on the
> waiter side. The holder's identity and stack can be captured at
> contention_begin time (e.g. perf lock contention --lock-owner), but only
> for locks with an owner field to read: mutex and rwsem. qspinlock has
> none, so a contended spinlock cannot be attributed to its holder at all.
> Even where the owner can be read, it reflects the holder's state when a
> waiter arrives, not when the lock is released.
> 
> This series adds a contended_release tracepoint to qspinlock that fires
> on the holder side when a lock with waiters is released. This provides:
> 
> - Hold time estimation: when the holder's own acquisition was
>    contended, its contention_end (acquisition) and contended_release
>    can be correlated to measure how long the lock was held under
>    contention.
> 
> - The holder's stack at release time, which for spinlocks is not
>    available by any other means.
> 
> The unlock path might be quite hot, so the tracepoint is made as cheap
> as possible, to keep it usable in production:
> 
> - x86 with PARAVIRT_SPINLOCKS=y, which is what distributions ship, swaps
>    the unlock implementation via static_call() when the tracepoint is
>    enabled. The disabled path is byte-identical to today's: the same
>    inline movb, no NOP and no call.
> 
> - Everywhere else a static-branch check is compiled into
>    queued_spin_unlock(). On x86_64 that is a single NOP on the executed
>    path, with the call to the traced helper emitted out of line and
>    unreachable while the tracepoint is off. On other architectures a few
>    more instructions to manage a stack frame land on the executed path
>    too, so the generic path sits behind
>    CONFIG_QUEUED_SPINLOCKS_TRACE_CONTENDED_RELEASE (default n).
> 
> Costs and measurements are in the individual changelogs. Briefly, no
> throughput or latency change is measurable on either x86_64 or arm64
> with QUEUED_SPINLOCKS_TRACE_CONTENDED_RELEASE=y.
> 
> Tested: x86_64 with PARAVIRT_SPINLOCKS=y and =n, arm64, tracepoint on
> and off, disassembly checked in both states, locktorture with tracepoint
> on and off.
> 
> Not covered: qrwlock, and architectures with fully custom qspinlock
> implementations (e.g. PowerPC). The stack frame managing instructions on
> arm64 should be avoidable, but that is not done in this patchset.
> 
> Patch 1 is Peter's draft from [1] and is missing his Signed-off-by.
> Peter, please add it if you are happy with the patch.
> 
> [1]: https://lore.kernel.org/all/20260603120811.GW3493090@noisy.programming.kicks-ass.net/
> 
> Dmitry Ilvokhin (4):
>    locking: Factor out queued_spin_release()
>    locking/qspinlock: Add contended_release tracepoint
>    tracing/lock: Use TRACE_EVENT_FN() for contended_release
>    x86/paravirt: Trace contended_release on unlock
> 
> Peter Zijlstra (1):
>    x86/paravirt: Use static_call() for the paravirt spinlock ops
> 
>   arch/mips/include/asm/spinlock.h         |  6 +--
>   arch/x86/hyperv/hv_spinlock.c            |  4 +-
>   arch/x86/include/asm/cpufeatures.h       |  1 -
>   arch/x86/include/asm/paravirt-spinlock.h | 21 +++++---
>   arch/x86/kernel/kvm.c                    |  5 +-
>   arch/x86/kernel/paravirt-spinlocks.c     | 63 +++++++++++++++++++++---
>   arch/x86/kernel/static_call.c            | 27 ++++++++++
>   arch/x86/xen/spinlock.c                  |  5 +-
>   include/asm-generic/qspinlock.h          | 38 ++++++++++++--
>   include/trace/events/lock.h              | 10 +++-
>   kernel/Kconfig.locks                     | 20 ++++++++
>   kernel/locking/mutex.c                   |  4 ++
>   kernel/locking/qspinlock.c               | 22 +++++++++
>   tools/arch/x86/include/asm/cpufeatures.h |  1 -
>   14 files changed, 195 insertions(+), 32 deletions(-)
> 
> 
> base-commit: 5e601ab3615c86be7c4068ce992f94654693a032

For the whole series:

Acked-by: Juergen Gross <jgross@suse.com>

I'm considering some followup patches replacing the remaining paravirt
cases not covered by CONFIG_PARAVIRT_XXL with static_call(), too.

This will allow to drop the 32-bit paravirt patching completely. :-)

The queued_spin_unlock() hook was the main reason I didn't do that yet.


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  parent reply	other threads:[~2026-08-04  7:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04  7:15 [PATCH 0/5] locking/qspinlock: Add contended_release tracepoint Dmitry Ilvokhin
2026-08-04  7:15 ` [PATCH 1/5] x86/paravirt: Use static_call() for the paravirt spinlock ops Dmitry Ilvokhin
2026-08-04  7:15 ` [PATCH 2/5] locking: Factor out queued_spin_release() Dmitry Ilvokhin
2026-08-04  7:15 ` [PATCH 3/5] locking/qspinlock: Add contended_release tracepoint Dmitry Ilvokhin
2026-08-04  7:36   ` sashiko-bot
2026-08-04  7:15 ` [PATCH 4/5] tracing/lock: Use TRACE_EVENT_FN() for contended_release Dmitry Ilvokhin
2026-08-04  7:15 ` [PATCH 5/5] x86/paravirt: Trace contended_release on unlock Dmitry Ilvokhin
2026-08-04  7:38   ` sashiko-bot
2026-08-04  7:57 ` Juergen Gross [this message]
2026-08-04 10:39 ` [PATCH 0/5] locking/qspinlock: Add contended_release tracepoint Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=627c59ee-54b1-4f37-b849-c331a9d01618@suse.com \
    --to=jgross@suse.com \
    --cc=ajay.kaher@broadcom.com \
    --cc=alexey.makhalov@broadcom.com \
    --cc=aliceryhl@google.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=boqun@kernel.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=d@ilvokhin.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kvm@vger.kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=longman@redhat.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=virtualization@lists.linux.dev \
    --cc=vkuznets@redhat.com \
    --cc=wei.liu@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox