Re: [PATCH v4 6/7] x86/i387.c: Thread xstate is initialized only onBSP once

From: Brian Gerst
Date: Sun Nov 13 2011 - 10:17:23 EST


On Sat, Nov 12, 2011 at 12:26 AM, Fenghua Yu <fenghua.yu@xxxxxxxxx> wrote:
> From: Fenghua Yu <fenghua.yu@xxxxxxxxx>
>
> init_thread_xstate() is only called on BSP once to avoid overriding xstate_size.
>
> Signed-off-by: Fenghua Yu <fenghua.yu@xxxxxxxxx>
> ---
> Âarch/x86/kernel/i387.c | Â Â9 ++++++++-
> Â1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
> index 739d859..72652ff 100644
> --- a/arch/x86/kernel/i387.c
> +++ b/arch/x86/kernel/i387.c
> @@ -93,6 +93,7 @@ void __cpuinit fpu_init(void)
> Â{
> Â Â Â Âunsigned long cr0;
> Â Â Â Âunsigned long cr4_mask = 0;
> + Â Â Â static int once = 1;
>
> Â Â Â Âif (cpu_has_fxsr)
> Â Â Â Â Â Â Â Âcr4_mask |= X86_CR4_OSFXSR;
> @@ -107,8 +108,14 @@ void __cpuinit fpu_init(void)
> Â Â Â Â Â Â Â Âcr0 |= X86_CR0_EM;
> Â Â Â Âwrite_cr0(cr0);
>
> - Â Â Â if (!smp_processor_id())
> + Â Â Â /*
> + Â Â Â Â* init_thread_xstate is only called on BSP once to avoid overriding
> + Â Â Â Â* xstate_size.
> + Â Â Â Â*/
> + Â Â Â if (!smp_processor_id() && once) {
> + Â Â Â Â Â Â Â once = 0;
> Â Â Â Â Â Â Â Âinit_thread_xstate();
> + Â Â Â }

Just check if xstate_size is 0 instead of adding a new flag.

--
Brian Gerst
--
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/