Skip to content

Commit 9ea366f

Browse files
paulmckrcuKAGA-KOKO
authored andcommitted
rcu: Make RCU IRQ enter/exit functions rely on in_nmi()
The rcu_nmi_enter_common() and rcu_nmi_exit_common() functions take an "irq" parameter that indicates whether these functions have been invoked from an irq handler (irq==true) or an NMI handler (irq==false). However, recent changes have applied notrace to a few critical functions such that rcu_nmi_enter_common() and rcu_nmi_exit_common() many now rely on in_nmi(). Note that in_nmi() works no differently than before, but rather that tracing is now prohibited in code regions where in_nmi() would incorrectly report NMI state. Therefore remove the "irq" parameter and inline rcu_nmi_enter_common() and rcu_nmi_exit_common() into rcu_nmi_enter() and rcu_nmi_exit(), respectively. Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent ff5c4f5 commit 9ea366f

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

kernel/rcu/tree.c

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -664,16 +664,18 @@ noinstr void rcu_user_enter(void)
664664
}
665665
#endif /* CONFIG_NO_HZ_FULL */
666666

667-
/*
667+
/**
668+
* rcu_nmi_exit - inform RCU of exit from NMI context
669+
*
668670
* If we are returning from the outermost NMI handler that interrupted an
669671
* RCU-idle period, update rdp->dynticks and rdp->dynticks_nmi_nesting
670672
* to let the RCU grace-period handling know that the CPU is back to
671673
* being RCU-idle.
672674
*
673-
* If you add or remove a call to rcu_nmi_exit_common(), be sure to test
675+
* If you add or remove a call to rcu_nmi_exit(), be sure to test
674676
* with CONFIG_RCU_EQS_DEBUG=y.
675677
*/
676-
static __always_inline void rcu_nmi_exit_common(bool irq)
678+
noinstr void rcu_nmi_exit(void)
677679
{
678680
struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
679681

@@ -704,29 +706,18 @@ static __always_inline void rcu_nmi_exit_common(bool irq)
704706
trace_rcu_dyntick(TPS("Startirq"), rdp->dynticks_nmi_nesting, 0, atomic_read(&rdp->dynticks));
705707
WRITE_ONCE(rdp->dynticks_nmi_nesting, 0); /* Avoid store tearing. */
706708

707-
if (irq)
709+
if (!in_nmi())
708710
rcu_prepare_for_idle();
709711
instrumentation_end();
710712

711713
// RCU is watching here ...
712714
rcu_dynticks_eqs_enter();
713715
// ... but is no longer watching here.
714716

715-
if (irq)
717+
if (!in_nmi())
716718
rcu_dynticks_task_enter();
717719
}
718720

719-
/**
720-
* rcu_nmi_exit - inform RCU of exit from NMI context
721-
*
722-
* If you add or remove a call to rcu_nmi_exit(), be sure to test
723-
* with CONFIG_RCU_EQS_DEBUG=y.
724-
*/
725-
void noinstr rcu_nmi_exit(void)
726-
{
727-
rcu_nmi_exit_common(false);
728-
}
729-
730721
/**
731722
* rcu_irq_exit - inform RCU that current CPU is exiting irq towards idle
732723
*
@@ -749,7 +740,7 @@ void noinstr rcu_nmi_exit(void)
749740
void noinstr rcu_irq_exit(void)
750741
{
751742
lockdep_assert_irqs_disabled();
752-
rcu_nmi_exit_common(true);
743+
rcu_nmi_exit();
753744
}
754745

755746
/*
@@ -838,7 +829,7 @@ void noinstr rcu_user_exit(void)
838829
#endif /* CONFIG_NO_HZ_FULL */
839830

840831
/**
841-
* rcu_nmi_enter_common - inform RCU of entry to NMI context
832+
* rcu_nmi_enter - inform RCU of entry to NMI context
842833
* @irq: Is this call from rcu_irq_enter?
843834
*
844835
* If the CPU was idle from RCU's viewpoint, update rdp->dynticks and
@@ -847,10 +838,10 @@ void noinstr rcu_user_exit(void)
847838
* long as the nesting level does not overflow an int. (You will probably
848839
* run out of stack space first.)
849840
*
850-
* If you add or remove a call to rcu_nmi_enter_common(), be sure to test
841+
* If you add or remove a call to rcu_nmi_enter(), be sure to test
851842
* with CONFIG_RCU_EQS_DEBUG=y.
852843
*/
853-
static __always_inline void rcu_nmi_enter_common(bool irq)
844+
noinstr void rcu_nmi_enter(void)
854845
{
855846
long incby = 2;
856847
struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
@@ -868,18 +859,18 @@ static __always_inline void rcu_nmi_enter_common(bool irq)
868859
*/
869860
if (rcu_dynticks_curr_cpu_in_eqs()) {
870861

871-
if (irq)
862+
if (!in_nmi())
872863
rcu_dynticks_task_exit();
873864

874865
// RCU is not watching here ...
875866
rcu_dynticks_eqs_exit();
876867
// ... but is watching here.
877868

878-
if (irq)
869+
if (!in_nmi())
879870
rcu_cleanup_after_idle();
880871

881872
incby = 1;
882-
} else if (irq) {
873+
} else if (!in_nmi()) {
883874
instrumentation_begin();
884875
if (tick_nohz_full_cpu(rdp->cpu) &&
885876
rdp->dynticks_nmi_nesting == DYNTICK_IRQ_NONIDLE &&
@@ -913,14 +904,6 @@ static __always_inline void rcu_nmi_enter_common(bool irq)
913904
barrier();
914905
}
915906

916-
/**
917-
* rcu_nmi_enter - inform RCU of entry to NMI context
918-
*/
919-
noinstr void rcu_nmi_enter(void)
920-
{
921-
rcu_nmi_enter_common(false);
922-
}
923-
924907
/**
925908
* rcu_irq_enter - inform RCU that current CPU is entering irq away from idle
926909
*
@@ -946,7 +929,7 @@ noinstr void rcu_nmi_enter(void)
946929
noinstr void rcu_irq_enter(void)
947930
{
948931
lockdep_assert_irqs_disabled();
949-
rcu_nmi_enter_common(true);
932+
rcu_nmi_enter();
950933
}
951934

952935
/*

0 commit comments

Comments
 (0)