Skip to contentSkip to conversation

cpuidle: Fix and replace cpu_idle_wait copied code

PATCH In review Thomas Gleixner 2 participants 18 messages May 7, 2012 – May 8, 2012

Subsystems (6)
Arm (32-bit) x86 PowerPC SuperH +2 more subsystems
lore
Share & tools
lore
#0 lore raw

cover cpuidle: Fix and replace cpu_idle_wait copied code

cpu_idle_wait() is available in several identical copies all over arch/ plus a broken variant.

This series fixes the broken one first and then replaces all the identical ones with a generic version.

Thanks,

tglx
----

 arch/arm/Kconfig                     |    3 ---
 arch/arm/include/asm/processor.h     |    2 --
 arch/arm/kernel/process.c            |   20 --------------------
 arch/ia64/include/asm/processor.h    |    1 -
 arch/ia64/kernel/process.c           |   20 --------------------
 arch/powerpc/Kconfig                 |    4 ----
 arch/powerpc/include/asm/processor.h |    1 -
 arch/powerpc/kernel/idle.c           |   23 -----------------------
 arch/sh/Kconfig                      |    3 ---
 arch/sh/include/asm/processor.h      |    1 -
 arch/sh/kernel/idle.c                |   20 --------------------
 arch/x86/Kconfig                     |    3 ---
 arch/x86/include/asm/processor.h     |    2 --
 arch/x86/kernel/apm_32.c             |    2 +-
 arch/x86/kernel/process.c            |   20 --------------------
 drivers/cpuidle/cpuidle.c            |   13 +------------
 include/linux/smp.h                  |    4 ++++
 kernel/smp.c                         |   23 +++++++++++++++++++++++
 18 files changed, 29 insertions(+), 136 deletions(-)
#1 lore raw

PATCH 1/8 powerpc: Fix broken cpu_idle_wait() implementation

commit 771dae818 (powerpc/cpuidle: Add cpu_idle_wait() to allow switching of idle routines) implemented cpu_idle_wait() for powerpc.

The changelog says:
"The equivalent routine for x86 is in arch/x86/kernel/process.c
but the powerpc implementation is different.":

Unfortunately the changelog is completely useless as it does not tell _WHY_ it is different.

Aside of being different the implementation is patently wrong.

The rescheduling IPI is async. That means that there is no guarantee, that the other cores have executed the IPI when cpu_idle_wait() returns. But that's the whole purpose of this function: to guarantee that no CPU uses the old idle handler anymore.

Use the smp_functional_call() based implementation, which fulfils the requirements.

