Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <frederic@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: David S. Miller <davem@davemloft.net>

+19 -5
+11 -5
arch/Kconfig
··· 540 540 help 541 541 Provide kernel/user boundaries probes necessary for subsystems 542 542 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(). 548 554 549 555 config HAVE_VIRT_CPU_ACCOUNTING 550 556 bool
+1
arch/arm/Kconfig
··· 72 72 select HAVE_ARM_SMCCC if CPU_V7 73 73 select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 74 74 select HAVE_CONTEXT_TRACKING 75 + select HAVE_TIF_NOHZ 75 76 select HAVE_COPY_THREAD_TLS 76 77 select HAVE_C_RECORDMCOUNT 77 78 select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL
+1
arch/arm64/Kconfig
··· 140 140 select HAVE_CMPXCHG_DOUBLE 141 141 select HAVE_CMPXCHG_LOCAL 142 142 select HAVE_CONTEXT_TRACKING 143 + select HAVE_TIF_NOHZ 143 144 select HAVE_COPY_THREAD_TLS 144 145 select HAVE_DEBUG_BUGVERBOSE 145 146 select HAVE_DEBUG_KMEMLEAK
+1
arch/mips/Kconfig
··· 51 51 select HAVE_ASM_MODVERSIONS 52 52 select HAVE_CBPF_JIT if !64BIT && !CPU_MICROMIPS 53 53 select HAVE_CONTEXT_TRACKING 54 + select HAVE_TIF_NOHZ 54 55 select HAVE_COPY_THREAD_TLS 55 56 select HAVE_C_RECORDMCOUNT 56 57 select HAVE_DEBUG_KMEMLEAK
+1
arch/powerpc/Kconfig
··· 182 182 select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13) 183 183 select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2) 184 184 select HAVE_CONTEXT_TRACKING if PPC64 185 + select HAVE_TIF_NOHZ if PPC64 185 186 select HAVE_COPY_THREAD_TLS 186 187 select HAVE_DEBUG_KMEMLEAK 187 188 select HAVE_DEBUG_STACKOVERFLOW
+1
arch/sparc/Kconfig
··· 71 71 select HAVE_FTRACE_MCOUNT_RECORD 72 72 select HAVE_SYSCALL_TRACEPOINTS 73 73 select HAVE_CONTEXT_TRACKING 74 + select HAVE_TIF_NOHZ 74 75 select HAVE_DEBUG_KMEMLEAK 75 76 select IOMMU_HELPER 76 77 select SPARSE_IRQ
+1
arch/x86/Kconfig
··· 211 211 select HAVE_STACK_VALIDATION if X86_64 212 212 select HAVE_RSEQ 213 213 select HAVE_SYSCALL_TRACEPOINTS 214 + select HAVE_TIF_NOHZ if X86_64 214 215 select HAVE_UNSTABLE_SCHED_CLOCK 215 216 select HAVE_USER_RETURN_NOTIFIER 216 217 select HAVE_GENERIC_VDSO
+2
kernel/context_tracking.c
··· 198 198 if (initialized) 199 199 return; 200 200 201 + #ifdef CONFIG_HAVE_TIF_NOHZ 201 202 /* 202 203 * Set TIF_NOHZ to init/0 and let it propagate to all tasks through fork 203 204 * This assumes that init is the only task at this early boot stage. 204 205 */ 205 206 set_tsk_thread_flag(&init_task, TIF_NOHZ); 207 + #endif 206 208 WARN_ON_ONCE(!tasklist_empty()); 207 209 208 210 initialized = true;