From nobody Thu Apr 16 20:47:14 2026 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (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 4E8FF3E8C7E for ; Wed, 25 Feb 2026 18:33:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044395; cv=none; b=muOUufWoAKWWpnxo3D20m0WTIi8jYAEH6xCmZjoJW3FowhboUTO1d7TkcPhQfxGwntDD2d4jebYCNH3yY6YfwMPJUYGYebFIxa1rXLFFVQFLJCK131wH6A2VR3NDdbcebXDWz8Vnwm3pkAwgkZUftIWCYlJkxNroQdAOEo1YU74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044395; c=relaxed/simple; bh=Fd4QlCBS3XMnSIway4RbUXxL5YviEZl8ExUm2osGkpA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BBQlT7JBsCq3xD2sgpHZguvwgGUJmSbnclepdzEblnagAmWqwIqj0cOub6RZPWtaUAJOBvlp/Kcu6TGQo2cGq03LgTBQec1utmM9fftMvzAplz9YlD7FLtMZ3srRo7n0m8HaTsyw/md4A3VC2PhzZukX9ob6Yf22E/T3aRPhAu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=hakl+frb; arc=none smtp.client-ip=199.89.1.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="hakl+frb" Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4fLjrh4Khsz1XM2FV; Wed, 25 Feb 2026 18:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1772044385; x=1774636386; bh=bJsiK ilVTOjUjVpr8rpy6omMf5I66gmtmucJY1LyA+g=; b=hakl+frbV2+2mTGWzyncd KMW4pVLfd2RAgiAeH1lDkgvSHh1ZR87VxcCoQjQ6Ob6jNiMdWgyZEfzG8Q4ArRi+ 1uFu/VWP40KK2FqEpT6n0xvZj4bAWrITeBYEMMswKDGEqVrL7tgS2uZPhgO+OOeO RZ5G5kpDgYkFb05nxWsQra6G4sG6JbaasXGQyXPnoCXw7Ol0KTvP3/Lwz6s1JsBk yRaBrf38FpGTIqsAzbpXKfKgA2nvrjrFc+G+/lKEsAUBxoi8dJ8xZuVsjg85zxuc IqberseY6nhjjSnpqhsDN5JMbHEM267VgHr5puvI/OQb8fK4dMG9MoIwv/ZAnNZu w== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id ZihB9OKn3UOn; Wed, 25 Feb 2026 18:33:05 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.180.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4fLjrZ38rkz1XM6J7; Wed, 25 Feb 2026 18:33:02 +0000 (UTC) From: Bart Van Assche To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org, Marco Elver , Christoph Hellwig , Steven Rostedt , Nick Desaulniers , Nathan Chancellor , Kees Cook , Jann Horn , Bart Van Assche Subject: [PATCH v2 1/4] locking: Fix rwlock and spinlock lock context annotations Date: Wed, 25 Feb 2026 10:32:41 -0800 Message-ID: <20260225183244.4035378-2-bvanassche@acm.org> X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog In-Reply-To: <20260225183244.4035378-1-bvanassche@acm.org> References: <20260225183244.4035378-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix two incorrect rwlock_t lock context annotations. Add the raw_spinlock_t lock context annotations that are missing. Fixes: f16a802d402d ("locking/rwlock, spinlock: Support Clang's context ana= lysis") Signed-off-by: Bart Van Assche --- include/linux/rwlock.h | 4 ++-- include/linux/rwlock_api_smp.h | 6 ++++-- include/linux/spinlock.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h index 3390d21c95dd..21ceefc4a49f 100644 --- a/include/linux/rwlock.h +++ b/include/linux/rwlock.h @@ -30,10 +30,10 @@ do { \ =20 #ifdef CONFIG_DEBUG_SPINLOCK extern void do_raw_read_lock(rwlock_t *lock) __acquires_shared(lock); - extern int do_raw_read_trylock(rwlock_t *lock); + extern int do_raw_read_trylock(rwlock_t *lock) __cond_acquires_shared(tru= e, lock); extern void do_raw_read_unlock(rwlock_t *lock) __releases_shared(lock); extern void do_raw_write_lock(rwlock_t *lock) __acquires(lock); - extern int do_raw_write_trylock(rwlock_t *lock); +extern int do_raw_write_trylock(rwlock_t *lock) __cond_acquires(true, lock= ); extern void do_raw_write_unlock(rwlock_t *lock) __releases(lock); #else # define do_raw_read_lock(rwlock) do {__acquire_shared(lock); arch_read_lo= ck(&(rwlock)->raw_lock); } while (0) diff --git a/include/linux/rwlock_api_smp.h b/include/linux/rwlock_api_smp.h index 61a852609eab..9e02a5f28cd1 100644 --- a/include/linux/rwlock_api_smp.h +++ b/include/linux/rwlock_api_smp.h @@ -23,7 +23,7 @@ void __lockfunc _raw_write_lock_bh(rwlock_t *lock) __acqu= ires(lock); void __lockfunc _raw_read_lock_irq(rwlock_t *lock) __acquires_shared(lock); void __lockfunc _raw_write_lock_irq(rwlock_t *lock) __acquires(lock); unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock) - __acquires(lock); + __acquires_shared(lock); unsigned long __lockfunc _raw_write_lock_irqsave(rwlock_t *lock) __acquires(lock); int __lockfunc _raw_read_trylock(rwlock_t *lock) __cond_acquires_shared(tr= ue, lock); @@ -36,7 +36,7 @@ void __lockfunc _raw_read_unlock_irq(rwlock_t *lock) __re= leases_shared(lock); void __lockfunc _raw_write_unlock_irq(rwlock_t *lock) __releases(lock); void __lockfunc _raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) - __releases(lock); + __releases_shared(lock); void __lockfunc _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) __releases(lock); @@ -116,6 +116,7 @@ _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned l= ong flags) #endif =20 static inline int __raw_read_trylock(rwlock_t *lock) + __cond_acquires_shared(true, lock) { preempt_disable(); if (do_raw_read_trylock(lock)) { @@ -127,6 +128,7 @@ static inline int __raw_read_trylock(rwlock_t *lock) } =20 static inline int __raw_write_trylock(rwlock_t *lock) + __cond_acquires(true, lock) { preempt_disable(); if (do_raw_write_trylock(lock)) { diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index e1e2f144af9b..241277cd34cf 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -178,7 +178,7 @@ do { \ =20 #ifdef CONFIG_DEBUG_SPINLOCK extern void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock); - extern int do_raw_spin_trylock(raw_spinlock_t *lock); + extern int do_raw_spin_trylock(raw_spinlock_t *lock) __cond_acquires(true= , lock); extern void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock); #else static inline void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock) @@ -189,6 +189,7 @@ static inline void do_raw_spin_lock(raw_spinlock_t *loc= k) __acquires(lock) } =20 static inline int do_raw_spin_trylock(raw_spinlock_t *lock) + __cond_acquires(true, lock) { int ret =3D arch_spin_trylock(&(lock)->raw_lock); =20 From nobody Thu Apr 16 20:47:14 2026 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (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 7F0112FFDEB for ; Wed, 25 Feb 2026 18:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044394; cv=none; b=L32trfTqsYl68XUzjELX8jo7vo/h3d1h7YR7AHriTTOd7enzwQxEEPP5djwbFLJ5ZRWfH355fEO7XK0JNSdtaZmLkwCJcBuDdPnd/5GWIhXObIDnyu4LR8RmMxLcTVcsJ519RuRrLF0L3SgVVeguE/9xjLGxiBA11lqaPtxjkoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044394; c=relaxed/simple; bh=6f9GfGJ2Gzu7ZYLkSWFpmuY/tkL1/aIu9THuv+5mV/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O0mfNDeei8GwUspQGrZqRbW2t1ZujR+4HpITuWCrT+8/iGip2NApeDHIin5SfLCPp2tgGlIPlmhhuKrBNDEuugdyykhf1gH3+WxGyklrorMMM5yY9ljN1KiZ7ORJ0XuQbLLyXxIV4P2ivbH1z2SAqJ0Rkx4srovoxUiqzqYwz18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=qrdPQNd/; arc=none smtp.client-ip=199.89.1.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="qrdPQNd/" Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4fLjrl3N3pz1XM0nj; Wed, 25 Feb 2026 18:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1772044388; x=1774636389; bh=qTAu5 42T8RbwwcrRZ0FBJa2c/ejJrRXMOJ9faNFLEC0=; b=qrdPQNd/gWM31fN+9XXvb el0jjuZYX+oUVBEo1xjJPVMaKZXHlGuwIq4EEuRwHR6kYCZMn0zFnrYa3O8yXY0/ L0WDn+UGajyatTrJyekxMoboPLGstg+jv1K2uJXYACPOZ+/YLr8yQLIxYN4vVpUX B01FSxXpkn4h1Spsoy1xBPf/k7JBXi1JKOW91ihF215b9AQR6fbFohyJK1FhyOHa E++UZVxifAkkLdjB1NeIFNXErRQAIlVbJa8qVyR79TMlbtmF4p0U1XuSh9ztfDon 4Zj7Cq+ATHY13RB1rLENoGjooRHxJb+cwWva9xXVDdqplB5qRhFK97J3BpOPkzZt w== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id Gj1AnTdlv0pm; Wed, 25 Feb 2026 18:33:08 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.180.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4fLjrd6hvZz1XM6J6; Wed, 25 Feb 2026 18:33:05 +0000 (UTC) From: Bart Van Assche To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org, Marco Elver , Christoph Hellwig , Steven Rostedt , Nick Desaulniers , Nathan Chancellor , Kees Cook , Jann Horn , Bart Van Assche Subject: [PATCH v2 2/4] signal: Fix the lock_task_sighand() annotation Date: Wed, 25 Feb 2026 10:32:42 -0800 Message-ID: <20260225183244.4035378-3-bvanassche@acm.org> X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog In-Reply-To: <20260225183244.4035378-1-bvanassche@acm.org> References: <20260225183244.4035378-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" lock_task_sighand() may return NULL. Make this clear in its lock context annotation. Fixes: 04e49d926f43 ("sched: Enable context analysis for core.c and fair.c") Signed-off-by: Bart Van Assche --- include/linux/sched/signal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index a22248aebcf9..a4835a7de07e 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -739,7 +739,7 @@ static inline int thread_group_empty(struct task_struct= *p) =20 extern struct sighand_struct *lock_task_sighand(struct task_struct *task, unsigned long *flags) - __acquires(&task->sighand->siglock); + __cond_acquires(nonnull, &task->sighand->siglock); =20 static inline void unlock_task_sighand(struct task_struct *task, unsigned long *flags) From nobody Thu Apr 16 20:47:14 2026 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (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 943743ED126 for ; Wed, 25 Feb 2026 18:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044396; cv=none; b=luJwsKGXRsXiL5rYXa+I+Fy+aFhh4budEUq/NMOaKfd/GAlpS65A0sGq4JNxNGoN9GMuGyGHP78Gimee3i6qmjpdEDKtl00fPiXjc4cx51kkG0UmIuN5U2o4ia55zAC94OUMvdZ4AT9X02uMHYaWts3qRKHWZyMz/eO/+NS9Ydo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044396; c=relaxed/simple; bh=bVc8/yuQKV9ZGwPf1skKx7qKYQwCrbEuzZfPlLKdW50=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I1bkdEppLXeiFpH//XgRIflRu7PhacltLroESnaHDsubVMc9dmdLBtECm0bOFZIECmEKKheDd3fQUiiapPT2JaNapVfD8IwpwxwpJpuc89flioo2rw/SSTuwKuCyU2yn+zFOKyP2ocGK8eHM3rT004bwNNLkrFShrGUruGEnBtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=L/MMCT7i; arc=none smtp.client-ip=199.89.1.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="L/MMCT7i" Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4fLjrq2GhVz1XM0nk; Wed, 25 Feb 2026 18:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1772044392; x=1774636393; bh=AGA+j aypXAgRXpOJm/1iaZK05pDP/k1iT1kI0HMoyew=; b=L/MMCT7i/ANeKRqhRw2q2 MwtEw6ovyMFZIDosglNqOr6nfjvRmUZEUl9FVL98GmNFNAqSFNgjjoQhLGB5Q36J m3vIX+9j9f0ssJuRA9wduPKJucXdoqeVxBO99Q4RfHgCKexzWbXvDczmeJsF8dxp oO+kM17nmfpvZShHjFuEqLe/bl0A0lItEWKcweTR7EETLSVuSdZ8OI5EoSYUAJBH 1a0AXu1/LweJD25yfHxvXSzIRXL0OkDH7AjyBGXO3jnWapXLdW/DyKushrxaJpwZ w2UqGKOcVwDA87bTp6Y5OLpoP4X1fuwXC1LY9oqkoR03F8PwIXFbMNQXjhLshu5H Q== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id wIypbyyZm6LL; Wed, 25 Feb 2026 18:33:12 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.180.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4fLjrj0Jmxz1XM6J5; Wed, 25 Feb 2026 18:33:08 +0000 (UTC) From: Bart Van Assche To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org, Marco Elver , Christoph Hellwig , Steven Rostedt , Nick Desaulniers , Nathan Chancellor , Kees Cook , Jann Horn , Bart Van Assche , Maarten Lankhorst Subject: [PATCH v2 3/4] ww-mutex: Fix the ww_acquire_ctx function annotations Date: Wed, 25 Feb 2026 10:32:43 -0800 Message-ID: <20260225183244.4035378-4-bvanassche@acm.org> X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog In-Reply-To: <20260225183244.4035378-1-bvanassche@acm.org> References: <20260225183244.4035378-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The ww_acquire_done() call is optional. Reflect this in the annotations of ww_acquire_done(). Acked-by: Maarten Lankhorst Fixes: 47907461e4f6 ("locking/ww_mutex: Support Clang's context analysis") Signed-off-by: Bart Van Assche --- include/linux/ww_mutex.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h index 85b1fff02fde..0c95ead5a297 100644 --- a/include/linux/ww_mutex.h +++ b/include/linux/ww_mutex.h @@ -181,7 +181,7 @@ static inline void ww_acquire_init(struct ww_acquire_ct= x *ctx, * data structures. */ static inline void ww_acquire_done(struct ww_acquire_ctx *ctx) - __releases(ctx) __acquires_shared(ctx) __no_context_analysis + __must_hold(ctx) { #ifdef DEBUG_WW_MUTEXES lockdep_assert_held(ctx); @@ -199,7 +199,7 @@ static inline void ww_acquire_done(struct ww_acquire_ct= x *ctx) * mutexes have been released with ww_mutex_unlock. */ static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx) - __releases_shared(ctx) __no_context_analysis + __releases(ctx) __no_context_analysis { #ifdef CONFIG_DEBUG_LOCK_ALLOC mutex_release(&ctx->first_lock_dep_map, _THIS_IP_); From nobody Thu Apr 16 20:47:14 2026 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (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 5B9873ECBFC for ; Wed, 25 Feb 2026 18:33:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044399; cv=none; b=fYGqWv6AWRQyKOT36JdOKcwKZY1/CktKiKrcei1iCNvAAXYSlKZ4Sn7N37ETEJsvKasGRlmIb2wOGiMxr4aZFVNh4NsUG+GAL+Mm2ov3cf+pK88NaSMV/pOCNVpp1Ns7UGlQUPAivMQ3/vFw2Xa9q4mhCHuld/TXvkIRkFmrj+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772044399; c=relaxed/simple; bh=19hrkUbABf0879zue0vUyB3SmJbLRsSTgHGYjcRaEME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LnW3nbJ9DXIiIhXgic33b27oM5Ui6lEb1YMHzICs2baM7CMy1GXBQJIf9jZUwCK4U0j1P+UUSbawmvZ/kN3nLLYQydm/0qtHm485R0bUHfy2G+ezWFUDUpXBhIePpBI9OJwa1Fkr00GMND6EAQXJZXF4F8S0usUUI6aUcgacwxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=GysPJpK1; arc=none smtp.client-ip=199.89.1.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="GysPJpK1" Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4fLjrt026rz1XM6J5; Wed, 25 Feb 2026 18:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1772044395; x=1774636396; bh=uPGzJ hbmcqdlWn8EvwtNYMBLjrN6vXAhnzgQdGow0u4=; b=GysPJpK1LoIr634kBp3+0 UDCWLIhIH1TGctXZToCmKRAHQkdb9xKUqrC8o6B6NhdBradhU3XW1u6j/bl0mx4d uAV9GvNMvuiZdrVZb2EPZ2K3vGFF/4x/NdoxwMh3N7WBdXGW5LwlXoQuItPGBiz8 Sn8tungCv+EnGEhC8gXA4hwo36Rh6VaZCWxOpgnr+rshklmn1NM6GmCUhwSxmpP/ vyGMAW8CV0jnEBQW4Ow9GYVWMaurx4P7/E9bnk+Ljr3Kzt5H3N+tiDpbAbJWGXOU aKL3RQyaZbMn7nTXx5UP6+v9WIMZb3NKqVkqg4MvurVl3ws6wXwl1pFozNTN3EdP g== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 5SXgN415q68w; Wed, 25 Feb 2026 18:33:15 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.180.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4fLjrm2ddYz1XM6J6; Wed, 25 Feb 2026 18:33:12 +0000 (UTC) From: Bart Van Assche To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org, Marco Elver , Christoph Hellwig , Steven Rostedt , Nick Desaulniers , Nathan Chancellor , Kees Cook , Jann Horn , Bart Van Assche Subject: [PATCH v2 4/4] Revert "lockdep: Annotate lockdep assertions for context analysis" Date: Wed, 25 Feb 2026 10:32:44 -0800 Message-ID: <20260225183244.4035378-5-bvanassche@acm.org> X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog In-Reply-To: <20260225183244.4035378-1-bvanassche@acm.org> References: <20260225183244.4035378-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" lockdep_assert_held() supports all data structures that have a member with the name dep_map. __assume_ctx_lock() only supports data structures that support lock context annotation. Remove __assume_ctx_lock() from lockdep_assert_held(). This patch fixes the following build errors if lock context analysis is enabled for the entire kernel tree: drivers/tty/tty_ldisc.c:451:2: error: call to '__assume_ctx_lock' is ambigu= ous 451 | lockdep_assert_held_write(&tty->ldisc_sem); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/tty_ldisc.c:451:2: error: call to '__assume_ctx_lock' is ambigu= ous 451 | lockdep_assert_held_write(&tty->ldisc_sem); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 7c451541743c ("lockdep: Annotate lockdep assertions for context anal= ysis") Signed-off-by: Bart Van Assche --- include/linux/lockdep.h | 12 ++++++------ lib/test_context-analysis.c | 6 +++--- mm/kfence/report.c | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 621566345406..dd634103b014 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -282,16 +282,16 @@ extern void lock_unpin_lock(struct lockdep_map *lock,= struct pin_cookie); do { WARN_ON_ONCE(debug_locks && !(cond)); } while (0) =20 #define lockdep_assert_held(l) \ - do { lockdep_assert(lockdep_is_held(l) !=3D LOCK_STATE_NOT_HELD); __assum= e_ctx_lock(l); } while (0) + lockdep_assert(lockdep_is_held(l) !=3D LOCK_STATE_NOT_HELD) =20 #define lockdep_assert_not_held(l) \ lockdep_assert(lockdep_is_held(l) !=3D LOCK_STATE_HELD) =20 #define lockdep_assert_held_write(l) \ - do { lockdep_assert(lockdep_is_held_type(l, 0)); __assume_ctx_lock(l); } = while (0) + lockdep_assert(lockdep_is_held_type(l, 0)) =20 #define lockdep_assert_held_read(l) \ - do { lockdep_assert(lockdep_is_held_type(l, 1)); __assume_shared_ctx_lock= (l); } while (0) + lockdep_assert(lockdep_is_held_type(l, 1)) =20 #define lockdep_assert_held_once(l) \ lockdep_assert_once(lockdep_is_held(l) !=3D LOCK_STATE_NOT_HELD) @@ -389,10 +389,10 @@ extern int lockdep_is_held(const void *); #define lockdep_assert(c) do { } while (0) #define lockdep_assert_once(c) do { } while (0) =20 -#define lockdep_assert_held(l) __assume_ctx_lock(l) +#define lockdep_assert_held(l) do { (void)(l); } while (0) #define lockdep_assert_not_held(l) do { (void)(l); } while (0) -#define lockdep_assert_held_write(l) __assume_ctx_lock(l) -#define lockdep_assert_held_read(l) __assume_shared_ctx_lock(l) +#define lockdep_assert_held_write(l) do { (void)(l); } while (0) +#define lockdep_assert_held_read(l) do { (void)(l); } while (0) #define lockdep_assert_held_once(l) do { (void)(l); } while (0) #define lockdep_assert_none_held_once() do { } while (0) =20 diff --git a/lib/test_context-analysis.c b/lib/test_context-analysis.c index 140efa8a9763..9846da75e9a3 100644 --- a/lib/test_context-analysis.c +++ b/lib/test_context-analysis.c @@ -68,7 +68,7 @@ static void __used test_common_helpers(void) } \ static void __used test_##class##_assert(struct test_##class##_data *d) = \ { \ - lockdep_assert_held(&d->lock); \ + __assume_ctx_lock(&d->lock); \ op(d->counter); \ } \ static void __used test_##class##_guard(struct test_##class##_data *d) \ @@ -199,7 +199,7 @@ static void __used test_mutex_trylock(struct test_mutex= _data *d, atomic_t *a) =20 static void __used test_mutex_assert(struct test_mutex_data *d) { - lockdep_assert_held(&d->mtx); + __assume_ctx_lock(&d->mtx); d->counter++; } =20 @@ -311,7 +311,7 @@ static void __used test_rwsem_writer(struct test_rwsem_= data *d) =20 static void __used test_rwsem_assert(struct test_rwsem_data *d) { - rwsem_assert_held_nolockdep(&d->sem); + __assume_ctx_lock(&d->sem); d->counter++; } =20 diff --git a/mm/kfence/report.c b/mm/kfence/report.c index 787e87c26926..d50a3f256650 100644 --- a/mm/kfence/report.c +++ b/mm/kfence/report.c @@ -263,6 +263,7 @@ void kfence_report_error(unsigned long address, bool is= _write, struct pt_regs *r =20 if (meta) { lockdep_assert_held(&meta->lock); + __assume_ctx_lock(&meta->lock); pr_err("\n"); kfence_print_object(NULL, meta); }