diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-04-29 20:24:14 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-05-19 15:48:04 +0200 |
commit | 6ffc152e4606c7f9149940d36a83e786f7f0a4f9 (patch) | |
tree | 613b2c361cba2334ab89319ae723756a9f955da0 /arch/x86/kernel/fpu/core.c | |
parent | 0e75c54f1703e83e6cdf239491bf7294f6c34777 (diff) | |
download | linux-stable-6ffc152e4606c7f9149940d36a83e786f7f0a4f9.tar.gz linux-stable-6ffc152e4606c7f9149940d36a83e786f7f0a4f9.tar.bz2 linux-stable-6ffc152e4606c7f9149940d36a83e786f7f0a4f9.zip |
x86/fpu: Move all the fpu__*() high level methods closer to each other
The fpu__*() methods are closely related, but they are defined
in scattered places within the FPU code.
Concentrate them, and also uninline fpu__save(), fpu__drop()
and fpu__reset() to save about 5K of kernel text on 64-bit kernels:
text data bss dec filename
14113063 2575280 1634304 18322647 vmlinux.before
14108070 2575280 1634304 18317654 vmlinux.after
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/fpu/core.c')
-rw-r--r-- | arch/x86/kernel/fpu/core.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 14d8e33d9fe0..acca83be23f0 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -349,6 +349,44 @@ void fpu__restore(void) EXPORT_SYMBOL_GPL(fpu__restore); /* + * Drops current FPU state: deactivates the fpregs and + * the fpstate. NOTE: it still leaves previous contents + * in the fpregs in the eager-FPU case. + * + * This function can be used in cases where we know that + * a state-restore is coming: either an explicit one, + * or a reschedule. + */ +void fpu__drop(struct fpu *fpu) +{ + preempt_disable(); + fpu->counter = 0; + + if (fpu->fpregs_active) { + /* Ignore delayed exceptions from user space */ + asm volatile("1: fwait\n" + "2:\n" + _ASM_EXTABLE(1b, 2b)); + fpregs_deactivate(fpu); + } + + fpu->fpstate_active = 0; + + preempt_enable(); +} + +/* + * Reset the FPU state back to init state: + */ +void fpu__reset(struct fpu *fpu) +{ + if (!use_eager_fpu()) + fpu__drop(fpu); + else + restore_init_xstate(); +} + +/* * Called by sys_execve() to clear the FPU fpregs, so that FPU state * of the previous binary does not leak over into the exec()ed binary: */ |