On Thu, Jan 29, 2026 at 07:33:59PM -0500, Steven Rostedt wrote:
> On Tue, 27 Jan 2026 15:18:05 -0800
> "Paul E. McKenney" <[email protected]> wrote:
> 
> > Ah, I get it.  I think.  NMIs, right?
> > 
> > In your source tree, line 792 of kernel/rcu/srcutree.c is this line of
> > code, correct?
> > 
> >     WARN_ON_ONCE((read_flavor != SRCU_READ_FLAVOR_NMI) && in_nmi());
> > 
> > If so, could you please try this test with the patch shown at the end
> > of this email?
> > 
> 
> > 
> > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> > index c469c708fdd6a..66ba6a2f83d3a 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);
> 
> It appears to fix the issue.
> 
> Tested-by: Steven Rostedt (Google) <[email protected]>
> 
> Care to send a formal patch, and I'll add it before the patch that causes
> issues.

Thank you, done, and apologies for the hassle!  This should show up
here in a bit:

https://lore.kernel.org/all/8232efe8-a7a3-446c-af0b-19f9b523b4f7@paulmck-laptop/

And I have it below, just in case.

                                                        Thanx, Paul

------------------------------------------------------------------------

commit 0bf3a51bef3c33ea528c96720ab6d6211d9009cf
Author: Paul E. McKenney <[email protected]>
Date:   Tue Jan 27 15:20:02 2026 -0800

    srcu: Fix warning to permit SRCU-fast readers in NMI handlers
    
    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 <[email protected]>
    Signed-off-by: Paul E. McKenney <[email protected]>
    Tested-by: Steven Rostedt <[email protected]>
    Cc: Andrii Nakryiko <[email protected]>
    Cc: Alexei Starovoitov <[email protected]>
    Cc: Peter Zijlstra <[email protected]>
    Cc: [email protected]

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index c469c708fdd6a..66ba6a2f83d3a 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);

Reply via email to