2007-11-26 08:35:48

by Yinghai Lu

[permalink] [raw]
Subject: [PATCH] x86_64: not set boot cpu in cpu_online_map at smp_prepare_boot_cpu

[PATCH] x86_64: not set boot cpu in cpu_online_map at smp_prepare_boot_cpu

in init/main.c boot_cpu_init() does that before

Signed-off-by: Yinghai Lu <[email protected]>

diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
index 500670c..966d124 100644
--- a/arch/x86/kernel/smpboot_64.c
+++ b/arch/x86/kernel/smpboot_64.c
@@ -912,7 +912,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
void __init smp_prepare_boot_cpu(void)
{
int me = smp_processor_id();
- cpu_set(me, cpu_online_map);
+ /* already set me in cpu_online_map in boot_cpu_init() */
cpu_set(me, cpu_callout_map);
per_cpu(cpu_state, me) = CPU_ONLINE;
}


2007-11-26 20:54:23

by Zachary Amsden

[permalink] [raw]
Subject: Re: [PATCH] x86_64: not set boot cpu in cpu_online_map at smp_prepare_boot_cpu

On Mon, 2007-11-26 at 00:38 -0800, Yinghai Lu wrote:
> [PATCH] x86_64: not set boot cpu in cpu_online_map at smp_prepare_boot_cpu
>
> in init/main.c boot_cpu_init() does that before
>
> Signed-off-by: Yinghai Lu <[email protected]>
>
> diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
> index 500670c..966d124 100644
> --- a/arch/x86/kernel/smpboot_64.c
> +++ b/arch/x86/kernel/smpboot_64.c
> @@ -912,7 +912,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> void __init smp_prepare_boot_cpu(void)
> {
> int me = smp_processor_id();
> - cpu_set(me, cpu_online_map);
> + /* already set me in cpu_online_map in boot_cpu_init() */
> cpu_set(me, cpu_callout_map);
> per_cpu(cpu_state, me) = CPU_ONLINE;
> }


This ordering can be tricky wrt CPU hotplug. Are you sure you are not
breaking CPU hotplug? AFAIK, x86_64 has that right and the 32-bit code
had it wrong.

Zach

2007-11-26 22:01:41

by Yinghai Lu

[permalink] [raw]
Subject: Re: [PATCH] x86_64: not set boot cpu in cpu_online_map at smp_prepare_boot_cpu

Zachary Amsden wrote:
> On Mon, 2007-11-26 at 00:38 -0800, Yinghai Lu wrote:
>> [PATCH] x86_64: not set boot cpu in cpu_online_map at smp_prepare_boot_cpu
>>
>> in init/main.c boot_cpu_init() does that before
>>
>> Signed-off-by: Yinghai Lu <[email protected]>
>>
>> diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
>> index 500670c..966d124 100644
>> --- a/arch/x86/kernel/smpboot_64.c
>> +++ b/arch/x86/kernel/smpboot_64.c
>> @@ -912,7 +912,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
>> void __init smp_prepare_boot_cpu(void)
>> {
>> int me = smp_processor_id();
>> - cpu_set(me, cpu_online_map);
>> + /* already set me in cpu_online_map in boot_cpu_init() */
>> cpu_set(me, cpu_callout_map);
>> per_cpu(cpu_state, me) = CPU_ONLINE;
>> }
>
>
> This ordering can be tricky wrt CPU hotplug. Are you sure you are not
> breaking CPU hotplug? AFAIK, x86_64 has that right and the 32-bit code
> had it wrong.


CPU hot plug path will call smp_prepare_boot_cpu?
it is using __init instead of __cpuinit?

YH

2007-11-26 22:32:55

by Zachary Amsden

[permalink] [raw]
Subject: Re: [PATCH] x86_64: not set boot cpu in cpu_online_map at smp_prepare_boot_cpu

On Mon, 2007-11-26 at 14:06 -0800, Yinghai Lu wrote:

> >> diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
> >> index 500670c..966d124 100644
> >> --- a/arch/x86/kernel/smpboot_64.c
> >> +++ b/arch/x86/kernel/smpboot_64.c
> >> @@ -912,7 +912,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> >> void __init smp_prepare_boot_cpu(void)
> >> {
> >> int me = smp_processor_id();
> >> - cpu_set(me, cpu_online_map);
> >> + /* already set me in cpu_online_map in boot_cpu_init() */
> >> cpu_set(me, cpu_callout_map);
> >> per_cpu(cpu_state, me) = CPU_ONLINE;
> >> }
> >
> >
> > This ordering can be tricky wrt CPU hotplug. Are you sure you are not
> > breaking CPU hotplug? AFAIK, x86_64 has that right and the 32-bit code
> > had it wrong.
>
>
> CPU hot plug path will call smp_prepare_boot_cpu?
> it is using __init instead of __cpuinit?

No, but moving the place where cpu is moved into online map might break
hotplug. In any case, I don't see anything wrong with your change now
that I look closer.

Zach