[ This code is going to replaced by a core version to remove all the
pointless copies in arch/*, but this one should go to stable ]

Cc Deepthi Dharwar <[email protected]>
Cc Trinabh Gupta <[email protected]>
Cc Arun R Bharadwaj <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/kernel/idle.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
arch/powerpc/kernel/idle.c +5 -9
Index: tip/arch/powerpc/kernel/idle.c
===================================================================
@@ -113,6 +113,9 @@ void cpu_idle(void)
 	}
 }
 
+static void do_nothing(void *unused)
+{
+}
 
 /*
  * cpu_idle_wait - Used to ensure that all the CPUs come out of the old
@@ -123,16 +126,9 @@ void cpu_idle(void)
  */
 void cpu_idle_wait(void)
 {
-	int cpu;
 	smp_mb();
-
-	/* kick all the CPUs so that they exit out of old idle routine */
-	get_online_cpus();
-	for_each_online_cpu(cpu) {
-		if (cpu != smp_processor_id())
-			smp_send_reschedule(cpu);
-	}
-	put_online_cpus();
+	/* kick all the CPUs so that they exit out of pm_idle */
+	smp_call_function(do_nothing, NULL, 1);
 }
 EXPORT_SYMBOL_GPL(cpu_idle_wait);
 
#2 lore raw

[tip:smp/hotplug] powerpc: Fix broken cpu_idle_wait() implementation

Commit-ID:  9cd75e13de2dcf32ecc21c7f277cff3c0ced059e
Gitweb:     http://git.kernel.org/tip/9cd75e13de2dcf32ecc21c7f277cff3c0ced059e
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 May 2012 17:59:47 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 8 May 2012 12:35:05 +0200

powerpc: Fix broken cpu_idle_wait() implementation

commit 771dae818 (powerpc/cpuidle: Add cpu_idle_wait() to allow switching of idle routines) implemented cpu_idle_wait() for powerpc.

The changelog says:
"The equivalent routine for x86 is in arch/x86/kernel/process.c
but the powerpc implementation is different.":

Unfortunately the changelog is completely useless as it does not tell _WHY_ it is different.

Aside of being different the implementation is patently wrong.

The rescheduling IPI is async. That means that there is no guarantee, that the other cores have executed the IPI when cpu_idle_wait() returns. But that's the whole purpose of this function: to guarantee that no CPU uses the old idle handler anymore.

Use the smp_functional_call() based implementation, which fulfils the requirements.

[ This code is going to replaced by a core version to remove all the
pointless copies in arch/*, but this one should go to stable ]

---
 arch/powerpc/kernel/idle.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)
arch/powerpc/kernel/idle.c +5 -9
index 6d2209a..04d7909 100644
@@ -113,6 +113,9 @@ void cpu_idle(void)
 	}
 }
 
+static void do_nothing(void *unused)
+{
+}
 
 /*
  * cpu_idle_wait - Used to ensure that all the CPUs come out of the old
@@ -123,16 +126,9 @@ void cpu_idle(void)
  */
 void cpu_idle_wait(void)
 {
-	int cpu;
 	smp_mb();
-
-	/* kick all the CPUs so that they exit out of old idle routine */
-	get_online_cpus();
-	for_each_online_cpu(cpu) {
-		if (cpu != smp_processor_id())
-			smp_send_reschedule(cpu);
-	}
-	put_online_cpus();
+	/* kick all the CPUs so that they exit out of pm_idle */
+	smp_call_function(do_nothing, NULL, 1);
 }
 EXPORT_SYMBOL_GPL(cpu_idle_wait);
 
#3 lore raw

PATCH 2/8 smp: Implement kick_all_cpus_sync()

In reply to Thomas Gleixner

Will replace the misnomed cpu_idle_wait() function which is copied a gazillion times all over arch/*

---
 include/linux/smp.h |    4 ++++
 kernel/smp.c        |   23 +++++++++++++++++++++++
 2 files changed, 27 insertions(+)
include/linux/smp.h +4 -0
Index: tip/include/linux/smp.h
===================================================================
@@ -81,6 +81,8 @@ void __smp_call_function_single(int cpui
 int smp_call_function_any(const struct cpumask *mask,
 			  smp_call_func_t func, void *info, int wait);
 
+void kick_all_cpus_sync(void);
+
 /*
  * Generic and arch helpers
  */
@@ -192,6 +194,8 @@ smp_call_function_any(const struct cpuma
 	return smp_call_function_single(0, func, info, wait);
 }
 
+static inline void kick_all_cpus_sync(void) {  }
+
 #endif /* !SMP */
 
 /*
kernel/smp.c +23 -0
Index: tip/kernel/smp.c
===================================================================
@@ -795,3 +795,26 @@ void on_each_cpu_cond(bool (*cond_func)(
 	}
 }
 EXPORT_SYMBOL(on_each_cpu_cond);
+
+static void do_nothing(void *unused)
+{
+}
+
+/**
+ * kick_all_cpus_sync - Force all cpus out of idle
+ *
+ * Used to synchronize the update of pm_idle function pointer. It's
+ * called after the pointer is updated and returns after the dummy
+ * callback function has been executed on all cpus. The execution of
+ * the function can only happen on the remote cpus after they have
+ * left the idle function which had been called via pm_idle function
+ * pointer. So it's guaranteed that nothing uses the previous pointer
+ * anymore.
+ */
+void kick_all_cpus_sync(void)
+{
+	/* Make sure the change is visible before we kick the cpus */
+	smp_mb();
+	smp_call_function(do_nothing, NULL, 1);
+}
+EXPORT_SYMBOL_GPL(kick_all_cpus_sync);
#4 lore raw

[tip:smp/hotplug] smp: Implement kick_all_cpus_sync()

Commit-ID:  f37f435f33717dcf15fd4bb422da739da7fc2052
Gitweb:     http://git.kernel.org/tip/f37f435f33717dcf15fd4bb422da739da7fc2052
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 May 2012 17:59:48 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 8 May 2012 12:35:06 +0200

smp: Implement kick_all_cpus_sync()

Will replace the misnomed cpu_idle_wait() function which is copied a gazillion times all over arch/*

---
 include/linux/smp.h |    4 ++++
 kernel/smp.c        |   23 +++++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
include/linux/smp.h +4 -0
index 24360de..717fb74 100644
@@ -81,6 +81,8 @@ void __smp_call_function_single(int cpuid, struct call_single_data *data,
 int smp_call_function_any(const struct cpumask *mask,
 			  smp_call_func_t func, void *info, int wait);
 
+void kick_all_cpus_sync(void);
+
 /*
  * Generic and arch helpers
  */
@@ -192,6 +194,8 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
 	return smp_call_function_single(0, func, info, wait);
 }
 
+static inline void kick_all_cpus_sync(void) {  }
+
 #endif /* !SMP */
 
 /*
kernel/smp.c +23 -0
index a61294c..d0ae5b2 100644
@@ -795,3 +795,26 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
 	}
 }
 EXPORT_SYMBOL(on_each_cpu_cond);
+
+static void do_nothing(void *unused)
+{
+}
+
+/**
+ * kick_all_cpus_sync - Force all cpus out of idle
+ *
+ * Used to synchronize the update of pm_idle function pointer. It's
+ * called after the pointer is updated and returns after the dummy
+ * callback function has been executed on all cpus. The execution of
+ * the function can only happen on the remote cpus after they have
+ * left the idle function which had been called via pm_idle function
+ * pointer. So it's guaranteed that nothing uses the previous pointer
+ * anymore.
+ */
+void kick_all_cpus_sync(void)
+{
+	/* Make sure the change is visible before we kick the cpus */
+	smp_mb();
+	smp_call_function(do_nothing, NULL, 1);
+}
+EXPORT_SYMBOL_GPL(kick_all_cpus_sync);
#5 lore raw

PATCH 3/8 cpuidle: Use kick_all_cpus_sync()

In reply to Thomas Gleixner

kick_all_cpus_sync() is the core implementation of cpu_idle_wait() which is copied all over the arch code.

---
 drivers/cpuidle/cpuidle.c |   13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/cpuidle/cpuidle.c +1 -12
Index: tip/drivers/cpuidle/cpuidle.c
===================================================================
@@ -40,17 +40,6 @@ void disable_cpuidle(void)
 	off = 1;
 }
 
