Skip to content

Commit 6cf4edb

Browse files
author
Ingo Molnar
committed
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 <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Eric Biggers <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Yu-cheng Yu <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent f1c8cd0 commit 6cf4edb

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

arch/x86/include/asm/fpu/internal.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,17 +526,13 @@ static inline int fpregs_state_valid(struct fpu *fpu, unsigned int cpu)
526526
*/
527527
static inline void fpregs_deactivate(struct fpu *fpu)
528528
{
529-
WARN_ON_FPU(!fpu->fpregs_active);
530-
531529
fpu->fpregs_active = 0;
532530
this_cpu_write(fpu_fpregs_owner_ctx, NULL);
533531
trace_x86_fpu_regs_deactivated(fpu);
534532
}
535533

536534
static inline void fpregs_activate(struct fpu *fpu)
537535
{
538-
WARN_ON_FPU(fpu->fpregs_active);
539-
540536
fpu->fpregs_active = 1;
541537
this_cpu_write(fpu_fpregs_owner_ctx, fpu);
542538
trace_x86_fpu_regs_activated(fpu);
@@ -604,8 +600,7 @@ static inline void user_fpu_begin(void)
604600
struct fpu *fpu = &current->thread.fpu;
605601

606602
preempt_disable();
607-
if (!fpu->fpregs_active)
608-
fpregs_activate(fpu);
603+
fpregs_activate(fpu);
609604
preempt_enable();
610605
}
611606

arch/x86/kernel/fpu/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ void fpu__drop(struct fpu *fpu)
426426
asm volatile("1: fwait\n"
427427
"2:\n"
428428
_ASM_EXTABLE(1b, 2b));
429-
if (fpu->fpregs_active)
430-
fpregs_deactivate(fpu);
429+
fpregs_deactivate(fpu);
431430
}
432431
} else {
433432
WARN_ON_FPU(fpu->fpregs_active);

0 commit comments

Comments
 (0)