* [PATCH] srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic()
@ 2026-09-11 16:09 Kunwu Chan
2026-09-11 17:14 ` Paul E. McKenney
2026-09-11 21:18 ` Bradley Morgan
0 siblings, 2 replies; 5+ messages in thread
From: Kunwu Chan @ 2026-09-11 16:09 UTC (permalink / raw)
To: paulmck, jiangshanlai, josh
Cc: rostedt, mathieu.desnoyers, rcu, linux-kernel, Kunwu Chan, Zqiang
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@linux.dev>
Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
---
kernel/rcu/srcutiny.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
index 99f8bfd98b04..76411562366f 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.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic()
2026-09-11 16:09 [PATCH] srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic() Kunwu Chan
@ 2026-09-11 17:14 ` Paul E. McKenney
2026-09-11 21:18 ` Bradley Morgan
1 sibling, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2026-09-11 17:14 UTC (permalink / raw)
To: Kunwu Chan
Cc: jiangshanlai, josh, rostedt, mathieu.desnoyers, rcu,
linux-kernel, Zqiang
On Sat, Sep 12, 2026 at 12:09:13AM +0800, Kunwu Chan wrote:
> 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@linux.dev>
> Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
Queued for testing and review, thank you both!
Thanx, Paul
> ---
> kernel/rcu/srcutiny.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
> index 99f8bfd98b04..76411562366f 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.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic()
2026-09-11 16:09 [PATCH] srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic() Kunwu Chan
2026-09-11 17:14 ` Paul E. McKenney
@ 2026-09-11 21:18 ` Bradley Morgan
2026-09-11 23:12 ` Paul E. McKenney
1 sibling, 1 reply; 5+ messages in thread
From: Bradley Morgan @ 2026-09-11 21:18 UTC (permalink / raw)
To: kunwu.chan
Cc: jiangshanlai, josh, linux-kernel, mathieu.desnoyers, paulmck,
qiang.zhang, rcu, rostedt
On 11 September 2026 17:09:13 BST, Kunwu Chan <kunwu.chan@gmail.com> wrote:
>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@linux.dev>
Ok.
Reviewed-by: Bradley Morgan <brads@mainlining.org>
>Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
>---
> kernel/rcu/srcutiny.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
>index 99f8bfd98b04..76411562366f 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;
>+
Wow!
> 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.
>
--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic()
2026-09-11 21:18 ` Bradley Morgan
@ 2026-09-11 23:12 ` Paul E. McKenney
2026-09-11 23:19 ` Bradley Morgan
0 siblings, 1 reply; 5+ messages in thread
From: Paul E. McKenney @ 2026-09-11 23:12 UTC (permalink / raw)
To: Bradley Morgan
Cc: kunwu.chan, jiangshanlai, josh, linux-kernel, mathieu.desnoyers,
qiang.zhang, rcu, rostedt
On Fri, Sep 11, 2026 at 10:18:04PM +0100, Bradley Morgan wrote:
> On 11 September 2026 17:09:13 BST, Kunwu Chan <kunwu.chan@gmail.com> wrote:
> >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@linux.dev>
>
> Ok.
>
> Reviewed-by: Bradley Morgan <brads@mainlining.org>
Applied, thank you!
> >Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
> >---
> > kernel/rcu/srcutiny.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> >diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
> >index 99f8bfd98b04..76411562366f 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;
> >+
>
> 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
> > 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.
> >
>
> --- Thanks!
> https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic()
2026-09-11 23:12 ` Paul E. McKenney
@ 2026-09-11 23:19 ` Bradley Morgan
0 siblings, 0 replies; 5+ messages in thread
From: Bradley Morgan @ 2026-09-11 23:19 UTC (permalink / raw)
To: paulmck, Paul E. McKenney
Cc: kunwu.chan, jiangshanlai, josh, linux-kernel, mathieu.desnoyers,
qiang.zhang, rcu, rostedt
On 12 September 2026 00:12:25 BST, "Paul E. McKenney" <paulmck@kernel.org>
wrote:
>On Fri, Sep 11, 2026 at 10:18:04PM +0100, Bradley Morgan wrote:
>> On 11 September 2026 17:09:13 BST, Kunwu Chan <kunwu.chan@gmail.com>
>wrote:
>> >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@linux.dev>
>>
>> Ok.
>>
>> Reviewed-by: Bradley Morgan <brads@mainlining.org>
>
>Applied, thank you!
>
>> >Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
>> >---
>> > kernel/rcu/srcutiny.c | 6 ++++++
>> > 1 file changed, 6 insertions(+)
>> >
>> >diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
>> >index 99f8bfd98b04..76411562366f 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;
>> >+
>>
>> Wow!
>
>If you think that this one is fun, take a look at the implementation of
>synchronize_rcu() in kernel/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!
>
> Thanx, Paul
>
>> > 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.
>> >
>>
>> --- Thanks!
>>
>https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/
--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-11 23:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 16:09 [PATCH] srcutiny: Add lockdep and early-boot checks to synchronize_srcu_atomic() Kunwu Chan
2026-09-11 17:14 ` Paul E. McKenney
2026-09-11 21:18 ` Bradley Morgan
2026-09-11 23:12 ` Paul E. McKenney
2026-09-11 23:19 ` Bradley Morgan
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®