Re: [for-next][PATCH 3/4] srcu: Fix warning to permit SRCU-fast readers in NMI handlers
From: Paul E. McKenney
Date: Fri Jan 30 2026 - 12:19:00 EST
On Fri, Jan 30, 2026 at 07:51:16AM -0800, Boqun Feng wrote:
> On Fri, Jan 30, 2026 at 10:46:10AM -0500, Steven Rostedt wrote:
> > From: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
> >
> > SRCU-fast is designed to be used in NMI handlers, even going so far
> > as to use atomic operations for architectures supporting NMIs but not
> > providing NMI-safe per-CPU atomic operations. However, the WARN_ON_ONCE()
> > in __srcu_check_read_flavor() complains if SRCU-fast is used in an NMI
> > handler. This commit therefore modifies that WARN_ON_ONCE() to avoid
> > such complaints.
> >
> > Reported-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
> > Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> > Tested-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
> > Cc: Andrii Nakryiko <andrii@xxxxxxxxxx>
> > Cc: Boqun Feng <boqun@xxxxxxxxxx>
> > Cc: Alexei Starovoitov <ast@xxxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: bpf@xxxxxxxxxxxxxxx
> > Link: https://patch.msgid.link/8232efe8-a7a3-446c-af0b-19f9b523b4f7@paulmck-laptop
> > Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
>
> Thank you, Steven! I will drop this in the RCU PR since you already plan
> to carry it via tracing.
Thank you both!
Thanx, Paul
> Regards,
> Boqun
>
> > ---
> > kernel/rcu/srcutree.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> > index ea3f128de06f..c4a0a93e8da4 100644
> > --- a/kernel/rcu/srcutree.c
> > +++ b/kernel/rcu/srcutree.c
> > @@ -789,7 +789,8 @@ void __srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor)
> > struct srcu_data *sdp;
> >
> > /* NMI-unsafe use in NMI is a bad sign, as is multi-bit read_flavor values. */
> > - WARN_ON_ONCE((read_flavor != SRCU_READ_FLAVOR_NMI) && in_nmi());
> > + WARN_ON_ONCE(read_flavor != SRCU_READ_FLAVOR_NMI &&
> > + read_flavor != SRCU_READ_FLAVOR_FAST && in_nmi());
> > WARN_ON_ONCE(read_flavor & (read_flavor - 1));
> >
> > sdp = raw_cpu_ptr(ssp->sda);
> > --
> > 2.51.0
> >
> >