]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/fpu: Push 'fpu' pointer calculation into the fpu__drop() call
authorIngo Molnar <mingo@kernel.org>
Wed, 9 Apr 2025 21:11:24 +0000 (23:11 +0200)
committerIngo Molnar <mingo@kernel.org>
Mon, 14 Apr 2025 06:18:29 +0000 (08:18 +0200)
This encapsulates the fpu__drop() functionality better, and it
will also enable other changes that want to check a task for
PF_KTHREAD before calling x86_task_fpu().

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Chang S. Bae <chang.seok.bae@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250409211127.3544993-6-mingo@kernel.org
arch/x86/include/asm/fpu/sched.h
arch/x86/kernel/fpu/core.c
arch/x86/kernel/process.c

index 1feaa68b75671a7dd52c0019f92d0c275fc182cf..5fd12634bcc4ebe1c1820b2a80afbc63bb448a26 100644 (file)
@@ -10,7 +10,7 @@
 #include <asm/trace/fpu.h>
 
 extern void save_fpregs_to_fpstate(struct fpu *fpu);
-extern void fpu__drop(struct fpu *fpu);
+extern void fpu__drop(struct task_struct *tsk);
 extern int  fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal,
                      unsigned long shstk_addr);
 extern void fpu_flush_thread(void);
index 974b276ff0da230a22573b1674a969ef21006d70..e4c20908ee49d150d5be2b3599650579fc70ab33 100644 (file)
@@ -681,8 +681,10 @@ int fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal,
  * a state-restore is coming: either an explicit one,
  * or a reschedule.
  */
-void fpu__drop(struct fpu *fpu)
+void fpu__drop(struct task_struct *tsk)
 {
+       struct fpu *fpu = x86_task_fpu(tsk);
+
        preempt_disable();
 
        if (fpu == x86_task_fpu(current)) {
index 88868a90459e9b5c30eecd420ba69c5e79475f7d..5fb502c97b08d5c65c840d35e4922654147a0b11 100644 (file)
@@ -120,7 +120,6 @@ void arch_release_task_struct(struct task_struct *tsk)
 void exit_thread(struct task_struct *tsk)
 {
        struct thread_struct *t = &tsk->thread;
-       struct fpu *fpu = x86_task_fpu(tsk);
 
        if (test_thread_flag(TIF_IO_BITMAP))
                io_bitmap_exit(tsk);
@@ -128,7 +127,7 @@ void exit_thread(struct task_struct *tsk)
        free_vm86(t);
 
        shstk_free(tsk);
-       fpu__drop(fpu);
+       fpu__drop(tsk);
 }
 
 static int set_new_tls(struct task_struct *p, unsigned long tls)