[PATCH] locking/lockdep: Use this_cpu_read() in lockdep_assert_RT_in_threaded_ctx()
From: Arun Iyengar via B4 Relay
Date: Sat Nov 28 2026 - 14:05:10 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=7227d49ef464b1dff36d
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
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@xxxxxxxxx>