From: Rik van Riel Date: Wed, 5 Oct 2016 00:34:38 +0000 (-0400) Subject: x86/fpu: Split old & new FPU code paths X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9ad93fe35aff616fca4e2b9581fdeed498605f9e;p=openwrt%2Fstaging%2Fblogic.git x86/fpu: Split old & new FPU code paths Now that CR0.TS is no longer being manipulated, we can simplify switch_fpu_prepare() by no longer nesting the handling of new_fpu inside the two branches for the old_fpu. Signed-off-by: Rik van Riel Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: Denys Vlasenko Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Quentin Casasnovas Cc: Thomas Gleixner Cc: pbonzini@redhat.com Link: http://lkml.kernel.org/r/1475627678-20788-10-git-send-email-riel@redhat.com Signed-off-by: Ingo Molnar --- diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index d0324bcdd3d6..1dcb29e8d92c 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -581,23 +581,17 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu) /* But leave fpu_fpregs_owner_ctx! */ old_fpu->fpregs_active = 0; trace_x86_fpu_regs_deactivated(old_fpu); + } else + old_fpu->last_cpu = -1; - /* Don't change CR0.TS if we just switch! */ - if (fpu.preload) { - fpregs_activate(new_fpu); - trace_x86_fpu_regs_activated(new_fpu); + if (fpu.preload) { + if (fpregs_state_valid(new_fpu, cpu)) + fpu.preload = 0; + else prefetch(&new_fpu->state); - } - } else { - old_fpu->last_cpu = -1; - if (fpu.preload) { - if (fpregs_state_valid(new_fpu, cpu)) - fpu.preload = 0; - else - prefetch(&new_fpu->state); - fpregs_activate(new_fpu); - } + fpregs_activate(new_fpu); } + return fpu; }