-#if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT)
-static void cpuidle_kick_cpus(void)
-{
-	cpu_idle_wait();
-}
-#elif defined(CONFIG_SMP)
-# error "Arch needs cpu_idle_wait() equivalent here"
-#else /* !CONFIG_ARCH_HAS_CPU_IDLE_WAIT && !CONFIG_SMP */
-static void cpuidle_kick_cpus(void) {}
-#endif
-
 static int __cpuidle_register_device(struct cpuidle_device *dev);
 
 static inline int cpuidle_enter(struct cpuidle_device *dev,
@@ -186,7 +175,7 @@ void cpuidle_uninstall_idle_handler(void
 {
 	if (enabled_devices) {
 		initialized = 0;
-		cpuidle_kick_cpus();
+		kick_all_cpus_sync();
 	}
 }
 
#6 lore raw

[tip:smp/hotplug] cpuidle: Use kick_all_cpus_sync()

Commit-ID:  4a1625133d4faaefcec0dc175941f49b186918d9
Gitweb:     http://git.kernel.org/tip/4a1625133d4faaefcec0dc175941f49b186918d9
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 May 2012 17:59:48 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 8 May 2012 12:35:06 +0200

cpuidle: Use kick_all_cpus_sync()

kick_all_cpus_sync() is the core implementation of cpu_idle_wait() which is copied all over the arch code.

---
 drivers/cpuidle/cpuidle.c |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)
drivers/cpuidle/cpuidle.c +1 -12
index 2f0083a..d90519c 100644
@@ -40,17 +40,6 @@ void disable_cpuidle(void)
 	off = 1;
 }
 
