diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-09-23 09:00:14 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-09-26 03:43:44 -0400 |
commit | e10078eba69859359ce8644dd423b4132a6a8913 (patch) | |
tree | db0aadc1cbc41c2690877954ed396dcdec85a860 | |
parent | 7f1487c59b7c6dcb20155f4302985da2659a2997 (diff) |
x86/fpu: Simplify and speed up fpu__copy()
fpu__copy() has a preempt_disable()/enable() pair, which it had to do to
be able to atomically unlazy the current task when doing an FNSAVE.
But we don't unlazy tasks anymore, we always do direct saves/restores of
FPU context.
So remove both the unnecessary critical section, and update the comments.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/20170923130016.21448-32-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/kernel/fpu/core.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 77668d91fdc1..52122dd418ae 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c | |||
@@ -206,22 +206,13 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) | |||
206 | * Save current FPU registers directly into the child | 206 | * Save current FPU registers directly into the child |
207 | * FPU context, without any memory-to-memory copying. | 207 | * FPU context, without any memory-to-memory copying. |
208 | * | 208 | * |
209 | * We have to do all this with preemption disabled, | 209 | * ( The function 'fails' in the FNSAVE case, which destroys |
210 | * mostly because of the FNSAVE case, because in that | 210 | * register contents so we have to copy them back. ) |
211 | * case we must not allow preemption in the window | ||
212 | * between the FNSAVE and us marking the context lazy. | ||
213 | * | ||
214 | * It shouldn't be an issue as even FNSAVE is plenty | ||
215 | * fast in terms of critical section length. | ||
216 | */ | 211 | */ |
217 | preempt_disable(); | ||
218 | if (!copy_fpregs_to_fpstate(dst_fpu)) { | 212 | if (!copy_fpregs_to_fpstate(dst_fpu)) { |
219 | memcpy(&src_fpu->state, &dst_fpu->state, | 213 | memcpy(&src_fpu->state, &dst_fpu->state, fpu_kernel_xstate_size); |
220 | fpu_kernel_xstate_size); | ||
221 | |||
222 | copy_kernel_to_fpregs(&src_fpu->state); | 214 | copy_kernel_to_fpregs(&src_fpu->state); |
223 | } | 215 | } |
224 | preempt_enable(); | ||
225 | 216 | ||
226 | trace_x86_fpu_copy_src(src_fpu); | 217 | trace_x86_fpu_copy_src(src_fpu); |
227 | trace_x86_fpu_copy_dst(dst_fpu); | 218 | trace_x86_fpu_copy_dst(dst_fpu); |