mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,  Will Deacon <will@kernel.org>,
	Boqun Feng <boqun@kernel.org>,  Waiman Long <longman@redhat.com>,
	 Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	 Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	 Thomas Gleixner <tglx@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	 syzbot+7227d49ef464b1dff36d@syzkaller.appspotmail.com,
	 Arun Iyengar <aiyengar1990@gmail.com>
Subject: [PATCH] locking/lockdep: Use this_cpu_read() in lockdep_assert_RT_in_threaded_ctx()
Date: Sat, 28 Nov 2026 19:04:59 +0000	[thread overview]
Message-ID: <20261128-lockdep-rt-threaded-v1-1-7976173c8c49@gmail.com> (raw)

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>



                 reply	other threads:[~2026-11-28 19:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261128-lockdep-rt-threaded-v1-1-7976173c8c49@gmail.com \
    --to=devnull+aiyengar1990.gmail.com@kernel.org \
    --cc=aiyengar1990@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=boqun@kernel.org \
    --cc=clrkwllms@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=syzbot+7227d49ef464b1dff36d@syzkaller.appspotmail.com \
    --cc=tglx@kernel.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®