Skip to content

Commit 7e29569

Browse files
amlutoZhengShunQian
authored andcommitted
x86/fpu: Default eagerfpu=on on all CPUs
commit 58122bf upstream. We have eager and lazy FPU modes, introduced in: 304bced ("x86, fpu: use non-lazy fpu restore for processors supporting xsave") The result is rather messy. There are two code paths in almost all of the FPU code, and only one of them (the eager case) is tested frequently, since most kernel developers have new enough hardware that we use eagerfpu. It seems that, on any remotely recent hardware, eagerfpu is a win: glibc uses SSE2, so laziness is probably overoptimistic, and, in any case, manipulating TS is far slower that saving and restoring the full state. (Stores to CR0.TS are serializing and are poorly optimized.) To try to shake out any latent issues on old hardware, this changes the default to eager on all CPUs. If no performance or functionality problems show up, a subsequent patch could remove lazy mode entirely. Signed-off-by: Andy Lutomirski <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Quentin Casasnovas <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Sai Praneeth Prakhya <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: yu-cheng yu <[email protected]> Link: http://lkml.kernel.org/r/ac290de61bf08d9cfc2664a4f5080257ffc1075a.1453675014.git.luto@kernel.org Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9722311 commit 7e29569

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

arch/x86/kernel/fpu/init.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ static void __init fpu__init_system_xstate_size_legacy(void)
252252
* not only saved the restores along the way, but we also have the
253253
* FPU ready to be used for the original task.
254254
*
255-
* 'eager' switching is used on modern CPUs, there we switch the FPU
255+
* 'lazy' is deprecated because it's almost never a performance win
256+
* and it's much more complicated than 'eager'.
257+
*
258+
* 'eager' switching is by default on all CPUs, there we switch the FPU
256259
* state during every context switch, regardless of whether the task
257260
* has used FPU instructions in that time slice or not. This is done
258261
* because modern FPU context saving instructions are able to optimize
@@ -263,7 +266,7 @@ static void __init fpu__init_system_xstate_size_legacy(void)
263266
* to use 'eager' restores, if we detect that a task is using the FPU
264267
* frequently. See the fpu->counter logic in fpu/internal.h for that. ]
265268
*/
266-
static enum { AUTO, ENABLE, DISABLE } eagerfpu = AUTO;
269+
static enum { ENABLE, DISABLE } eagerfpu = ENABLE;
267270

268271
/*
269272
* Find supported xfeatures based on cpu features and command-line input.
@@ -340,15 +343,9 @@ static void __init fpu__init_system_ctx_switch(void)
340343
*/
341344
static void __init fpu__init_parse_early_param(void)
342345
{
343-
/*
344-
* No need to check "eagerfpu=auto" again, since it is the
345-
* initial default.
346-
*/
347346
if (cmdline_find_option_bool(boot_command_line, "eagerfpu=off")) {
348347
eagerfpu = DISABLE;
349348
fpu__clear_eager_fpu_features();
350-
} else if (cmdline_find_option_bool(boot_command_line, "eagerfpu=on")) {
351-
eagerfpu = ENABLE;
352349
}
353350

354351
if (cmdline_find_option_bool(boot_command_line, "no387"))

0 commit comments

Comments
 (0)