x86/fpu changes for v4.6
Linus,
Please pull the latest x86-fpu-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-fpu-for-linus
# HEAD: 14ddde78c787248ada9da2f2d04900548ffcf342 Merge branch 'linus' into x86/fpu, to pick up fixes
The biggest change in terms of impact is the changing of the FPU context switch model to 'eagerfpu' for all CPU types, via:
58122bf1d856 x86/fpu: Default eagerfpu=on on all CPUs
This makes all FPU saves and restores synchronous and makes the FPU code a lot more obvious to read. In the next cycle, if this change is problem free, we'll remove the old lazy FPU restore code altogether.
This change flushed out some old bugs, which should all be fixed by now, BYMMV.
Thanks,
Ingo
------------------>
Andy Lutomirski (5):
x86/fpu: Fix math emulation in eager fpu mode x86/fpu: Fix FNSAVE usage in eagerfpu mode x86/fpu: Fold fpu_copy() into fpu__copy() x86/fpu: Speed up lazy FPU restores slightly x86/fpu: Default eagerfpu=on on all CPUs
arch/x86/include/asm/fpu/internal.h | 3 ++- arch/x86/kernel/fpu/core.c | 52 +++++++++++++++++++------------------ arch/x86/kernel/fpu/init.c | 13 ++++------ arch/x86/kernel/traps.c | 3 +-- 4 files changed, 35 insertions(+), 36 deletions(-)
arch/x86/include/asm/fpu/internal.h +2 -1
@@ -589,7 +589,8 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)* If the task has used the math, pre-load the FPU on xsave processors * or if the past 5 consecutive context-switches used math. */ - fpu.preload = new_fpu->fpstate_active && + fpu.preload =static_cpu_has (X86_FEATURE_FPU ) && + new_fpu->fpstate_active && (use_eager_fpu () || new_fpu->counter >5 );if (old_fpu->fpregs_active) {
arch/x86/kernel/fpu/core.c +27 -25
91 lines not on this page · raw message
arch/x86/kernel/fpu/init.c +5 -8
@@ -260,7 +260,10 @@ static void __init fpu__init_system_xstate_size_legacy(void)* not only saved the restores along the way, but we also have the * FPU ready to be used for the original task. * -* 'eager' switching is used on modern CPUs, there we switch the FPU +* 'lazy' is deprecated because it's almost never a performance win +* and it's much more complicated than 'eager'. +* +* 'eager' switching is by default on all CPUs, there we switch the FPU * state during every context switch, regardless of whether the task * has used FPU instructions in that time slice or not. This is done * because modern FPU context saving instructions are able to optimize
@@ -271,7 +274,7 @@ static void __init fpu__init_system_xstate_size_legacy(void)* to use 'eager' restores, if we detect that a task is using the FPU * frequently. See the fpu->counter logic in fpu/internal.h for that. ] */ -static enum {AUTO ,ENABLE ,DISABLE } eagerfpu =AUTO ; +static enum {ENABLE ,DISABLE } eagerfpu =ENABLE ;/* * Find supported xfeatures based on cpu features and command-line input.
@@ -348,15 +351,9 @@ static void __init fpu__init_system_ctx_switch(void)*/ static void __init fpu__init_parse_early_param (void ) { -/* -* No need to check "eagerfpu=auto" again, since it is the -* initial default. -*/ if (cmdline_find_option_bool (boot_command_line,"eagerfpu=off" )) { eagerfpu =DISABLE ;fpu__clear_eager_fpu_features (); - }else if (cmdline_find_option_bool (boot_command_line,"eagerfpu=on" )) { - eagerfpu =ENABLE ; }if (cmdline_find_option_bool (boot_command_line,"no387" ))
arch/x86/kernel/traps.c +1 -2
@@ -750,10 +750,9 @@ dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code) {RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" ); -BUG_ON (use_eager_fpu ());#ifdef CONFIG_MATH_EMULATION -if (read_cr0 () &X86_CR0_EM ) { +if (!boot_cpu_has (X86_FEATURE_FPU ) && (read_cr0 () &X86_CR0_EM )) {struct math_emu_info info = { };conditional_sti (regs);