srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic()
Subsystems (2)
PATCH 1/1 srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic()
Add the RCU_LOCKDEP_WARN and early-boot check that the Tree version gained, srcu_lock_sync() was already present.
--- kernel/rcu/srcutiny.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/rcu/srcutiny.c +6 -0
@@ -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.
Signature · 1 line
2.43.0
Paul E. McKenney
maintainerQuoted 5 lines · Kunwu Chan
Add the
RCU_LOCKDEP_WARNand early-boot check that the Tree version gained,srcu_lock_sync()was already present.Suggested-by Zqiang <[email protected]>Signed-off-by Kunwu Chan <[email protected]>
Queued for testing and review, thank you both!
Thanx, Paul
Quoted 24 lines
--- kernel/rcu/srcutiny.c | 6 ++++++ 1 file changed, 6 insertions(+)kernel/rcu/srcutiny.c +6
-0@@ -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. Signature · 1 line
2.43.0
Quoted 4 lines · Kunwu Chan
Add the
RCU_LOCKDEP_WARNand early-boot check that the Tree version gained,srcu_lock_sync()was already present.Suggested-by Zqiang <[email protected]>
Ok.
Quoted 10 lines
Signed-off-by Kunwu Chan <[email protected]>---
kernel/rcu/srcutiny.c| 6 ++++++1 file changed, 6 insertions(+)kernel/rcu/srcutiny.c +0
-0
kernel/rcu/srcutiny.c void synchronize_srcu_atomic(struct srcu_struct *ssp) · line 369
Quoted 9 lines
kernel/rcu/srcutiny.c +6
-0@@ -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 ; +
Wow!
kernel/rcu/srcutiny.c void synchronize_srcu_atomic(struct srcu_struct *ssp) · line 372
Quoted 4 lines
kernel/rcu/srcutiny.c +0
-0if (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.
Quoted 9 lines · Bradley Morgan
Quoted 4 lines · Kunwu Chan
Add the
RCU_LOCKDEP_WARNand early-boot check that the Tree version gained,srcu_lock_sync()was already present.Suggested-by Zqiang <[email protected]>Ok.
Reviewed-by Bradley Morgan <[email protected]>
Applied, thank you!
Quoted 13 lines
Quoted 13 lines
Signed-off-by Kunwu Chan <[email protected]>---
kernel/rcu/srcutiny.c| 6 ++++++1 file changed, 6 insertions(+)kernel/rcu/srcutiny.c +0
-0@@ -361,6 +361,12 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp)srcu_lock_sync (&ssp->dep_map);
Quoted 8 lines
kernel/rcu/srcutiny.c void synchronize_srcu_atomic(struct srcu_struct *ssp) · line 369
Quoted 6 lines
kernel/rcu/srcutiny.c +6
-0+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 ; +Wow!
If you think that this one is fun, take a look at the implementation of synchronize_rcu() in kernel/rcu/tiny.c. ;-)
Thanx, Paul
Quoted 7 lines
kernel/rcu/srcutiny.c void synchronize_srcu_atomic(struct srcu_struct *ssp) · line 372
Quoted 4 lines
kernel/rcu/srcutiny.c +0
-0if (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.
Quoted 37 lines · Paul E. McKenney
Quoted 1 line · Bradley Morgan
On 11 September 2026 17:09:13 BST, Kunwu Chan <[email protected]>
Quoted 8 lines · wrote:
Quoted 4 lines
Add the
RCU_LOCKDEP_WARNand early-boot check that the Tree version gained,srcu_lock_sync()was already present.Suggested-by Zqiang <[email protected]>Ok.
Reviewed-by Bradley Morgan <[email protected]>Applied, thank you!
Quoted 10 lines
kernel/rcu/srcutiny.c void synchronize_srcu_atomic(struct srcu_struct
Quoted 10 lines
Signed-off-by Kunwu Chan <[email protected]>---
kernel/rcu/srcutiny.c| 6 ++++++1 file changed, 6 insertions(+)kernel/rcu/srcutiny.c +0
-0@@ -361,6 +361,12 @@ void synchronize_srcu_atomic(struct srcu_struct*ssp)
Quoted 11 lines
kernel/rcu/srcutiny.c void synchronize_srcu_atomic(struct srcu_struct *ssp) · line 369
Quoted 9 lines
kernel/rcu/srcutiny.c +6
-0srcu_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 ; +Wow!
Quoted 2 lines
If you think that this one is fun, take a look at the implementation of
synchronize_rcu()inkernel/rcu/tiny.c. ;-)
void synchronize_rcu(void)
{
RCU_LOCKDEP_WARN(...);
preempt_disable();
WRITE_ONCE(rcu_ctrlblk.gp_seq, rcu_ctrlblk.gp_seq + 2);
preempt_enable();
}Hah!
Quoted 11 lines
Thanx, Paul
Quoted 7 lines
kernel/rcu/srcutiny.c void synchronize_srcu_atomic(struct srcu_struct *ssp)
Quoted 4 lines
kernel/rcu/srcutiny.c +0
-0if (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. --- Thanks!