Re: [Next] CPU Hotplug test failures on powerpc

From: Xiaotian Feng
Date: Wed Dec 16 2009 - 04:07:40 EST


On Wed, Dec 16, 2009 at 4:24 PM, Sachin Sant <sachinp@xxxxxxxxxx> wrote:
> Xiaotian Feng wrote:
>>
>> Could follow be possible? ÂWe know there's cpu 0 and cpu 1,
>>
>> offline cpu1 > done
>> offline cpu0 > false
>>
>> consider this in cpu_down code,
>>
>>
>> int __ref cpu_down(unsigned int cpu)
>> {
>> <snip>
>> Â Â Â Âset_cpu_active(cpu, false); // here, we set cpu 0 to inactive
>>
>> Â Â Â Âsynchronize_sched();
>>
>> Â Â Â Âerr = _cpu_down(cpu, 0);
>> out:
>> <snip>
>> }
>>
>> Then in _cpu_down code:
>>
>> static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
>> {
>> <snip>
>> Â Â Â Âif (num_online_cpus() == 1) Â Â Â Â// if we're trying to
>> offline cpu0, num_online_cpus will be 1
>> Â Â Â Â Â Â Â Âreturn -EBUSY; Â Â Â Â Â Â Â Â Â Â// after return back
>> to cpu_down, we didn't change cpu 0 back to active
>>
>> Â Â Â Âif (!cpu_online(cpu))
>> Â Â Â Â Â Â Â Âreturn -EINVAL;
>>
>> Â Â Â Âif (!alloc_cpumask_var(&old_allowed, GFP_KERNEL))
>> Â Â Â Â Â Â Â Âreturn -ENOMEM;
>> <snip>
>> }
>>
>> Then cpu 0 is not active, but online, then we try to offline cpu1, .......
>> This can not be exposed because x86 does not have
>> /sys/devices/system/cpu0/online.
>> I guess following patch fixes this bug.
>>
>
> Just tested this one on the POWER box and the test passed.
> I did not observe the hang.

Thanks for confirm, I will send formatted patch to upstream then:-)

>
> Thanks
> -Sachin
>
>> ---
>> diff --git a/kernel/cpu.c b/kernel/cpu.c
>> index 291ac58..21ddace 100644
>> --- a/kernel/cpu.c
>> +++ b/kernel/cpu.c
>> @@ -199,14 +199,18 @@ static int __ref _cpu_down(unsigned int cpu, int
>> tasks_frozen)
>> Â Â Â Â Â Â Â Â.hcpu = hcpu,
>> Â Â Â Â};
>>
>> - Â Â Â if (num_online_cpus() == 1)
>> + Â Â Â if (num_online_cpus() == 1) {
>> + Â Â Â Â Â Â Â set_cpu_active(cpu, true);
>> Â Â Â Â Â Â Â Âreturn -EBUSY;
>> + Â Â Â }
>>
>> Â Â Â Âif (!cpu_online(cpu))
>> Â Â Â Â Â Â Â Âreturn -EINVAL;
>>
>> - Â Â Â if (!alloc_cpumask_var(&old_allowed, GFP_KERNEL))
>> + Â Â Â if (!alloc_cpumask_var(&old_allowed, GFP_KERNEL)) {
>> + Â Â Â Â Â Â Â set_cpu_active(cpu, true);
>> Â Â Â Â Â Â Â Âreturn -ENOMEM;
>> + Â Â Â }
>>
>> Â Â Â Âcpu_hotplug_begin();
>> Â Â Â Âerr = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod,
>>
>>
>>
>>>
>>> Unless of course, I messed up, which appears to be rather likely given
>>> these problems ;-)
>>>
>>>
>>>
>>
>>
>
>
> --
>
> ---------------------------------
> Sachin Sant
> IBM Linux Technology Center
> India Systems and Technology Labs
> Bangalore, India
> ---------------------------------
>
>
--
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/