Skip to content

Commit ec2227e

Browse files
author
Ingo Molnar
committed
x86/fpu: Push 'fpu' pointer calculation into the fpu__drop() call
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
1 parent 55bc30f commit ec2227e

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

arch/x86/include/asm/fpu/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <asm/trace/fpu.h>
1111

1212
extern void save_fpregs_to_fpstate(struct fpu *fpu);
13-
extern void fpu__drop(struct fpu *fpu);
13+
extern void fpu__drop(struct task_struct *tsk);
1414
extern int fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal,
1515
unsigned long shstk_addr);
1616
extern void fpu_flush_thread(void);

arch/x86/kernel/fpu/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,10 @@ int fpu_clone(struct task_struct *dst, unsigned long clone_flags, bool minimal,
681681
* a state-restore is coming: either an explicit one,
682682
* or a reschedule.
683683
*/
684-
void fpu__drop(struct fpu *fpu)
684+
void fpu__drop(struct task_struct *tsk)
685685
{
686+
struct fpu *fpu = x86_task_fpu(tsk);
687+
686688
preempt_disable();
687689

688690
if (fpu == x86_task_fpu(current)) {

arch/x86/kernel/process.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,14 @@ void arch_release_task_struct(struct task_struct *tsk)
120120
void exit_thread(struct task_struct *tsk)
121121
{
122122
struct thread_struct *t = &tsk->thread;
123-
struct fpu *fpu = x86_task_fpu(tsk);
124123

125124
if (test_thread_flag(TIF_IO_BITMAP))
126125
io_bitmap_exit(tsk);
127126

128127
free_vm86(t);
129128

130129
shstk_free(tsk);
131-
fpu__drop(fpu);
130+
fpu__drop(tsk);
132131
}
133132

134133
static int set_new_tls(struct task_struct *p, unsigned long tls)

0 commit comments

Comments
 (0)