[PATCH 4/5] x86, fpu: shift init_fpu() from eager_fpu_init() to eager_fpu_init_bp()

From: Oleg Nesterov
Date: Sun Aug 24 2014 - 15:50:12 EST

This is not strictly needed, eager_fpu_init() is called before
the very first schedule() on this CPU, but let's remove the last
unconditional clear_used_math().

eager_fpu_init() does init_fpu() every time, but this is only needed
on boot CPU, otherwise this idle thread already has a valid fpu state
copied by arch_dup_task_struct().

And this allows to remove clear_used_math(). swapper/0 doesn't have
this flag when start_kernel() calls us, other idle threads correctly
have this flag set.

Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
arch/x86/kernel/xsave.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index 51be404..33f4ebe 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -601,19 +601,20 @@ void xsave_init(void)

-static inline void __init eager_fpu_init_bp(void)
+static void __init eager_fpu_init_bp(void)
current->thread.fpu.state =
alloc_bootmem_align(xstate_size, __alignof__(struct xsave_struct));
if (!init_xstate_buf)
+ init_fpu(current);

void eager_fpu_init(void)
static __refdata void (*boot_func)(void) = eager_fpu_init_bp;

- clear_used_math();
current_thread_info()->status = 0;

if (eagerfpu == ENABLE)
@@ -633,7 +634,6 @@ void eager_fpu_init(void)
* This is same as math_state_restore(). But use_xsave() is
* not yet patched to use math_state_restore().
- init_fpu(current);
if (cpu_has_xsave)
xrstor_state(init_xstate_buf, -1);

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/