From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D9FE342532 for ; Wed, 13 May 2026 15:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778686992; cv=none; b=aNJn1osOGAZMOHsL0f1r90O9Gjalyle47XHkFX3/omkDWtouaEAU8qEtenhQcLP4rzz7dlem2wRDqlGrmx1UgahhyAT5Y1g0G1/QTPh4Dz62T09UW8Bvs9Bpepl9hVlBZw9sQcULKhZT3nlMg7QWqT5SEgQA8uBEzkKOxZNaZHQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778686992; c=relaxed/simple; bh=gkRQjgXAOUtsQDsoJPrjl1J5lhzGoe8KMasfHcOGNSk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ibsvkR95Ck2rvxlPGpzC5FWlYnMorvDzGUiurxdev6XVaVrU4+VV4TuEovbkuJRqrkj0VLlOVpZIRtvCP1Dv6wQau+k/Z90YZ7C6tBx0zzwGv6aKCVRBVY75kZ1Vg7qPgZZtdZK9jihoZiAT5ZYAPpTqMM3PDrHptuj5dKgktP8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; arc=none smtp.client-ip=216.40.44.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Received: from omf02.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 49B49C0439; Wed, 13 May 2026 15:43:08 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf02.hostedemail.com (Postfix) with ESMTPA id AF64F8000F; Wed, 13 May 2026 15:43:02 +0000 (UTC) Date: Wed, 13 May 2026 11:43:05 -0400 From: Steven Rostedt To: Dmitry Ilvokhin Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Thomas Bogendoerfer , Juergen Gross , Ajay Kaher , Alexey Makhalov , Broadcom internal kernel review list , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Arnd Bergmann , Dennis Zhou , Tejun Heo , Christoph Lameter , Masami Hiramatsu , Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, virtualization@lists.linux.dev, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v6 7/7] locking: Add contended_release tracepoint to qrwlock Message-ID: <20260513114305.21ffc98f@gandalf.local.home> In-Reply-To: References: X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: AF64F8000F X-Rspamd-Server: rspamout06 X-Stat-Signature: w86rrez7eqwjzfhgqoxgq67qhkb7x9up X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX19Ry8RzWesZfFcKD7J3lfQK7el56ZbsoNM= X-HE-Tag: 1778686982-257566 X-HE-Meta: U2FsdGVkX191OTt5Ksd6rUOT63By4bRHO3knmbxlImxeNwSRm6MiHtOjFX4vJPI7crm7BSyrSIbvYT2WqOIcyORlXBEY2Q745H1gRnZgzxFxnZc2Bi+ODYvQqGyzbt0gxBvY2ORVu7Y4GQ21a4wpv6/a90k23BYL7etn+PwAjOo5gxJiydIgCFloW6Mpqm0UrvbWwABEN81N7oFp14CVTY728nkwzhqSyPCqbUhdm6Gp7kGkEzhfOsmKyTBnoEo7WZmXFfbv5M1ZAKLN8diVSXcT2j7/QCb3HvSSmT0BmXISJ4AvPIW0Eh8Dhn0nmq6iowz0POq6263XgbEXZQ9JarrVBkMeNNzrxBaehT1mK01cf9rA6EvFjUu8THAnEVExi+n7p8EX5+Ja1SfaAhM8P576YgkfJW2f On Tue, 5 May 2026 17:09:36 +0000 Dmitry Ilvokhin wrote: > Extend the contended_release tracepoint to queued rwlocks, using the > same out-of-line traced unlock approach as queued spinlocks. > > Signed-off-by: Dmitry Ilvokhin > --- > include/asm-generic/qrwlock.h | 22 ++++++++++++++++++++++ > kernel/locking/qrwlock.c | 16 ++++++++++++++++ > 2 files changed, 38 insertions(+) > > diff --git a/include/asm-generic/qrwlock.h b/include/asm-generic/qrwlock.h > index 4b627bafba8b..274c19006125 100644 > --- a/include/asm-generic/qrwlock.h > +++ b/include/asm-generic/qrwlock.h > @@ -14,6 +14,7 @@ > #define __ASM_GENERIC_QRWLOCK_H > > #include > +#include > #include > #include > > @@ -35,6 +36,10 @@ > */ > extern void queued_read_lock_slowpath(struct qrwlock *lock); > extern void queued_write_lock_slowpath(struct qrwlock *lock); > +extern void queued_read_unlock_traced(struct qrwlock *lock); > +extern void queued_write_unlock_traced(struct qrwlock *lock); > + > +DECLARE_TRACEPOINT(contended_release); > > /** > * queued_read_trylock - try to acquire read lock of a queued rwlock > @@ -115,6 +120,17 @@ static __always_inline void __queued_read_unlock(struct qrwlock *lock) > */ > static inline void queued_read_unlock(struct qrwlock *lock) > { > + /* > + * Trace and unlock are combined in the traced unlock variant so > + * the compiler does not need to preserve the lock pointer across > + * the function call, avoiding callee-saved register save/restore > + * on the hot path. > + */ > + if (tracepoint_enabled(contended_release)) { > + queued_read_unlock_traced(lock); Same issue here about duplicating the code. > + return; > + } > + > __queued_read_unlock(lock); > } > > @@ -129,6 +145,12 @@ static __always_inline void __queued_write_unlock(struct qrwlock *lock) > */ > static inline void queued_write_unlock(struct qrwlock *lock) > { > + /* See comment in queued_read_unlock(). */ > + if (tracepoint_enabled(contended_release)) { > + queued_write_unlock_traced(lock); And here. > + return; > + } > + > __queued_write_unlock(lock); > } > > diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c > index d2ef312a8611..5ae4b0372719 100644 > --- a/kernel/locking/qrwlock.c > +++ b/kernel/locking/qrwlock.c > @@ -90,3 +90,19 @@ void __lockfunc queued_write_lock_slowpath(struct qrwlock *lock) > trace_contention_end(lock, 0); > } > EXPORT_SYMBOL(queued_write_lock_slowpath); > + > +void __lockfunc queued_read_unlock_traced(struct qrwlock *lock) > +{ > + if (queued_rwlock_is_contended(lock)) > + trace_call__contended_release(lock); Just have this trace and not actually do any locking. > + __queued_read_unlock(lock); > +} > +EXPORT_SYMBOL(queued_read_unlock_traced); > + > +void __lockfunc queued_write_unlock_traced(struct qrwlock *lock) > +{ > + if (queued_rwlock_is_contended(lock)) > + trace_call__contended_release(lock); Ditto. -- Steve > + __queued_write_unlock(lock); > +} > +EXPORT_SYMBOL(queued_write_unlock_traced);