Skip to content

Commit 493c182

Browse files
Frederic Weisbeckerpaulmckrcu
Frederic Weisbecker
authored andcommitted
context_tracking: Take NMI eqs entrypoints over RCU
The RCU dynticks counter is going to be merged into the context tracking subsystem. Prepare with moving the NMI extended quiescent states entrypoints to context tracking. For now those are dumb redirection to existing RCU calls. Acked-by: Paul E. McKenney <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Neeraj Upadhyay <[email protected]> Cc: Uladzislau Rezki <[email protected]> Cc: Joel Fernandes <[email protected]> Cc: Boqun Feng <[email protected]> Cc: Nicolas Saenz Julienne <[email protected]> Cc: Marcelo Tosatti <[email protected]> Cc: Xiongfeng Wang <[email protected]> Cc: Yu Liao <[email protected]> Cc: Phil Auld <[email protected]> Cc: Paul Gortmaker<[email protected]> Cc: Alex Belits <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Reviewed-by: Nicolas Saenz Julienne <[email protected]> Tested-by: Nicolas Saenz Julienne <[email protected]>
1 parent 6f0e6c1 commit 493c182

File tree

9 files changed

+27
-13
lines changed

9 files changed

+27
-13
lines changed

Documentation/RCU/Design/Requirements/Requirements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ normal interrupts. One way that this can happen is for code that
18471847
directly invokes ct_irq_enter() and ct_irq_exit() to be called
18481848
from an NMI handler. This astonishing fact of life prompted the current
18491849
code structure, which has ct_irq_enter() invoking
1850-
rcu_nmi_enter() and ct_irq_exit() invoking rcu_nmi_exit().
1850+
ct_nmi_enter() and ct_irq_exit() invoking ct_nmi_exit().
18511851
And yes, I also learned of this requirement the hard way.
18521852

18531853
Loadable Modules

arch/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ config HAVE_CONTEXT_TRACKING_USER_OFFSTACK
797797

798798
- Critical entry code isn't preemptible (or better yet:
799799
not interruptible).
800-
- No use of RCU read side critical sections, unless rcu_nmi_enter()
800+
- No use of RCU read side critical sections, unless ct_nmi_enter()
801801
got called.
802802
- No use of instrumentation, unless instrumentation_begin() got
803803
called.

arch/arm64/kernel/entry-common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static void noinstr arm64_enter_nmi(struct pt_regs *regs)
161161
__nmi_enter();
162162
lockdep_hardirqs_off(CALLER_ADDR0);
163163
lockdep_hardirq_enter();
164-
rcu_nmi_enter();
164+
ct_nmi_enter();
165165

166166
trace_hardirqs_off_finish();
167167
ftrace_nmi_enter();
@@ -182,7 +182,7 @@ static void noinstr arm64_exit_nmi(struct pt_regs *regs)
182182
lockdep_hardirqs_on_prepare();
183183
}
184184

185-
rcu_nmi_exit();
185+
ct_nmi_exit();
186186
lockdep_hardirq_exit();
187187
if (restore)
188188
lockdep_hardirqs_on(CALLER_ADDR0);
@@ -199,7 +199,7 @@ static void noinstr arm64_enter_el1_dbg(struct pt_regs *regs)
199199
regs->lockdep_hardirqs = lockdep_hardirqs_enabled();
200200

201201
lockdep_hardirqs_off(CALLER_ADDR0);
202-
rcu_nmi_enter();
202+
ct_nmi_enter();
203203

204204
trace_hardirqs_off_finish();
205205
}
@@ -218,7 +218,7 @@ static void noinstr arm64_exit_el1_dbg(struct pt_regs *regs)
218218
lockdep_hardirqs_on_prepare();
219219
}
220220

221-
rcu_nmi_exit();
221+
ct_nmi_exit();
222222
if (restore)
223223
lockdep_hardirqs_on(CALLER_ADDR0);
224224
}

include/linux/context_tracking_irq.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ void ct_irq_enter(void);
77
void ct_irq_exit(void);
88
void ct_irq_enter_irqson(void);
99
void ct_irq_exit_irqson(void);
10+
void ct_nmi_enter(void);
11+
void ct_nmi_exit(void);
1012
#else
1113
static inline void ct_irq_enter(void) { }
1214
static inline void ct_irq_exit(void) { }
1315
static inline void ct_irq_enter_irqson(void) { }
1416
static inline void ct_irq_exit_irqson(void) { }
17+
static inline void ct_nmi_enter(void) { }
18+
static inline void ct_nmi_exit(void) { }
1519
#endif
1620

1721
#endif

include/linux/hardirq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ extern void rcu_nmi_exit(void);
124124
do { \
125125
__nmi_enter(); \
126126
lockdep_hardirq_enter(); \
127-
rcu_nmi_enter(); \
127+
ct_nmi_enter(); \
128128
instrumentation_begin(); \
129129
ftrace_nmi_enter(); \
130130
instrumentation_end(); \
@@ -143,7 +143,7 @@ extern void rcu_nmi_exit(void);
143143
instrumentation_begin(); \
144144
ftrace_nmi_exit(); \
145145
instrumentation_end(); \
146-
rcu_nmi_exit(); \
146+
ct_nmi_exit(); \
147147
lockdep_hardirq_exit(); \
148148
__nmi_exit(); \
149149
} while (0)

kernel/context_tracking.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ void ct_irq_exit_irqson(void)
5555
{
5656
rcu_irq_exit_irqson();
5757
}
58+
59+
noinstr void ct_nmi_enter(void)
60+
{
61+
rcu_nmi_enter();
62+
}
63+
64+
noinstr void ct_nmi_exit(void)
65+
{
66+
rcu_nmi_exit();
67+
}
5868
#endif /* #ifdef CONFIG_CONTEXT_TRACKING_IDLE */
5969

6070
#ifdef CONFIG_CONTEXT_TRACKING_USER

kernel/entry/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs)
449449
__nmi_enter();
450450
lockdep_hardirqs_off(CALLER_ADDR0);
451451
lockdep_hardirq_enter();
452-
rcu_nmi_enter();
452+
ct_nmi_enter();
453453

454454
instrumentation_begin();
455455
trace_hardirqs_off_finish();
@@ -469,7 +469,7 @@ void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state)
469469
}
470470
instrumentation_end();
471471

472-
rcu_nmi_exit();
472+
ct_nmi_exit();
473473
lockdep_hardirq_exit();
474474
if (irq_state.lockdep)
475475
lockdep_hardirqs_on(CALLER_ADDR0);

kernel/extable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int kernel_text_address(unsigned long addr)
114114

115115
/* Treat this like an NMI as it can happen anywhere */
116116
if (no_rcu)
117-
rcu_nmi_enter();
117+
ct_nmi_enter();
118118

119119
if (is_module_text_address(addr))
120120
goto out;
@@ -127,7 +127,7 @@ int kernel_text_address(unsigned long addr)
127127
ret = 0;
128128
out:
129129
if (no_rcu)
130-
rcu_nmi_exit();
130+
ct_nmi_exit();
131131

132132
return ret;
133133
}

kernel/trace/trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3105,7 +3105,7 @@ void __trace_stack(struct trace_array *tr, unsigned int trace_ctx,
31053105
}
31063106

31073107
/*
3108-
* When an NMI triggers, RCU is enabled via rcu_nmi_enter(),
3108+
* When an NMI triggers, RCU is enabled via ct_nmi_enter(),
31093109
* but if the above rcu_is_watching() failed, then the NMI
31103110
* triggered someplace critical, and ct_irq_enter() should
31113111
* not be called from NMI.

0 commit comments

Comments
 (0)