-#if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT)
-static void cpuidle_kick_cpus(void)
-{
-	cpu_idle_wait();
-}
-#elif defined(CONFIG_SMP)
-# error "Arch needs cpu_idle_wait() equivalent here"
-#else /* !CONFIG_ARCH_HAS_CPU_IDLE_WAIT && !CONFIG_SMP */
-static void cpuidle_kick_cpus(void) {}
-#endif
-
 static int __cpuidle_register_device(struct cpuidle_device *dev);
 
 static inline int cpuidle_enter(struct cpuidle_device *dev,
@@ -186,7 +175,7 @@ void cpuidle_uninstall_idle_handler(void)
 {
 	if (enabled_devices) {
 		initialized = 0;
-		cpuidle_kick_cpus();
+		kick_all_cpus_sync();
 	}
 }
 
#7 lore raw

PATCH 4/8 x86: Use kick_all_cpus_sync()

In reply to Thomas Gleixner

Use kick_all_cpus_sync() and remove cpu_idle_wait().

---
 arch/x86/Kconfig                 |    3 ---
 arch/x86/include/asm/processor.h |    2 --
 arch/x86/kernel/apm_32.c         |    2 +-
 arch/x86/kernel/process.c        |   20 --------------------
 4 files changed, 1 insertion(+), 26 deletions(-)
arch/x86/Kconfig +0 -3
Index: tip/arch/x86/Kconfig
===================================================================
@@ -161,9 +161,6 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
 	def_bool X86_XADD
 
-config ARCH_HAS_CPU_IDLE_WAIT
-	def_bool y
-
 config GENERIC_CALIBRATE_DELAY
 	def_bool y
 
arch/x86/include/asm/processor.h +0 -2
Index: tip/arch/x86/include/asm/processor.h
===================================================================
@@ -974,8 +974,6 @@ extern bool cpu_has_amd_erratum(const in
 #define cpu_has_amd_erratum(x)	(false)
 #endif /* CONFIG_CPU_SUP_AMD */
 
-void cpu_idle_wait(void);
-
 extern unsigned long arch_align_stack(unsigned long sp);
 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
 
arch/x86/kernel/apm_32.c +1 -1
Index: tip/arch/x86/kernel/apm_32.c
===================================================================
@@ -2401,7 +2401,7 @@ static void __exit apm_exit(void)
 		 * (pm_idle), Wait for all processors to update cached/local
 		 * copies of pm_idle before proceeding.
 		 */
-		cpu_idle_wait();
+		kick_all_cpus_sync();
 	}
 	if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0)
 	    && (apm_info.connection_version > 0x0100)) {
arch/x86/kernel/process.c +0 -20
Index: tip/arch/x86/kernel/process.c
===================================================================
@@ -525,26 +525,6 @@ void stop_this_cpu(void *dummy)
 	}
 }
 
-static void do_nothing(void *unused)
-{
-}
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
- * pm_idle and update to new pm_idle value. Required while changing pm_idle
- * handler on SMP systems.
- *
- * Caller must have changed pm_idle to the new value before the call. Old
- * pm_idle value will not be used by any CPU after the return of this function.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
 /* Default MONITOR/MWAIT with no hints, used for default C1 state */
 static void mwait_idle(void)
 {
#8 lore raw

[tip:smp/hotplug] x86: Use kick_all_cpus_sync()

Commit-ID:  85f7f656274fa0ba109dd8774db3887d42de5c6b
Gitweb:     http://git.kernel.org/tip/85f7f656274fa0ba109dd8774db3887d42de5c6b
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 May 2012 17:59:49 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 8 May 2012 12:35:06 +0200

x86: Use kick_all_cpus_sync()

Use kick_all_cpus_sync() and remove cpu_idle_wait().

---
 arch/x86/Kconfig                 |    3 ---
 arch/x86/include/asm/processor.h |    2 --
 arch/x86/kernel/apm_32.c         |    2 +-
 arch/x86/kernel/process.c        |   20 --------------------
 4 files changed, 1 insertions(+), 26 deletions(-)
arch/x86/Kconfig +0 -3
index 046bf4b..98876f5 100644
@@ -161,9 +161,6 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
 	def_bool X86_XADD
 
-config ARCH_HAS_CPU_IDLE_WAIT
-	def_bool y
-
 config GENERIC_CALIBRATE_DELAY
 	def_bool y
 
arch/x86/include/asm/processor.h +0 -2
index 4fa7dcc..ccbb1ea 100644
@@ -974,8 +974,6 @@ extern bool cpu_has_amd_erratum(const int *);
 #define cpu_has_amd_erratum(x)	(false)
 #endif /* CONFIG_CPU_SUP_AMD */
 
-void cpu_idle_wait(void);
-
 extern unsigned long arch_align_stack(unsigned long sp);
 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
 
arch/x86/kernel/apm_32.c +1 -1
index 459e78c..07b0c0d 100644
@@ -2401,7 +2401,7 @@ static void __exit apm_exit(void)
 		 * (pm_idle), Wait for all processors to update cached/local
 		 * copies of pm_idle before proceeding.
 		 */
-		cpu_idle_wait();
+		kick_all_cpus_sync();
 	}
 	if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0)
 	    && (apm_info.connection_version > 0x0100)) {
arch/x86/kernel/process.c +0 -20
index 8aa532f..8215458 100644
@@ -525,26 +525,6 @@ void stop_this_cpu(void *dummy)
 	}
 }
 
