* [PATCH] x86/fpu: kill the PF_KTHREAD|PF_USER_WORKER check in switch_fpu() and kernel_fpu_begin_mask()
@ 2025-08-29 15:05 Oleg Nesterov
0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2025-08-29 15:05 UTC (permalink / raw)
To: Ingo Molnar
Cc: Borislav Petkov, Chao Gao, Dave Hansen, Edgecombe, Rick P,
Eric Biggers, H. Peter Anvin, Peter Zijlstra, Thomas Gleixner,
linux-kernel, x86
PF_KTHREAD | PF_USER_WORKER kernel threads do not use their FPU context,
this means that TIF_NEED_FPU_LOAD must be always set, we can remove the
unnecessary "PF_KTHREAD | PF_USER_WORKER" check.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
arch/x86/include/asm/fpu/sched.h | 3 +--
arch/x86/kernel/fpu/core.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/fpu/sched.h b/arch/x86/include/asm/fpu/sched.h
index c060549c6c94..20091b4cda6a 100644
--- a/arch/x86/include/asm/fpu/sched.h
+++ b/arch/x86/include/asm/fpu/sched.h
@@ -32,8 +32,7 @@ extern void fpu_flush_thread(void);
static inline void switch_fpu(struct task_struct *old, int cpu)
{
if (!test_tsk_thread_flag(old, TIF_NEED_FPU_LOAD) &&
- cpu_feature_enabled(X86_FEATURE_FPU) &&
- !(old->flags & (PF_KTHREAD | PF_USER_WORKER))) {
+ cpu_feature_enabled(X86_FEATURE_FPU)) {
struct fpu *old_fpu = x86_task_fpu(old);
set_tsk_thread_flag(old, TIF_NEED_FPU_LOAD);
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index aefd412a23dc..ef54da3c1f1a 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -453,8 +453,7 @@ void kernel_fpu_begin_mask(unsigned int kfpu_mask)
WARN_ON_FPU(!this_cpu_read(kernel_fpu_allowed));
this_cpu_write(kernel_fpu_allowed, false);
- if (!(current->flags & (PF_KTHREAD | PF_USER_WORKER)) &&
- !test_thread_flag(TIF_NEED_FPU_LOAD)) {
+ if (!test_thread_flag(TIF_NEED_FPU_LOAD)) {
set_thread_flag(TIF_NEED_FPU_LOAD);
save_fpregs_to_fpstate(x86_task_fpu(current));
}
--
2.25.1.362.g51ebf55
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-29 15:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-29 15:05 [PATCH] x86/fpu: kill the PF_KTHREAD|PF_USER_WORKER check in switch_fpu() and kernel_fpu_begin_mask() Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).