public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] a patch to fix the cpu-offline-online problem caused by pm_idle
@ 2011-01-24  7:34 Luming Yu
  2011-01-24 18:41 ` Peter Zijlstra
  0 siblings, 1 reply; 13+ messages in thread
From: Luming Yu @ 2011-01-24  7:34 UTC (permalink / raw)
  To: LKML; +Cc: Len Brown

[-- Attachment #1: Type: text/plain, Size: 1653 bytes --]

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@intel.com>

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();

[-- Attachment #2: bz586551-using-default-idle.patch --]
[-- Type: application/octet-stream, Size: 1144 bytes --]

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();

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-01-31 14:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-24  7:34 [PATCH] a patch to fix the cpu-offline-online problem caused by pm_idle Luming Yu
2011-01-24 18:41 ` Peter Zijlstra
2011-01-25  1:59   ` Luming Yu
2011-01-25  9:12     ` Peter Zijlstra
2011-01-26  6:42       ` Luming Yu
2011-01-28 10:30         ` Peter Zijlstra
2011-01-29  5:44           ` Luming Yu
2011-01-30 16:36             ` Peter Zijlstra
2011-01-31  3:26               ` Luming Yu
2011-01-31 10:16                 ` Peter Zijlstra
2011-01-31 14:10                   ` Luming Yu
2011-01-31 14:17                     ` Peter Zijlstra
2011-01-31 10:48                 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox