mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] srcutree: Add lockdep and early-boot checks to synchronize_srcu_atomic()
@ 2026-09-11  9:35 Kunwu Chan
  2026-09-11 16:47 ` Paul E. McKenney
  0 siblings, 1 reply; 7+ messages in thread
From: Kunwu Chan @ 2026-09-11  9:35 UTC (permalink / raw)
  To: jiangshanlai, paulmck
  Cc: josh, rostedt, mathieu.desnoyers, rcu, linux-kernel, Kunwu Chan, Zqiang

Add the lockdep annotation, same-type SRCU nesting warning, and
early-boot check used by __synchronize_srcu().

Suggested-by: Zqiang <qiang.zhang@linux.dev>
Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
---
 kernel/rcu/srcutree.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 6a9c432a3bd0..6c729e805fb3 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -2123,6 +2123,14 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp)
 	unsigned long rdm0, rdm1;
 	unsigned long unlocks0, unlocks1;
 
+	srcu_lock_sync(&ssp->dep_map);
+
+	RCU_LOCKDEP_WARN(lockdep_is_held(ssp),
+			 "Illegal synchronize_srcu_atomic() in same-type SRCU read-side critical section");
+
+	if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE)
+		return;
+
 	// Initialize.	Either init_srcu_struct() was invoked or
 	// DEFINE_SRCU() or similar was used.  Therefore, no allocation
 	// will be done here.
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-13 10:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11  9:35 [PATCH] srcutree: Add lockdep and early-boot checks to synchronize_srcu_atomic() Kunwu Chan
2026-09-11 16:47 ` Paul E. McKenney
2026-09-12 12:37   ` KunWu Chan
2026-09-12 18:50     ` Paul E. McKenney
2026-09-13  6:21       ` Zqiang
2026-09-13 10:36         ` KunWu Chan
2026-09-13 10:23       ` KunWu Chan

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®