Skip to content

Commit 490f561

Browse files
author
Frederic Weisbecker
committed
context-tracking: Introduce CONFIG_HAVE_TIF_NOHZ
A few archs (x86, arm, arm64) don't rely anymore on TIF_NOHZ to call into context tracking on user entry/exit but instead use static keys (or not) to optimize those calls. Ideally every arch should migrate to that behaviour in the long run. Settle a config option to let those archs remove their TIF_NOHZ definitions. Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Russell King <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Paul Burton <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: David S. Miller <[email protected]>
1 parent 7c80579 commit 490f561

File tree

8 files changed

+19
-5
lines changed

8 files changed

+19
-5
lines changed

arch/Kconfig

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,17 @@ config HAVE_CONTEXT_TRACKING
540540
help
541541
Provide kernel/user boundaries probes necessary for subsystems
542542
that need it, such as userspace RCU extended quiescent state.
543-
Syscalls need to be wrapped inside user_exit()-user_enter() through
544-
the slow path using TIF_NOHZ flag. Exceptions handlers must be
545-
wrapped as well. Irqs are already protected inside
546-
rcu_irq_enter/rcu_irq_exit() but preemption or signal handling on
547-
irq exit still need to be protected.
543+
Syscalls need to be wrapped inside user_exit()-user_enter(), either
544+
optimized behind static key or through the slow path using TIF_NOHZ
545+
flag. Exceptions handlers must be wrapped as well. Irqs are already
546+
protected inside rcu_irq_enter/rcu_irq_exit() but preemption or signal
547+
handling on irq exit still need to be protected.
548+
549+
config HAVE_TIF_NOHZ
550+
bool
551+
help
552+
Arch relies on TIF_NOHZ and syscall slow path to implement context
553+
tracking calls to user_enter()/user_exit().
548554

549555
config HAVE_VIRT_CPU_ACCOUNTING
550556
bool

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ config ARM
7272
select HAVE_ARM_SMCCC if CPU_V7
7373
select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32
7474
select HAVE_CONTEXT_TRACKING
75+
select HAVE_TIF_NOHZ
7576
select HAVE_COPY_THREAD_TLS
7677
select HAVE_C_RECORDMCOUNT
7778
select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ config ARM64
140140
select HAVE_CMPXCHG_DOUBLE
141141
select HAVE_CMPXCHG_LOCAL
142142
select HAVE_CONTEXT_TRACKING
143+
select HAVE_TIF_NOHZ
143144
select HAVE_COPY_THREAD_TLS
144145
select HAVE_DEBUG_BUGVERBOSE
145146
select HAVE_DEBUG_KMEMLEAK

arch/mips/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ config MIPS
5151
select HAVE_ASM_MODVERSIONS
5252
select HAVE_CBPF_JIT if !64BIT && !CPU_MICROMIPS
5353
select HAVE_CONTEXT_TRACKING
54+
select HAVE_TIF_NOHZ
5455
select HAVE_COPY_THREAD_TLS
5556
select HAVE_C_RECORDMCOUNT
5657
select HAVE_DEBUG_KMEMLEAK

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ config PPC
182182
select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
183183
select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2)
184184
select HAVE_CONTEXT_TRACKING if PPC64
185+
select HAVE_TIF_NOHZ if PPC64
185186
select HAVE_COPY_THREAD_TLS
186187
select HAVE_DEBUG_KMEMLEAK
187188
select HAVE_DEBUG_STACKOVERFLOW

arch/sparc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ config SPARC64
7171
select HAVE_FTRACE_MCOUNT_RECORD
7272
select HAVE_SYSCALL_TRACEPOINTS
7373
select HAVE_CONTEXT_TRACKING
74+
select HAVE_TIF_NOHZ
7475
select HAVE_DEBUG_KMEMLEAK
7576
select IOMMU_HELPER
7677
select SPARSE_IRQ

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ config X86
211211
select HAVE_STACK_VALIDATION if X86_64
212212
select HAVE_RSEQ
213213
select HAVE_SYSCALL_TRACEPOINTS
214+
select HAVE_TIF_NOHZ if X86_64
214215
select HAVE_UNSTABLE_SCHED_CLOCK
215216
select HAVE_USER_RETURN_NOTIFIER
216217
select HAVE_GENERIC_VDSO

kernel/context_tracking.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,13 @@ void __init context_tracking_cpu_set(int cpu)
198198
if (initialized)
199199
return;
200200

201+
#ifdef CONFIG_HAVE_TIF_NOHZ
201202
/*
202203
* Set TIF_NOHZ to init/0 and let it propagate to all tasks through fork
203204
* This assumes that init is the only task at this early boot stage.
204205
*/
205206
set_tsk_thread_flag(&init_task, TIF_NOHZ);
207+
#endif
206208
WARN_ON_ONCE(!tasklist_empty());
207209

208210
initialized = true;

0 commit comments

Comments
 (0)