x86/fpu: don't set TIF_NEED_FPU_LOAD for PF_IO_WORKER threads
PATCH 1/1 x86/fpu: don't set TIF_NEED_FPU_LOAD for PF_IO_WORKER threads
We don't set it on PF_KTHREAD threads as they never return to userspace, and PF_IO_WORKER threads are identical in that regard. As they keep running in the kernel until they die, skip setting the FPU flag on them.
---
Not urgent, more of a cosmetic thing that was found while debugging and issue and pondering why the FPU flag is set on these threads.
arch/x86/include/asm/fpu/sched.h +1 -1
@@ -39,7 +39,7 @@ extern void fpu_flush_thread(void);static inline void switch_fpu_prepare (struct fpu *old_fpu,int cpu) {if (cpu_feature_enabled (X86_FEATURE_FPU ) && - !(current->flags &PF_KTHREAD )) { + !(current->flags & (PF_KTHREAD |PF_IO_WORKER ))) {save_fpregs_to_fpstate (old_fpu);/* * The save operation preserved register state, so the
arch/x86/kernel/fpu/context.h +1 -1
@@ -57,7 +57,7 @@ static inline void fpregs_restore_userregs(void)struct fpu *fpu = ¤t->thread.fpu;int cpu =smp_processor_id (); -if (WARN_ON_ONCE (current->flags &PF_KTHREAD )) +if (WARN_ON_ONCE (current->flags & (PF_KTHREAD |PF_IO_WORKER )))return ;if (!fpregs_state_valid (fpu, cpu)) {
arch/x86/kernel/fpu/core.c +1 -1
@@ -426,7 +426,7 @@ void kernel_fpu_begin_mask(unsigned int kfpu_mask)this_cpu_write (in_kernel_fpu, true); -if (!(current->flags &PF_KTHREAD ) && +if (!(current->flags & (PF_KTHREAD |PF_IO_WORKER )) && !test_thread_flag (TIF_NEED_FPU_LOAD )) {set_thread_flag (TIF_NEED_FPU_LOAD );save_fpregs_to_fpstate (¤t->thread.fpu);
Signature · 1 line
Jens Axboe
Quoted 3 lines · Jens Axboe
We don't set it on
PF_KTHREADthreads as they never return to userspace, andPF_IO_WORKERthreads are identical in that regard. As they keep running in the kernel until they die, skip setting the FPU flag on them.
No objection to the actual patch; but this changelog fails to tell us why this is important.
What made you get up and write this patch :-) Presumably this is a performance issue? If so, can you quantify how much?
Quoted 10 lines · Peter Zijlstra
Quoted 3 lines · Jens Axboe
We don't set it on
PF_KTHREADthreads as they never return to userspace, andPF_IO_WORKERthreads are identical in that regard. As they keep running in the kernel until they die, skip setting the FPU flag on them.No objection to the actual patch; but this changelog fails to tell us why this is important.
What made you get up and write this patch :-) Presumably this is a performance issue? If so, can you quantify how much?
You snipped the part where that was explained, but arguably that should probably go into the commit message itself:
"Not urgent, more of a cosmetic thing that was found while debugging and issue and pondering why the FPU flag is set on these threads."
So it's not really a performance issue, it was just something odd that got me scratching my head when debugging another issue and poking at the flags.
Want a resend of it, or will you just augment the commit message?
Signature · 1 line
Jens Axboe
Quoted 9 lines · Jens Axboe
Quoted 8 lines · Peter Zijlstra
Quoted 3 lines · Jens Axboe
We don't set it on
PF_KTHREADthreads as they never return to userspace, andPF_IO_WORKERthreads are identical in that regard. As they keep running in the kernel until they die, skip setting the FPU flag on them.No objection to the actual patch; but this changelog fails to tell us why this is important.
Quoted 8 lines
Quoted 2 lines
What made you get up and write this patch :-) Presumably this is a performance issue? If so, can you quantify how much?
You snipped the part where that was explained, but arguably that should probably go into the commit message itself:
"Not urgent, more of a cosmetic thing that was found while debugging and issue and pondering why the FPU flag is set on these threads."
Duh, I stopped reading at the --- just like a patch tool.. :/
Quoted 5 lines
So it's not really a performance issue, it was just something odd that got me scratching my head when debugging another issue and poking at the flags.
Want a resend of it, or will you just augment the commit message?
I think tglx typically takes fpu patches, but sure can do.
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Jens Axboe
Quoted 10 lines · Peter Zijlstra
Quoted 3 lines · Jens Axboe
We don't set it on
PF_KTHREADthreads as they never return to userspace, andPF_IO_WORKERthreads are identical in that regard. As they keep running in the kernel until they die, skip setting the FPU flag on them.No objection to the actual patch; but this changelog fails to tell us why this is important.
What made you get up and write this patch :-) Presumably this is a performance issue? If so, can you quantify how much?
Quoted 7 lines
Quoted 5 lines
You snipped the part where that was explained, but arguably that should probably go into the commit message itself:
"Not urgent, more of a cosmetic thing that was found while debugging and issue and pondering why the FPU flag is set on these threads."
Duh, I stopped reading at the --- just like a patch tool.. :/
Yeah... Half of that should've been in the commit message, my bad.
Quoted 7 lines
Quoted 5 lines
So it's not really a performance issue, it was just something odd that got me scratching my head when debugging another issue and poking at the flags.
Want a resend of it, or will you just augment the commit message?
I think tglx typically takes fpu patches, but sure can do.
Thanks!
Signature · 1 line
Jens Axboe
[tip: x86/fpu] x86/fpu: Don't set TIF_NEED_FPU_LOAD for PF_IO_WORKER threads
In reply to Jens AxboeThe following commit has been merged into the x86/fpu branch of tip:
The following commit has been merged into the x86/fpu branch of tip:
Commit-ID: cb3ea4b7671b7cfbac3ee609976b790aebd0bbda Gitweb: https://git.kernel.org/tip/cb3ea4b7671b7cfbac3ee609976b790aebd0bbda Author: Jens Axboe <[email protected]> AuthorDate: Tue, 24 Jan 2023 08:23:20 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 25 Jan 2023 12:35:15 +01:00
x86/fpu: Don't set TIF_NEED_FPU_LOAD for PF_IO_WORKER threads
We don't set it on PF_KTHREAD threads as they never return to userspace, and PF_IO_WORKER threads are identical in that regard. As they keep running in the kernel until they die, skip setting the FPU flag on them.
More of a cosmetic thing that was found while debugging and issue and pondering why the FPU flag is set on these threads.
--- arch/x86/include/asm/fpu/sched.h | 2 +- arch/x86/kernel/fpu/context.h | 2 +- arch/x86/kernel/fpu/core.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/fpu/sched.h +1 -1
@@ -39,7 +39,7 @@ extern void fpu_flush_thread(void);static inline void switch_fpu_prepare (struct fpu *old_fpu,int cpu) {if (cpu_feature_enabled (X86_FEATURE_FPU ) && - !(current->flags &PF_KTHREAD )) { + !(current->flags & (PF_KTHREAD |PF_IO_WORKER ))) {save_fpregs_to_fpstate (old_fpu);/* * The save operation preserved register state, so the
arch/x86/kernel/fpu/context.h +1 -1
@@ -57,7 +57,7 @@ static inline void fpregs_restore_userregs(void)struct fpu *fpu = ¤t->thread.fpu;int cpu =smp_processor_id (); -if (WARN_ON_ONCE (current->flags &PF_KTHREAD )) +if (WARN_ON_ONCE (current->flags & (PF_KTHREAD |PF_IO_WORKER )))return ;if (!fpregs_state_valid (fpu, cpu)) {
arch/x86/kernel/fpu/core.c +1 -1
@@ -426,7 +426,7 @@ void kernel_fpu_begin_mask(unsigned int kfpu_mask)this_cpu_write (in_kernel_fpu, true); -if (!(current->flags &PF_KTHREAD ) && +if (!(current->flags & (PF_KTHREAD |PF_IO_WORKER )) && !test_thread_flag (TIF_NEED_FPU_LOAD )) {set_thread_flag (TIF_NEED_FPU_LOAD );save_fpregs_to_fpstate (¤t->thread.fpu);