x86/fpu: Move eager_fpu_init() to fpu/init.c
Move eager_fpu_init() and the 'eagerfpu' boot parameter handling function to the generic FPU init file: it's generic FPU functionality. Reviewed-by: Borislav Petkov <bp@alien8.de> Cc: Andy Lutomirski <luto@amacapital.net> 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>
This commit is contained in:
parent
89abbe01a4
commit
6f5d265aff
2 changed files with 48 additions and 48 deletions
|
@ -149,6 +149,54 @@ void fpu__init_cpu(void)
|
||||||
fpu__init_cpu_xstate();
|
fpu__init_cpu_xstate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum { AUTO, ENABLE, DISABLE } eagerfpu = AUTO;
|
||||||
|
|
||||||
|
static int __init eager_fpu_setup(char *s)
|
||||||
|
{
|
||||||
|
if (!strcmp(s, "on"))
|
||||||
|
eagerfpu = ENABLE;
|
||||||
|
else if (!strcmp(s, "off"))
|
||||||
|
eagerfpu = DISABLE;
|
||||||
|
else if (!strcmp(s, "auto"))
|
||||||
|
eagerfpu = AUTO;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
__setup("eagerfpu=", eager_fpu_setup);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* setup_init_fpu_buf() is __init and it is OK to call it here because
|
||||||
|
* init_xstate_ctx will be unset only once during boot.
|
||||||
|
*/
|
||||||
|
void __init_refok eager_fpu_init(void)
|
||||||
|
{
|
||||||
|
WARN_ON(current->thread.fpu.fpstate_active);
|
||||||
|
current_thread_info()->status = 0;
|
||||||
|
|
||||||
|
/* Auto enable eagerfpu for xsaveopt */
|
||||||
|
if (cpu_has_xsaveopt && eagerfpu != DISABLE)
|
||||||
|
eagerfpu = ENABLE;
|
||||||
|
|
||||||
|
if (xfeatures_mask & XSTATE_EAGER) {
|
||||||
|
if (eagerfpu == DISABLE) {
|
||||||
|
pr_err("x86/fpu: eagerfpu switching disabled, disabling the following xstate features: 0x%llx.\n",
|
||||||
|
xfeatures_mask & XSTATE_EAGER);
|
||||||
|
xfeatures_mask &= ~XSTATE_EAGER;
|
||||||
|
} else {
|
||||||
|
eagerfpu = ENABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eagerfpu == ENABLE)
|
||||||
|
setup_force_cpu_cap(X86_FEATURE_EAGER_FPU);
|
||||||
|
|
||||||
|
printk_once(KERN_INFO "x86/fpu: Using '%s' FPU context switches.\n", eagerfpu == ENABLE ? "eager" : "lazy");
|
||||||
|
|
||||||
|
if (!cpu_has_eager_fpu) {
|
||||||
|
stts();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called on the boot CPU once per system bootup, to set up the initial FPU state that
|
* Called on the boot CPU once per system bootup, to set up the initial FPU state that
|
||||||
* is later cloned into all processes.
|
* is later cloned into all processes.
|
||||||
|
|
|
@ -599,20 +599,6 @@ static void setup_init_fpu_buf(void)
|
||||||
xsave_state_booting(&init_xstate_ctx);
|
xsave_state_booting(&init_xstate_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum { AUTO, ENABLE, DISABLE } eagerfpu = AUTO;
|
|
||||||
static int __init eager_fpu_setup(char *s)
|
|
||||||
{
|
|
||||||
if (!strcmp(s, "on"))
|
|
||||||
eagerfpu = ENABLE;
|
|
||||||
else if (!strcmp(s, "off"))
|
|
||||||
eagerfpu = DISABLE;
|
|
||||||
else if (!strcmp(s, "auto"))
|
|
||||||
eagerfpu = AUTO;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
__setup("eagerfpu=", eager_fpu_setup);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate total size of enabled xstates in XCR0/xfeatures_mask.
|
* Calculate total size of enabled xstates in XCR0/xfeatures_mask.
|
||||||
*/
|
*/
|
||||||
|
@ -692,40 +678,6 @@ void fpu__init_system_xstate(void)
|
||||||
cpu_has_xsaves ? "compacted" : "standard");
|
cpu_has_xsaves ? "compacted" : "standard");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* setup_init_fpu_buf() is __init and it is OK to call it here because
|
|
||||||
* init_xstate_ctx will be unset only once during boot.
|
|
||||||
*/
|
|
||||||
void __init_refok eager_fpu_init(void)
|
|
||||||
{
|
|
||||||
WARN_ON(current->thread.fpu.fpstate_active);
|
|
||||||
current_thread_info()->status = 0;
|
|
||||||
|
|
||||||
/* Auto enable eagerfpu for xsaveopt */
|
|
||||||
if (cpu_has_xsaveopt && eagerfpu != DISABLE)
|
|
||||||
eagerfpu = ENABLE;
|
|
||||||
|
|
||||||
if (xfeatures_mask & XSTATE_EAGER) {
|
|
||||||
if (eagerfpu == DISABLE) {
|
|
||||||
pr_err("x86/fpu: eagerfpu switching disabled, disabling the following xstate features: 0x%llx.\n",
|
|
||||||
xfeatures_mask & XSTATE_EAGER);
|
|
||||||
xfeatures_mask &= ~XSTATE_EAGER;
|
|
||||||
} else {
|
|
||||||
eagerfpu = ENABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eagerfpu == ENABLE)
|
|
||||||
setup_force_cpu_cap(X86_FEATURE_EAGER_FPU);
|
|
||||||
|
|
||||||
printk_once(KERN_INFO "x86/fpu: Using '%s' FPU context switches.\n", eagerfpu == ENABLE ? "eager" : "lazy");
|
|
||||||
|
|
||||||
if (!cpu_has_eager_fpu) {
|
|
||||||
stts();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Restore minimal FPU state after suspend:
|
* Restore minimal FPU state after suspend:
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue