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

From: Paul E. McKenney

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


From: Kunwu Chan <kunwu.chan@xxxxxxxxx>

Add the RCU_LOCKDEP_WARN and early-boot check that the Tree version
gained, srcu_lock_sync() was already present.

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

diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
index a31398def0b18..63a3f0a8bc53c 100644
--- a/kernel/rcu/srcutiny.c
+++ b/kernel/rcu/srcutiny.c
@@ -361,6 +361,12 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp)

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;
+
if (IS_ENABLED(CONFIG_PREEMPTION))
synchronize_rcu(); // Needed for RCU Tasks Trace to imply RCU grace period.
// And in Tiny RCU, it is near zero cost and doesn't block.
--
2.40.1