Re: [PATCH 2/8] x86/mtrr/main.c: Ask the first online CPU to savemtrr

From: Srivatsa S. Bhat
Date: Wed Oct 05 2011 - 15:04:06 EST


Hi,

On 10/05/2011 10:09 PM, Fenghua Yu wrote:
> From: Fenghua Yu <fenghua.yu@xxxxxxxxx>
>
> Ask the first online CPU to save mtrr instead of asking BSP. BSP can be
> offlined when mtrr_save_state() is called.
>
> Signed-off-by: Fenghua Yu <fenghua.yu@xxxxxxxxx>
> ---
> arch/x86/kernel/cpu/mtrr/main.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
> index 6b96110..e18a4d3 100644
> --- a/arch/x86/kernel/cpu/mtrr/main.c
> +++ b/arch/x86/kernel/cpu/mtrr/main.c
> @@ -695,11 +695,13 @@ void mtrr_ap_init(void)
> }
>
> /**
> - * Save current fixed-range MTRR state of the BSP
> + * Save current fixed-range MTRR state of the first cpu in cpu_online_mask.
> */
> void mtrr_save_state(void)
> {
> - smp_call_function_single(0, mtrr_save_fixed_ranges, NULL, 1);
> + int first_cpu = cpumask_first(cpu_online_mask);

There is a race condition here as well. What if, at this point, the cpu
represented by first_cpu is taken offline (due to a cpu hotplug operation)?

> + smp_call_function_single(first_cpu, mtrr_save_fixed_ranges, NULL, 1);
> }
>
> void set_mtrr_aps_delayed_init(void)


--
Regards,
Srivatsa S. Bhat <srivatsa.bhat@xxxxxxxxxxxxxxxxxx>
Linux Technology Center,
IBM India Systems and Technology Lab
--
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/