-static void do_nothing(void *unused)
-{
-}
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
- * pm_idle and update to new pm_idle value. Required while changing pm_idle
- * handler on SMP systems.
- *
- * Caller must have changed pm_idle to the new value before the call. Old
- * pm_idle value will not be used by any CPU after the return of this function.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
 /* Default MONITOR/MWAIT with no hints, used for default C1 state */
 static void mwait_idle(void)
 {
#9 lore raw

PATCH 5/8 arm: Remove unused cpu_idle_wait()

In reply to Thomas Gleixner

cpuidle uses a generic function now. Remove the unused code.

---
 arch/arm/Kconfig                 |    3 ---
 arch/arm/include/asm/processor.h |    2 --
 arch/arm/kernel/process.c        |   20 --------------------
 3 files changed, 25 deletions(-)
arch/arm/Kconfig +0 -3
Index: tip/arch/arm/Kconfig
===================================================================
@@ -160,9 +160,6 @@ config ARCH_HAS_CPUFREQ
 	  and that the relevant menu configurations are displayed for
 	  it.
 
-config ARCH_HAS_CPU_IDLE_WAIT
-       def_bool y
-
 config GENERIC_HWEIGHT
 	bool
 	default y
arch/arm/include/asm/processor.h +0 -2
Index: tip/arch/arm/include/asm/processor.h
===================================================================
@@ -88,8 +88,6 @@ unsigned long get_wchan(struct task_stru
 #define cpu_relax()			barrier()
 #endif
 
-void cpu_idle_wait(void);
-
 /*
  * Create a new kernel thread
  */
arch/arm/kernel/process.c +0 -20
Index: tip/arch/arm/kernel/process.c
===================================================================
@@ -157,26 +157,6 @@ EXPORT_SYMBOL(pm_power_off);
 void (*arm_pm_restart)(char str, const char *cmd) = null_restart;
 EXPORT_SYMBOL_GPL(arm_pm_restart);
 
-static void do_nothing(void *unused)
-{
-}
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
- * pm_idle and update to new pm_idle value. Required while changing pm_idle
- * handler on SMP systems.
- *
- * Caller must have changed pm_idle to the new value before the call. Old
- * pm_idle value will not be used by any CPU after the return of this function.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
 /*
  * This is our default idle handler.
  */
#10 lore raw

[tip:smp/hotplug] arm: Remove unused cpu_idle_wait()

Commit-ID:  448eca90932d97856b6a6097fc50eef96d77dec0
Gitweb:     http://git.kernel.org/tip/448eca90932d97856b6a6097fc50eef96d77dec0
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 May 2012 17:59:49 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 8 May 2012 12:35:06 +0200

arm: Remove unused cpu_idle_wait()

cpuidle uses a generic function now. Remove the unused code.

---
 arch/arm/Kconfig                 |    3 ---
 arch/arm/include/asm/processor.h |    2 --
 arch/arm/kernel/process.c        |   20 --------------------
 3 files changed, 0 insertions(+), 25 deletions(-)
arch/arm/Kconfig +0 -3
index cb253ce..a3ad496 100644
@@ -160,9 +160,6 @@ config ARCH_HAS_CPUFREQ
 	  and that the relevant menu configurations are displayed for
 	  it.
 
-config ARCH_HAS_CPU_IDLE_WAIT
-       def_bool y
-
 config GENERIC_HWEIGHT
 	bool
 	default y
arch/arm/include/asm/processor.h +0 -2
index 5ac8d3d..d7038fa 100644
@@ -88,8 +88,6 @@ unsigned long get_wchan(struct task_struct *p);
 #define cpu_relax()			barrier()
 #endif
 
-void cpu_idle_wait(void);
-
 /*
  * Create a new kernel thread
  */
arch/arm/kernel/process.c +0 -20
index 2b7b017..19c95ea 100644
@@ -157,26 +157,6 @@ EXPORT_SYMBOL(pm_power_off);
 void (*arm_pm_restart)(char str, const char *cmd) = null_restart;
 EXPORT_SYMBOL_GPL(arm_pm_restart);
 
-static void do_nothing(void *unused)
-{
-}
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
- * pm_idle and update to new pm_idle value. Required while changing pm_idle
- * handler on SMP systems.
- *
- * Caller must have changed pm_idle to the new value before the call. Old
- * pm_idle value will not be used by any CPU after the return of this function.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
 /*
  * This is our default idle handler.
  */
#11 lore raw

PATCH 6/8 powerpc: Remove unused cpu_idle_wait()

In reply to Thomas Gleixner

cpuidle uses a generic function now. Remove the cruft.

Cc Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/Kconfig                 |    4 ----
 arch/powerpc/include/asm/processor.h |    1 -
 arch/powerpc/kernel/idle.c           |   19 -------------------
 3 files changed, 24 deletions(-)
arch/powerpc/Kconfig +0 -4
Index: tip/arch/powerpc/Kconfig
===================================================================
@@ -87,10 +87,6 @@ config ARCH_HAS_ILOG2_U64
 	bool
 	default y if 64BIT
 
-config ARCH_HAS_CPU_IDLE_WAIT
-	bool
-	default y
-
 config GENERIC_HWEIGHT
 	bool
 	default y
arch/powerpc/include/asm/processor.h +0 -1
Index: tip/arch/powerpc/include/asm/processor.h
===================================================================
@@ -386,7 +386,6 @@ extern unsigned long cpuidle_disable;
 enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
 
 extern int powersave_nap;	/* set if nap mode can be used in idle loop */
-void cpu_idle_wait(void);
 
 #ifdef CONFIG_PSERIES_IDLE
 extern void update_smt_snooze_delay(int snooze);
arch/powerpc/kernel/idle.c +0 -19
Index: tip/arch/powerpc/kernel/idle.c
===================================================================
@@ -113,25 +113,6 @@ void cpu_idle(void)
 	}
 }
 
