@@ -631,17 +631,16 @@ void cleanup_srcu_struct(struct srcu_struct *ssp)
631631}
632632EXPORT_SYMBOL_GPL (cleanup_srcu_struct );
633633
634+ #ifdef CONFIG_PROVE_RCU
634635/*
635636 * Check for consistent NMI safety.
636637 */
637- static void srcu_check_nmi_safety (struct srcu_struct * ssp , bool nmi_safe )
638+ void srcu_check_nmi_safety (struct srcu_struct * ssp , bool nmi_safe )
638639{
639640 int nmi_safe_mask = 1 << nmi_safe ;
640641 int old_nmi_safe_mask ;
641642 struct srcu_data * sdp ;
642643
643- if (!IS_ENABLED (CONFIG_PROVE_RCU ))
644- return ;
645644 /* NMI-unsafe use in NMI is a bad sign */
646645 WARN_ON_ONCE (!nmi_safe && in_nmi ());
647646 sdp = raw_cpu_ptr (ssp -> sda );
@@ -652,6 +651,7 @@ static void srcu_check_nmi_safety(struct srcu_struct *ssp, bool nmi_safe)
652651 }
653652 WARN_ONCE (old_nmi_safe_mask != nmi_safe_mask , "CPU %d old state %d new state %d\n" , sdp -> cpu , old_nmi_safe_mask , nmi_safe_mask );
654653}
654+ #endif /* CONFIG_PROVE_RCU */
655655
656656/*
657657 * Counts the new reader in the appropriate per-CPU element of the
@@ -665,7 +665,6 @@ int __srcu_read_lock(struct srcu_struct *ssp)
665665 idx = READ_ONCE (ssp -> srcu_idx ) & 0x1 ;
666666 this_cpu_inc (ssp -> sda -> srcu_lock_count [idx ].counter );
667667 smp_mb (); /* B */ /* Avoid leaking the critical section. */
668- srcu_check_nmi_safety (ssp , false);
669668 return idx ;
670669}
671670EXPORT_SYMBOL_GPL (__srcu_read_lock );
@@ -679,7 +678,6 @@ void __srcu_read_unlock(struct srcu_struct *ssp, int idx)
679678{
680679 smp_mb (); /* C */ /* Avoid leaking the critical section. */
681680 this_cpu_inc (ssp -> sda -> srcu_unlock_count [idx ].counter );
682- srcu_check_nmi_safety (ssp , false);
683681}
684682EXPORT_SYMBOL_GPL (__srcu_read_unlock );
685683
@@ -688,16 +686,14 @@ EXPORT_SYMBOL_GPL(__srcu_read_unlock);
688686 * srcu_struct, but in an NMI-safe manner using RMW atomics.
689687 * Returns an index that must be passed to the matching srcu_read_unlock().
690688 */
691- int __srcu_read_lock_nmisafe (struct srcu_struct * ssp , bool chknmisafe )
689+ int __srcu_read_lock_nmisafe (struct srcu_struct * ssp )
692690{
693691 int idx ;
694692 struct srcu_data * sdp = raw_cpu_ptr (ssp -> sda );
695693
696694 idx = READ_ONCE (ssp -> srcu_idx ) & 0x1 ;
697695 atomic_long_inc (& sdp -> srcu_lock_count [idx ]);
698696 smp_mb__after_atomic (); /* B */ /* Avoid leaking the critical section. */
699- if (chknmisafe )
700- srcu_check_nmi_safety (ssp , true);
701697 return idx ;
702698}
703699EXPORT_SYMBOL_GPL (__srcu_read_lock_nmisafe );
@@ -707,14 +703,12 @@ EXPORT_SYMBOL_GPL(__srcu_read_lock_nmisafe);
707703 * element of the srcu_struct. Note that this may well be a different
708704 * CPU than that which was incremented by the corresponding srcu_read_lock().
709705 */
710- void __srcu_read_unlock_nmisafe (struct srcu_struct * ssp , int idx , bool chknmisafe )
706+ void __srcu_read_unlock_nmisafe (struct srcu_struct * ssp , int idx )
711707{
712708 struct srcu_data * sdp = raw_cpu_ptr (ssp -> sda );
713709
714710 smp_mb__before_atomic (); /* C */ /* Avoid leaking the critical section. */
715711 atomic_long_inc (& sdp -> srcu_unlock_count [idx ]);
716- if (chknmisafe )
717- srcu_check_nmi_safety (ssp , true);
718712}
719713EXPORT_SYMBOL_GPL (__srcu_read_unlock_nmisafe );
720714
@@ -1159,7 +1153,7 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp,
11591153 * SRCU read-side critical section so that the grace-period
11601154 * sequence number cannot wrap around in the meantime.
11611155 */
1162- idx = __srcu_read_lock_nmisafe (ssp , false );
1156+ idx = __srcu_read_lock_nmisafe (ssp );
11631157 ss_state = smp_load_acquire (& ssp -> srcu_size_state );
11641158 if (ss_state < SRCU_SIZE_WAIT_CALL )
11651159 sdp = per_cpu_ptr (ssp -> sda , 0 );
@@ -1192,7 +1186,7 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp,
11921186 srcu_funnel_gp_start (ssp , sdp , s , do_norm );
11931187 else if (needexp )
11941188 srcu_funnel_exp_start (ssp , sdp_mynode , s );
1195- __srcu_read_unlock_nmisafe (ssp , idx , false );
1189+ __srcu_read_unlock_nmisafe (ssp , idx );
11961190 return s ;
11971191}
11981192
@@ -1496,13 +1490,13 @@ void srcu_barrier(struct srcu_struct *ssp)
14961490 /* Initial count prevents reaching zero until all CBs are posted. */
14971491 atomic_set (& ssp -> srcu_barrier_cpu_cnt , 1 );
14981492
1499- idx = __srcu_read_lock_nmisafe (ssp , false );
1493+ idx = __srcu_read_lock_nmisafe (ssp );
15001494 if (smp_load_acquire (& ssp -> srcu_size_state ) < SRCU_SIZE_WAIT_BARRIER )
15011495 srcu_barrier_one_cpu (ssp , per_cpu_ptr (ssp -> sda , 0 ));
15021496 else
15031497 for_each_possible_cpu (cpu )
15041498 srcu_barrier_one_cpu (ssp , per_cpu_ptr (ssp -> sda , cpu ));
1505- __srcu_read_unlock_nmisafe (ssp , idx , false );
1499+ __srcu_read_unlock_nmisafe (ssp , idx );
15061500
15071501 /* Remove the initial count, at which point reaching zero can happen. */
15081502 if (atomic_dec_and_test (& ssp -> srcu_barrier_cpu_cnt ))
0 commit comments