• Frederic Weisbecker's avatar
    srcu: Warn when NMI-unsafe API is used in NMI · 6b77bb9b
    Frederic Weisbecker authored
    Using the NMI-unsafe reader API from within an NMI handler is very likely
    to be buggy for three reasons:
    
    1) NMIs aren't strictly re-entrant (a pending nested NMI will execute at
       the end of the current one) so it should be fine to use a non-atomic
       increment here. However, breakpoints can still interrupt NMIs and if
       a breakpoint callback has a reader on that same ssp, a racy increment
       can happen.
    
    2) If the only reader site for a given srcu_struct structure is in an
       NMI handler, then RCU should be used instead of SRCU.
    
    3) Because of the previous reason (2), an srcu_struct structure having
       an SRCU read side critical section in an NMI handler is likely to
       have another one from a task context.
    
    For all these reasons, warn if an NMI-unsafe reader API is used from an
    NMI handler.
    Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
    Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    6b77bb9b
srcutree.c 62.1 KB