-static void do_nothing(void *unused)
-{
-}
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs come out of the old
- * idle loop and start using the new idle loop.
- * Required while changing idle handler on SMP systems.
- * Caller must have changed idle handler to the new value before the call.
- * This window may be larger on shared systems.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
 int powersave_nap;
 
 #ifdef CONFIG_SYSCTL
#12 lore raw

[tip:smp/hotplug] powerpc: Remove unused cpu_idle_wait()

Commit-ID:  c9b92b840705542a1ae50b5407154a5595d17359
Gitweb:     http://git.kernel.org/tip/c9b92b840705542a1ae50b5407154a5595d17359
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 May 2012 17:59:50 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 8 May 2012 12:35:07 +0200

powerpc: Remove unused cpu_idle_wait()

cpuidle uses a generic function now. Remove the cruft.

---
 arch/powerpc/Kconfig                 |    4 ----
 arch/powerpc/include/asm/processor.h |    1 -
 arch/powerpc/kernel/idle.c           |   19 -------------------
 3 files changed, 0 insertions(+), 24 deletions(-)
arch/powerpc/Kconfig +0 -4
index c815535..296e4f9 100644
@@ -87,10 +87,6 @@ config ARCH_HAS_ILOG2_U64
 	bool
 	default y if 64BIT
 
-config ARCH_HAS_CPU_IDLE_WAIT
-	bool
-	default y
-
 config GENERIC_HWEIGHT
 	bool
 	default y
arch/powerpc/include/asm/processor.h +0 -1
index 8e2d037..48a26d3 100644
@@ -386,7 +386,6 @@ extern unsigned long cpuidle_disable;
 enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
 
 extern int powersave_nap;	/* set if nap mode can be used in idle loop */
