[PATCH v2 19/21] srcutree: Add lockdep and early-boot checks to synchronize_srcu_atomic()

From: Paul E. McKenney

Date: Wed Oct 07 2026 - 17:00:41 EST


From: Kunwu Chan <kunwu.chan@xxxxxxxxx>

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

Suggested-by: Zqiang <qiang.zhang@xxxxxxxxx>
Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
Reviewed-by: Joel Fernandes <joelagnelf@xxxxxxxxxx>
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
---
kernel/rcu/srcutree.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 6e37d53b412e1..7890f7c7c2ee7 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -2122,6 +2122,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.40.1