Re: [PATCH] a patch to fix the cpu-offline-online problem caused by pm_idle
From: Luming Yu
Date: Mon Jan 24 2011 - 20:59:46 EST
On Tue, Jan 25, 2011 at 2:41 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Mon, 2011-01-24 at 02:34 -0500, Luming Yu wrote:
>> Hi there,
>>
>> I've seen many problems caused by deep-c-state-capable pm_idle on a
>> NHM-EX system with this test script
>> # for i in `seq 1 1000`; do echo $i; echo 0 >
>> /sys/devices/system/cpu/cpu59/online ; sleep 1; echo 1 >
>> /sys/devices/system/cpu/cpu59/online; done
>>
>> As the bug " CPU online/offline causes system slowdown"
>> https://bugzilla.redhat.com/show_bug.cgi?id=586551 described.
>>
>> The simplest and easiest and cleanest way I can think of now is as the
>> patch attached.
>>
>> Signed-off-by: Yu Luming <luming.yu@xxxxxxxxx>
>>
>> diff --git a/kernel/cpu.c b/kernel/cpu.c
>> index c75fcdd..d419eb3 100644
>> --- a/kernel/cpu.c
>> +++ b/kernel/cpu.c
>> @@ -135,6 +135,7 @@ int __ref register_cpu_notifier(struct notifier_block *nb)
>>
>> Â#ifdef CONFIG_HOTPLUG_CPU
>>
>> +static void (*pm_idle_saved) (void) __read_mostly;
>> ÂEXPORT_SYMBOL(register_cpu_notifier);
>>
>> Âvoid __ref unregister_cpu_notifier(struct notifier_block *nb)
>> @@ -145,6 +146,19 @@ void __ref unregister_cpu_notifier(struct
>> notifier_block *nb)
>> Â}
>> ÂEXPORT_SYMBOL(unregister_cpu_notifier);
>>
>> +static inline void save_pm_idle(void)
>> +{
>> + Â Â pm_idle_saved = pm_idle;
>> + Â Â pm_idle = default_idle;
>> + Â Â cpu_idle_wait();
>> +}
>> +
>> +static inline void restore_pm_idle(void)
>> +{
>> + Â Â pm_idle = pm_idle_saved;
>> + Â Â cpu_idle_wait();
>> +}
>> +
>> Âstatic inline void check_for_tasks(int cpu)
>> Â{
>> Â Â Â struct task_struct *p;
>> @@ -278,7 +292,9 @@ int __ref cpu_down(unsigned int cpu)
>> Â Â Â Â Â Â Â goto out;
>> Â Â Â }
>>
>> + Â Â save_pm_idle();
>> Â Â Â err = _cpu_down(cpu, 0);
>> + Â Â restore_pm_idle();
>>
>> Âout:
>> Â Â Â cpu_maps_update_done();
>> @@ -376,7 +392,9 @@ int __cpuinit cpu_up(unsigned int cpu)
>> Â Â Â Â Â Â Â goto out;
>> Â Â Â }
>>
>> + Â Â save_pm_idle();
>> Â Â Â err = _cpu_up(cpu, 0);
>> + Â Â restore_pm_idle();
>>
>> Âout:
>> Â Â Â cpu_maps_update_done();
>
> Ow god this is ugly.. pm_idle should die asap, not find it way into generic code, so NAK!
Without the ugly fix, we seem not able to fix the problem in short time.
Or , Are you suggesting to wrap pm_idle or similar in some generic
code that would not disappear in foreseeable future , Or Are you just
suggesting me don't do the stuff in kerne/cpu.c, and do it in Arch
code?
But..I bet It's not that wise to let CPU hot-plug code to interact
with PM code for all Arch, so I proposed the ugly patch in generic
code.
--Luming
--
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/