Commit 6cf4edbe authored by Ingo Molnar's avatar Ingo Molnar

x86/fpu: Decouple fpregs_activate()/fpregs_deactivate() from fpu->fpregs_active

The fpregs_activate()/fpregs_deactivate() are currently called in such a pattern:

	if (!fpu->fpregs_active)
		fpregs_activate(fpu);

	...

	if (fpu->fpregs_active)
		fpregs_deactivate(fpu);

But note that it's actually safe to call them without checking the flag first.

This further decouples the fpu->fpregs_active flag from actual FPU logic.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
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-20-mingo@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent f1c8cd01
...@@ -526,8 +526,6 @@ static inline int fpregs_state_valid(struct fpu *fpu, unsigned int cpu) ...@@ -526,8 +526,6 @@ static inline int fpregs_state_valid(struct fpu *fpu, unsigned int cpu)
*/ */
static inline void fpregs_deactivate(struct fpu *fpu) static inline void fpregs_deactivate(struct fpu *fpu)
{ {
WARN_ON_FPU(!fpu->fpregs_active);
fpu->fpregs_active = 0; fpu->fpregs_active = 0;
this_cpu_write(fpu_fpregs_owner_ctx, NULL); this_cpu_write(fpu_fpregs_owner_ctx, NULL);
trace_x86_fpu_regs_deactivated(fpu); trace_x86_fpu_regs_deactivated(fpu);
...@@ -535,8 +533,6 @@ static inline void fpregs_deactivate(struct fpu *fpu) ...@@ -535,8 +533,6 @@ static inline void fpregs_deactivate(struct fpu *fpu)
static inline void fpregs_activate(struct fpu *fpu) static inline void fpregs_activate(struct fpu *fpu)
{ {
WARN_ON_FPU(fpu->fpregs_active);
fpu->fpregs_active = 1; fpu->fpregs_active = 1;
this_cpu_write(fpu_fpregs_owner_ctx, fpu); this_cpu_write(fpu_fpregs_owner_ctx, fpu);
trace_x86_fpu_regs_activated(fpu); trace_x86_fpu_regs_activated(fpu);
...@@ -604,8 +600,7 @@ static inline void user_fpu_begin(void) ...@@ -604,8 +600,7 @@ static inline void user_fpu_begin(void)
struct fpu *fpu = &current->thread.fpu; struct fpu *fpu = &current->thread.fpu;
preempt_disable(); preempt_disable();
if (!fpu->fpregs_active) fpregs_activate(fpu);
fpregs_activate(fpu);
preempt_enable(); preempt_enable();
} }
......
...@@ -426,8 +426,7 @@ void fpu__drop(struct fpu *fpu) ...@@ -426,8 +426,7 @@ void fpu__drop(struct fpu *fpu)
asm volatile("1: fwait\n" asm volatile("1: fwait\n"
"2:\n" "2:\n"
_ASM_EXTABLE(1b, 2b)); _ASM_EXTABLE(1b, 2b));
if (fpu->fpregs_active) fpregs_deactivate(fpu);
fpregs_deactivate(fpu);
} }
} else { } else {
WARN_ON_FPU(fpu->fpregs_active); WARN_ON_FPU(fpu->fpregs_active);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment