context_tracking: Remove TIF_NOHZ from 3 archs
Subsystems (7)
Frederic Weisbecker
maintainercover context_tracking: Remove TIF_NOHZ from 3 archs
TIF_NOHZ is getting deprecated by static keys which avoid to invoke syscall slow path on every syscall. So remove that flag from architectures that don't need it anymore (or worse yet: that spuriously triggered syscall slow path when it's not needed anymore).
We hope to remove TIF_NOHZ entirely in the long run (PPC, MIPS, SPARC). If we want to be able to enable/disable nohz full dynamically on runtime, freezing all tasks and iterating through the whole tasklist to set/clear TIF_NOHZ doesn't sound very appealing.
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
arch/nohz
WARNING: untested on ARM 32
HEAD: 92502ebbf06ac37858694ed8f9d16fdb13ed0fe3
Thanks,
Frederic
---
Frederic Weisbecker (4):
context-tracking: Introduce CONFIG_HAVE_TIF_NOHZ
x86: Remove TIF_NOHZ
arm: Remove TIF_NOHZ
arm64: Remove TIF_NOHZ
Thomas Gleixner (1):
x86/entry: Remove _TIF_NOHZ from _TIF_WORK_SYSCALL_ENTRY
arch/Kconfig | 16 +++++++++++----- arch/arm/include/asm/thread_info.h | 1 - arch/arm64/include/asm/thread_info.h | 4 +--- arch/mips/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/x86/include/asm/thread_info.h | 10 ++-------- kernel/context_tracking.c | 2 ++ 8 files changed, 19 insertions(+), 17 deletions(-)
Frederic Weisbecker
maintainerPATCH 1/5 x86/entry: Remove _TIF_NOHZ from _TIF_WORK_SYSCALL_ENTRY
From: Thomas Gleixner <[email protected]>
Evaluating _TIF_NOHZ to decide whether to use the slow syscall entry path is not only pointless, it's actually counterproductive:
1) Context tracking code is invoked unconditionally before that flag is evaluated.
2) If the flag is set the slow path is invoked for nothing due to #1
Remove it.
--- arch/x86/include/asm/thread_info.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/include/asm/thread_info.h +2 -6
@@ -133,14 +133,10 @@ struct thread_info {#define _TIF_X32 (1 << TIF_X32)#define _TIF_FSCHECK (1 << TIF_FSCHECK) -/* -* work to do in syscall_trace_enter(). Also includes TIF_NOHZ for -* enter_from_user_mode() -*/ +/* Work to do before invoking the actual syscall. */ #define _TIF_WORK_SYSCALL_ENTRY \ (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \ - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \ - _TIF_NOHZ) + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)/* flags to check in __switch_to() */ #define _TIF_WORK_CTXSW_BASE \
Signature · 1 line
2.25.0
Frederic Weisbecker
maintainerPATCH 2/5 context-tracking: Introduce CONFIG_HAVE_TIF_NOHZ
In reply to Frederic WeisbeckerA 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.
--- arch/Kconfig | 16 +++++++++++----- arch/arm/Kconfig | 1 + arch/arm64/Kconfig | 1 + arch/mips/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/x86/Kconfig | 1 + kernel/context_tracking.c | 2 ++ 8 files changed, 19 insertions(+), 5 deletions(-)
arch/Kconfig +11 -5
@@ -540,11 +540,17 @@ config HAVE_CONTEXT_TRACKING help Provide kernel/user boundaries probes necessary for subsystems that need it, such as userspace RCU extended quiescent state. - Syscalls need to be wrapped inside user_exit()-user_enter() through - the slow path using TIF_NOHZ flag. Exceptions handlers must be - wrapped as well. Irqs are already protected inside - rcu_irq_enter/rcu_irq_exit() but preemption or signal handling on - irq exit still need to be protected. + Syscalls need to be wrapped inside user_exit()-user_enter(), either + optimized behind static key or through the slow path using TIF_NOHZ + flag. Exceptions handlers must be wrapped as well. Irqs are already + protected inside rcu_irq_enter/rcu_irq_exit() but preemption or signal + handling on irq exit still need to be protected. + +config HAVE_TIF_NOHZ + bool + help + Arch relies on TIF_NOHZ and syscall slow path to implement context + tracking calls to user_enter()/user_exit(). config HAVE_VIRT_CPU_ACCOUNTING bool
arch/arm/Kconfig +1 -0
@@ -72,6 +72,7 @@ config ARM select HAVE_ARM_SMCCC if CPU_V7 select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 select HAVE_CONTEXT_TRACKING + select HAVE_TIF_NOHZ select HAVE_COPY_THREAD_TLS select HAVE_C_RECORDMCOUNT select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL
arch/arm64/Kconfig +1 -0
@@ -140,6 +140,7 @@ config ARM64 select HAVE_CMPXCHG_DOUBLE select HAVE_CMPXCHG_LOCAL select HAVE_CONTEXT_TRACKING + select HAVE_TIF_NOHZ select HAVE_COPY_THREAD_TLS select HAVE_DEBUG_BUGVERBOSE select HAVE_DEBUG_KMEMLEAK
arch/mips/Kconfig +1 -0
@@ -51,6 +51,7 @@ config MIPS select HAVE_ASM_MODVERSIONS select HAVE_CBPF_JIT if !64BIT && !CPU_MICROMIPS select HAVE_CONTEXT_TRACKING + select HAVE_TIF_NOHZ select HAVE_COPY_THREAD_TLS select HAVE_C_RECORDMCOUNT select HAVE_DEBUG_KMEMLEAK
arch/powerpc/Kconfig +1 -0
@@ -182,6 +182,7 @@ config PPC select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13) select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2) select HAVE_CONTEXT_TRACKING if PPC64 + select HAVE_TIF_NOHZ if PPC64 select HAVE_COPY_THREAD_TLS select HAVE_DEBUG_KMEMLEAK select HAVE_DEBUG_STACKOVERFLOW
arch/sparc/Kconfig +1 -0
@@ -71,6 +71,7 @@ config SPARC64 select HAVE_FTRACE_MCOUNT_RECORD select HAVE_SYSCALL_TRACEPOINTS select HAVE_CONTEXT_TRACKING + select HAVE_TIF_NOHZ select HAVE_DEBUG_KMEMLEAK select IOMMU_HELPER select SPARSE_IRQ
arch/x86/Kconfig +1 -0
@@ -211,6 +211,7 @@ config X86 select HAVE_STACK_VALIDATION if X86_64 select HAVE_RSEQ select HAVE_SYSCALL_TRACEPOINTS + select HAVE_TIF_NOHZ if X86_64 select HAVE_UNSTABLE_SCHED_CLOCK select HAVE_USER_RETURN_NOTIFIER select HAVE_GENERIC_VDSO
kernel/context_tracking.c +2 -0
@@ -198,11 +198,13 @@ void __init context_tracking_cpu_set(int cpu)if (initialized)return ; +#ifdef CONFIG_HAVE_TIF_NOHZ /* * Set TIF_NOHZ to init/0 and let it propagate to all tasks through fork * This assumes that init is the only task at this early boot stage. */ set_tsk_thread_flag (&init_task,TIF_NOHZ ); +#endif WARN_ON_ONCE (!tasklist_empty ()); initialized = true;
Signature · 1 line
2.25.0
Frederic Weisbecker
maintainerPATCH 3/5 x86: Remove TIF_NOHZ
In reply to Frederic WeisbeckerStatic keys have replaced TIF_NOHZ to optimize the calls to context tracking. We can now safely remove that thread flag.
--- arch/x86/Kconfig | 1 - arch/x86/include/asm/thread_info.h | 2 -- 2 files changed, 3 deletions(-)
arch/x86/Kconfig +0 -1
@@ -211,7 +211,6 @@ config X86 select HAVE_STACK_VALIDATION if X86_64 select HAVE_RSEQ select HAVE_SYSCALL_TRACEPOINTS - select HAVE_TIF_NOHZ if X86_64 select HAVE_UNSTABLE_SCHED_CLOCK select HAVE_USER_RETURN_NOTIFIER select HAVE_GENERIC_VDSO
arch/x86/include/asm/thread_info.h +0 -2
@@ -92,7 +92,6 @@ struct thread_info {#define TIF_NOCPUID 15/* CPUID is not accessible in userland */ #define TIF_NOTSC 16/* TSC is not accessible in userland */ #define TIF_IA32 17/* IA32 compatibility process */ -#define TIF_NOHZ 19/* in adaptive nohz mode */ #define TIF_MEMDIE 20/* is terminating due to OOM killer */ #define TIF_POLLING_NRFLAG 21/* idle is polling for TIF_NEED_RESCHED */ #define TIF_IO_BITMAP 22/* uses I/O bitmap */
@@ -122,7 +121,6 @@ struct thread_info {#define _TIF_NOCPUID (1 << TIF_NOCPUID)#define _TIF_NOTSC (1 << TIF_NOTSC)#define _TIF_IA32 (1 << TIF_IA32) -#define _TIF_NOHZ (1 << TIF_NOHZ)#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)#define _TIF_FORCED_TF (1 << TIF_FORCED_TF)
Signature · 1 line
2.25.0
Frederic Weisbecker
maintainerPATCH 4/5 arm: Remove TIF_NOHZ
In reply to Frederic WeisbeckerArm entry code calls context tracking from fast path. TIF_NOHZ is unused and can be safely removed.
--- arch/arm/Kconfig | 1 - arch/arm/include/asm/thread_info.h | 1 - 2 files changed, 2 deletions(-)
arch/arm/Kconfig +0 -1
@@ -72,7 +72,6 @@ config ARM select HAVE_ARM_SMCCC if CPU_V7 select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 select HAVE_CONTEXT_TRACKING - select HAVE_TIF_NOHZ select HAVE_COPY_THREAD_TLS select HAVE_C_RECORDMCOUNT select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL
arch/arm/include/asm/thread_info.h +0 -1
@@ -141,7 +141,6 @@ extern int vfp_restore_user_hwstate(struct user_vfp *,#define TIF_SYSCALL_TRACEPOINT 6/* syscall tracepoint instrumentation */ #define TIF_SECCOMP 7/* seccomp syscall filtering active */ -#define TIF_NOHZ 12/* in adaptive nohz mode */ #define TIF_USING_IWMMXT 17#define TIF_MEMDIE 18/* is terminating due to OOM killer */ #define TIF_RESTORE_SIGMASK 20
Signature · 1 line
2.25.0
Frederic Weisbecker
maintainerPATCH 5/5 arm64: Remove TIF_NOHZ
In reply to Frederic WeisbeckerThe syscall slow path is spuriously invoked when context tracking is activated while the entry code calls context tracking from fast path.
Remove that overhead and the unused flag itself while at it.
--- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/thread_info.h | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-)
arch/arm64/Kconfig +0 -1
@@ -140,7 +140,6 @@ config ARM64 select HAVE_CMPXCHG_DOUBLE select HAVE_CMPXCHG_LOCAL select HAVE_CONTEXT_TRACKING - select HAVE_TIF_NOHZ select HAVE_COPY_THREAD_TLS select HAVE_DEBUG_BUGVERBOSE select HAVE_DEBUG_KMEMLEAK
arch/arm64/include/asm/thread_info.h +1 -3
@@ -63,7 +63,6 @@ void arch_release_task_struct(struct task_struct *tsk);#define TIF_FOREIGN_FPSTATE 3/* CPU's FP state is not current's */ #define TIF_UPROBE 4/* uprobe breakpoint or singlestep */ #define TIF_FSCHECK 5/* Check FS is USER_DS on return */ -#define TIF_NOHZ 7#define TIF_SYSCALL_TRACE 8/* syscall trace active */ #define TIF_SYSCALL_AUDIT 9/* syscall auditing */ #define TIF_SYSCALL_TRACEPOINT 10/* syscall tracepoint for ftrace */
@@ -83,7 +82,6 @@ void arch_release_task_struct(struct task_struct *tsk);#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)#define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE) -#define _TIF_NOHZ (1 << TIF_NOHZ)#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
@@ -100,7 +98,7 @@ void arch_release_task_struct(struct task_struct *tsk);#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ - _TIF_NOHZ | _TIF_SYSCALL_EMU) + _TIF_SYSCALL_EMU)#define INIT_THREAD_INFO (tsk) \ { \
Signature · 1 line
2.25.0
Re: [PATCH 5/5] arm64: Remove TIF_NOHZ
Quoted 12 lines · Frederic Weisbecker
The syscall slow path is spuriously invoked when context tracking is activated while the entry code calls context tracking from fast path.
Remove that overhead and the unused flag itself while at it.
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 Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>
Quoted 4 lines
--- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/thread_info.h | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-)
Do you want this to go via the arm64 tree? It looks like it makes sense on its own to me, so I could pick it as a fix.
Will
Frederic Weisbecker
maintainerRe: [PATCH 5/5] arm64: Remove TIF_NOHZ
Quoted 18 lines · Will Deacon
Quoted 12 lines · Frederic Weisbecker
The syscall slow path is spuriously invoked when context tracking is activated while the entry code calls context tracking from fast path.
Remove that overhead and the unused flag itself while at it.
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 Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Quoted 4 lines
--- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/thread_info.h | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-)
Quoted 4 lines
Acked-by Will Deacon <[email protected]>Do you want this to go via the arm64 tree? It looks like it makes sense on its own to me, so I could pick it as a fix.
Thanks Will, unfortunately it depends on some patches on the series, so the whole needs to go together.
Frederic Weisbecker
maintainerIngo, Thomas,
Please pull the arch/nohz branch that can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
arch/nohz
HEAD: 320a4fc2d1b0c2314342dfdd3348270f126196a4
---TIF_NOHZ is getting deprecated by static keys which avoid to invoke syscall slow path on every syscall. So remove that flag from architectures that don't need it anymore (or worse yet: that spuriously triggered syscall slow path when it's not needed anymore).
We hope to remove TIF_NOHZ entirely in the long run (PPC, MIPS, SPARC). If we want to be able to enable/disable nohz full dynamically on runtime, freezing all tasks and iterating through the whole tasklist to set/clear TIF_NOHZ doesn't sound very appealing.
Thanks,
Frederic
---
Frederic Weisbecker (4):
context-tracking: Introduce CONFIG_HAVE_TIF_NOHZ
x86: Remove TIF_NOHZ
arm: Remove TIF_NOHZ
arm64: Remove TIF_NOHZ
Thomas Gleixner (1):
x86/entry: Remove _TIF_NOHZ from _TIF_WORK_SYSCALL_ENTRY
arch/Kconfig | 16 +++++++++++----- arch/arm/include/asm/thread_info.h | 1 - arch/arm64/include/asm/thread_info.h | 4 +--- arch/mips/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/x86/include/asm/thread_info.h | 10 ++-------- kernel/context_tracking.c | 2 ++ 8 files changed, 19 insertions(+), 17 deletions(-)
Frederic Weisbecker
maintainerQuoted 7 lines · Frederic Weisbecker
Ingo, Thomas,
Please pull the
arch/nohzbranch that can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
arch/nohz
Ping?