-void cpu_idle_wait(void);
 
 #ifdef CONFIG_PSERIES_IDLE
 extern void update_smt_snooze_delay(int snooze);
arch/powerpc/kernel/idle.c +0 -19
index 04d7909..2099d9a 100644
@@ -113,25 +113,6 @@ void cpu_idle(void)
 	}
 }
 
-static void do_nothing(void *unused)
-{
-}
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs come out of the old
- * idle loop and start using the new idle loop.
- * Required while changing idle handler on SMP systems.
- * Caller must have changed idle handler to the new value before the call.
- * This window may be larger on shared systems.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
 int powersave_nap;
 
 #ifdef CONFIG_SYSCTL
#13 lore raw

PATCH 7/8 ia64: Remove unused cpu_idle_wait()

In reply to Thomas Gleixner

IA64 does not set CONFIG_ARCH_HAVE_IDLE_WAIT and cpuidle uses a generic function now. Remove the unused code.

---
 arch/ia64/include/asm/processor.h |    1 -
 arch/ia64/kernel/process.c        |   20 --------------------
 2 files changed, 21 deletions(-)
arch/ia64/include/asm/processor.h +0 -1
Index: tip/arch/ia64/include/asm/processor.h
===================================================================
@@ -723,7 +723,6 @@ extern unsigned long boot_option_idle_ov
 enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT,
 			 IDLE_NOMWAIT, IDLE_POLL};
 
-void cpu_idle_wait(void);
 void default_idle(void);
 
 #define ia64_platform_is(x) (strcmp(x, platform_name) == 0)
arch/ia64/kernel/process.c +0 -20
Index: tip/arch/ia64/kernel/process.c
===================================================================
@@ -273,26 +273,6 @@ static inline void play_dead(void)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
-static void do_nothing(void *unused)
-{
-}
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
- * pm_idle and update to new pm_idle value. Required while changing pm_idle
- * handler on SMP systems.
- *
- * Caller must have changed pm_idle to the new value before the call. Old
- * pm_idle value will not be used by any CPU after the return of this function.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
 void __attribute__((noreturn))
 cpu_idle (void)
 {
#14 lore raw

[tip:smp/hotplug] ia64: Remove unused cpu_idle_wait()

Commit-ID:  bbe78cbd729f85c4da6e04f45c8b2de43c3573f1
Gitweb:     http://git.kernel.org/tip/bbe78cbd729f85c4da6e04f45c8b2de43c3573f1
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 May 2012 17:59:50 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 8 May 2012 12:35:06 +0200

ia64: Remove unused cpu_idle_wait()

IA64 does not set CONFIG_ARCH_HAVE_IDLE_WAIT and cpuidle uses a generic function now. Remove the unused code.

---
 arch/ia64/include/asm/processor.h |    1 -
 arch/ia64/kernel/process.c        |   20 --------------------
 2 files changed, 0 insertions(+), 21 deletions(-)
arch/ia64/include/asm/processor.h +0 -1
index 483f6c6..f92f67a 100644
@@ -723,7 +723,6 @@ extern unsigned long boot_option_idle_override;
 enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT,
 			 IDLE_NOMWAIT, IDLE_POLL};
 
-void cpu_idle_wait(void);
 void default_idle(void);
 
 #define ia64_platform_is(x) (strcmp(x, platform_name) == 0)
