From: Oleg Nesterov Date: Sat, 3 May 2025 14:38:56 +0000 (+0200) Subject: x86/fpu: Check TIF_NEED_FPU_LOAD instead of PF_KTHREAD|PF_USER_WORKER in fpu__drop() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=016a2e6f8ae5ed544ba8fb2b6d78f64ddfd9d01b;p=users%2Fdwmw2%2Flinux.git x86/fpu: Check TIF_NEED_FPU_LOAD instead of PF_KTHREAD|PF_USER_WORKER in fpu__drop() PF_KTHREAD|PF_USER_WORKER tasks should never clear TIF_NEED_FPU_LOAD, so the TIF_NEED_FPU_LOAD check should equally filter them out. And this way an exiting userspace task can avoid the unnecessary "fwait" if it does context_switch() at least once on its way to exit_thread(). Signed-off-by: Oleg Nesterov Signed-off-by: Ingo Molnar Cc: Chang S . Bae Cc: H. Peter Anvin Cc: Andy Lutomirski Cc: Brian Gerst Cc: Linus Torvalds Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20250503143856.GA9009@redhat.com --- diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 8d674435f1731..fa131299c7da3 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -693,8 +693,7 @@ void fpu__drop(struct task_struct *tsk) { struct fpu *fpu; - /* PF_KTHREAD tasks do not use the FPU context area: */ - if (tsk->flags & (PF_KTHREAD | PF_USER_WORKER)) + if (test_tsk_thread_flag(tsk, TIF_NEED_FPU_LOAD)) return; fpu = x86_task_fpu(tsk);