mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	Boqun Feng <boqun@kernel.org>, Waiman Long <longman@redhat.com>,
	linux-kernel@vger.kernel.org, Marco Elver <elver@google.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	Bart Van Assche <bvanassche@acm.org>,
	Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH v2 06/14] locking/rwsem: Annotate rwsem internal functions with __must_hold()
Date: Mon,  9 Nov 2026 11:13:14 -0800	[thread overview]
Message-ID: <b71d72daebe303f97ac7250f4c78e33020395451.1794250850.git.bvanassche@acm.org> (raw)
In-Reply-To: <cover.1794250850.git.bvanassche@acm.org>

Annotate rwsem_del_waiter(), rwsem_mark_wake(), and
rwsem_cond_wake_waiter() with __must_hold(&sem->wait_lock).

rwsem_del_waiter(), rwsem_mark_wake(), and rwsem_cond_wake_waiter()
access members guarded by sem->wait_lock and call functions requiring
sem->wait_lock. Currently, lockdep_assert_held(&sem->wait_lock)
implicitly assumes lock ownership for Clang context analysis. Prepare
for removing the context assumption from lockdep_assert_held() by
explicitly annotating these functions with __must_hold(&sem->wait_lock).

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 kernel/locking/rwsem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index b9c180ac1eee..c76a3a712c31 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -392,6 +392,7 @@ bool __rwsem_del_waiter(struct rw_semaphore *sem, struct rwsem_waiter *waiter)
  */
 static inline bool
 rwsem_del_waiter(struct rw_semaphore *sem, struct rwsem_waiter *waiter)
+	__must_hold(&sem->wait_lock)
 {
 	lockdep_assert_held(&sem->wait_lock);
 	if (__rwsem_del_waiter(sem, waiter))
@@ -429,6 +430,7 @@ struct rwsem_waiter *next_waiter(const struct rw_semaphore *sem,
 static void rwsem_mark_wake(struct rw_semaphore *sem,
 			    enum rwsem_wake_type wake_type,
 			    struct wake_q_head *wake_q)
+	__must_hold(&sem->wait_lock)
 {
 	struct rwsem_waiter *waiter, *next;
 	long oldcount, woken = 0, adjustment = 0;
@@ -995,6 +997,7 @@ rwsem_spin_on_owner(struct rw_semaphore *sem)
  */
 static inline void rwsem_cond_wake_waiter(struct rw_semaphore *sem, long count,
 					  struct wake_q_head *wake_q)
+	__must_hold(&sem->wait_lock)
 {
 	enum rwsem_wake_type wake_type;
 

  parent reply	other threads:[~2026-11-09 19:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 19:13 [PATCH v2 00/14] Stop lockdep_assert_held*() from assuming lock ownership Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 01/14] bit_spinlock: Fix the __bitlock() definition Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 02/14] cleanup: Disable context analysis for __free() helpers Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 03/14] tracing: Disable branch profiling for COMPILE_TEST builds Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 04/14] srcu: Remove check from srcu_dereference_check() Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 05/14] futex: Annotate __attach_to_pi_owner() and fixup_pi_*owner() Bart Van Assche
2026-11-09 19:13 ` Bart Van Assche [this message]
2026-11-09 19:13 ` [PATCH v2 07/14] nvme-fabrics: Annotate nvmf_lookup_transport() with __must_hold_shared() Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 08/14] lockdep: Introduce lockdep_assume_ctx_held() Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 09/14] kfence: Use lockdep_assume_ctx_held() in kfence_report_error() Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 10/14] Bluetooth: Add lock context annotations for connection aliases Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 11/14] futex: Verify exit_mutex ownership in futex_exit_recursive() Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 12/14] lockdep: Stop lockdep_assert_held*() from assuming lock ownership Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 13/14] compiler-context-analysis: Split the RCU assertion tests Bart Van Assche
2026-11-09 19:13 ` [PATCH v2 14/14] rcu: Introduce lockdep_assume_in_rcu_*() Bart Van Assche

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=b71d72daebe303f97ac7250f4c78e33020395451.1794250850.git.bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=boqun@kernel.org \
    --cc=elver@google.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will@kernel.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

all inboxes | Powered by JetHome®