mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] locking/lockdep: Use this_cpu_read() in lockdep_assert_RT_in_threaded_ctx()
@ 2026-11-28 19:04 Arun Iyengar via B4 Relay
  0 siblings, 0 replies; only message in thread
From: Arun Iyengar via B4 Relay @ 2026-11-28 19:04 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
	Waiman Long, Sebastian Andrzej Siewior, Clark Williams,
	Steven Rostedt, Thomas Gleixner
  Cc: linux-kernel, linux-rt-devel, syzbot+7227d49ef464b1dff36d, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

lockdep_hardirq_context() is raw_cpu_read(). In preemptible code the
task can migrate between computing the per-CPU address and the load, and
read another CPU's hardirq_context. complete_all() from process context
then warns "Not in threaded context on PREEMPT_RT as expected".

Commit baffd723e44d ("lockdep: Revert "lockdep: Use raw_cpu_*() for
per-cpu variables"") fixed this for the other lockdep_assert_*()
helpers but missed this one, which reads it via irqflags.h.

Use this_cpu_read() like the other helpers.

Fixes: fddf9055a60d ("lockdep: Use raw_cpu_*() for per-cpu variables")
Reported-by: syzbot+7227d49ef464b1dff36d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7227d49ef464b1dff36d
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Tested on an Orange Pi 5 (RK3588S) with KASAN and PROVE_RAW_LOCK_NESTING:
before, the WARN hit from a panthor drm_sched kworker (1 in 4 boots of
the same run); after, 0 lockdep/KASAN reports in 5 boots.

This patch was developed with Claude (Anthropic), which wrote the code
and the commit message. I reviewed every change.
---
 include/linux/lockdep.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index a6451ecbbe9a..d2a6840d03e8 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -644,7 +644,7 @@ extern void lockdep_assert_in_softirq_func(void);
 
 # define lockdep_assert_RT_in_threaded_ctx() do {			\
 		WARN_ONCE(debug_locks && !current->lockdep_recursion &&	\
-			  lockdep_hardirq_context() &&			\
+			  this_cpu_read(hardirq_context) &&		\
 			  !(current->hardirq_threaded || current->irq_config),	\
 			  "Not in threaded context on PREEMPT_RT as expected\n");	\
 } while (0)

---
base-commit: 8e7c6217be7f8c016975f5b0954f6736b9ac42cf
change-id: 20261128-lockdep-rt-threaded-b55b31489c1e

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-28 19:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 19:04 [PATCH] locking/lockdep: Use this_cpu_read() in lockdep_assert_RT_in_threaded_ctx() Arun Iyengar via B4 Relay

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®