arch/ia64/kernel/process.c +0 -20
index ce74e14..5e0e86d 100644
@@ -273,26 +273,6 @@ static inline void play_dead(void)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
-static void do_nothing(void *unused)
-{
-}
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
- * pm_idle and update to new pm_idle value. Required while changing pm_idle
- * handler on SMP systems.
- *
- * Caller must have changed pm_idle to the new value before the call. Old
- * pm_idle value will not be used by any CPU after the return of this function.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
 void __attribute__((noreturn))
 cpu_idle (void)
 {
#15 lore raw

PATCH 8/8 sh: Remove cpu_idle_wait()

In reply to Thomas Gleixner

cpuidle uses the generic kick_all_cpus_sync() now. Remove the unused code.

---
 arch/sh/Kconfig                 |    3 ---
 arch/sh/include/asm/processor.h |    1 -
 arch/sh/kernel/idle.c           |   20 --------------------
 3 files changed, 24 deletions(-)
arch/sh/Kconfig +0 -3
Index: tip/arch/sh/Kconfig
===================================================================
@@ -153,9 +153,6 @@ config ARCH_NO_VIRT_TO_BUS
 config ARCH_HAS_DEFAULT_IDLE
 	def_bool y
 
-config ARCH_HAS_CPU_IDLE_WAIT
-	def_bool y
-
 config NO_IOPORT
 	def_bool !PCI
 	depends on !SH_CAYMAN && !SH_SH4202_MICRODEV && !SH_SHMIN
arch/sh/include/asm/processor.h +0 -1
Index: tip/arch/sh/include/asm/processor.h
===================================================================
@@ -98,7 +98,6 @@ extern struct sh_cpuinfo cpu_data[];
 #define cpu_relax()	barrier()
 
 void default_idle(void);
-void cpu_idle_wait(void);
 void stop_this_cpu(void *);
 
 /* Forward decl */
arch/sh/kernel/idle.c +0 -20
Index: tip/arch/sh/kernel/idle.c
===================================================================
@@ -132,10 +132,6 @@ void __init select_idle_routine(void)
 		pm_idle = poll_idle;
 }
 
-static void do_nothing(void *unused)
-{
-}
-
 void stop_this_cpu(void *unused)
 {
 	local_irq_disable();
@@ -144,19 +140,3 @@ void stop_this_cpu(void *unused)
 	for (;;)
 		cpu_sleep();
 }
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
- * pm_idle and update to new pm_idle value. Required while changing pm_idle
- * handler on SMP systems.
- *
- * Caller must have changed pm_idle to the new value before the call. Old
- * pm_idle value will not be used by any CPU after the return of this function.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
#16 lore raw

[tip:smp/hotplug] sh: Remove cpu_idle_wait()

Commit-ID:  86627c93b35082f7a0e4d3111546943984b932c7
Gitweb:     http://git.kernel.org/tip/86627c93b35082f7a0e4d3111546943984b932c7
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 May 2012 17:59:51 +0000
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 8 May 2012 12:35:07 +0200

sh: Remove cpu_idle_wait()

cpuidle uses generic kick_all_cpus_sync() now. Remove the unused code.

---
 arch/sh/Kconfig                 |    3 ---
 arch/sh/include/asm/processor.h |    1 -
 arch/sh/kernel/idle.c           |   20 --------------------
 3 files changed, 0 insertions(+), 24 deletions(-)
arch/sh/Kconfig +0 -3
index 244cfd0..04a8cb4 100644
@@ -153,9 +153,6 @@ config ARCH_NO_VIRT_TO_BUS
 config ARCH_HAS_DEFAULT_IDLE
 	def_bool y
 
-config ARCH_HAS_CPU_IDLE_WAIT
-	def_bool y
-
 config NO_IOPORT
 	def_bool !PCI
 	depends on !SH_CAYMAN && !SH_SH4202_MICRODEV && !SH_SHMIN
arch/sh/include/asm/processor.h +0 -1
index 6d87912..6dbc1be 100644
@@ -98,7 +98,6 @@ extern struct sh_cpuinfo cpu_data[];
 #define cpu_relax()	barrier()
 
 void default_idle(void);
-void cpu_idle_wait(void);
 void stop_this_cpu(void *);
 
 /* Forward decl */
arch/sh/kernel/idle.c +0 -20
index ee226e2..0c91016 100644
@@ -132,10 +132,6 @@ void __init select_idle_routine(void)
 		pm_idle = poll_idle;
 }
 
-static void do_nothing(void *unused)
-{
-}
-
 void stop_this_cpu(void *unused)
 {
 	local_irq_disable();
@@ -144,19 +140,3 @@ void stop_this_cpu(void *unused)
 	for (;;)
 		cpu_sleep();
 }
-
-/*
- * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
- * pm_idle and update to new pm_idle value. Required while changing pm_idle
- * handler on SMP systems.
- *
- * Caller must have changed pm_idle to the new value before the call. Old
- * pm_idle value will not be used by any CPU after the return of this function.
- */
-void cpu_idle_wait(void)
-{
-	smp_mb();
-	/* kick all the CPUs so that they exit out of pm_idle */
-	smp_call_function(do_nothing, NULL, 1);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);