Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
---
arch/powerpc/Kconfig | 1
arch/powerpc/kernel/idle.c | 78 ++++++++++++---------------------------------
arch/powerpc/kernel/smp.c | 2 -
3 files changed, 24 insertions(+), 57 deletions(-)
Index: linux-2.6/arch/powerpc/Kconfig
===================================================================
--- linux-2.6.orig/arch/powerpc/Kconfig
+++ linux-2.6/arch/powerpc/Kconfig
@@ -133,6 +133,7 @@ config PPC
select HAVE_ARCH_JUMP_LABEL
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select GENERIC_SMP_IDLE_THREAD
+ select GENERIC_IDLE_LOOP
select GENERIC_CMOS_UPDATE
select GENERIC_TIME_VSYSCALL_OLD
select GENERIC_CLOCKEVENTS
Index: linux-2.6/arch/powerpc/kernel/idle.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/idle.c
+++ linux-2.6/arch/powerpc/kernel/idle.c
@@ -50,64 +50,30 @@ static int __init powersave_off(char *ar
}
__setup("powersave=off", powersave_off);
-/*
- * The body of the idle task.
- */
-void cpu_idle(void)
+void arch_cpu_idle(void)
{
- set_thread_flag(TIF_POLLING_NRFLAG);
- while (1) {
- tick_nohz_idle_enter();
- rcu_idle_enter();
-
- while (!need_resched() && !cpu_should_die()) {
- ppc64_runlatch_off();
-
- if (ppc_md.power_save) {
- clear_thread_flag(TIF_POLLING_NRFLAG);
- /*
- * smp_mb is so clearing of TIF_POLLING_NRFLAG
- * is ordered w.r.t. need_resched() test.
- */
- smp_mb();
- local_irq_disable();
-
- /* Don't trace irqs off for idle */
- stop_critical_timings();
-
- /* check again after disabling irqs */
- if (!need_resched() && !cpu_should_die())
- ppc_md.power_save();
-
- start_critical_timings();
-
- /* Some power_save functions return with
- * interrupts enabled, some don't.
- */
- if (irqs_disabled())
- local_irq_enable();
- set_thread_flag(TIF_POLLING_NRFLAG);
-
- } else {
- /*
- * Go into low thread priority and possibly
- * low power mode.
- */
- HMT_low();
- HMT_very_low();
- }
- }
-
- HMT_medium();
- ppc64_runlatch_on();
- rcu_idle_exit();
- tick_nohz_idle_exit();
- if (cpu_should_die()) {
- sched_preempt_enable_no_resched();
- cpu_die();
- }
- schedule_preempt_disabled();
+ ppc64_runlatch_off();
+
+ if (ppc_md.power_save) {
+ ppc_md.power_save();
+ /*
+ * Some power_save functions return with
+ * interrupts enabled, some don't.
+ */
+ if (irqs_disabled())
+ local_irq_enable();
+ } else {
+ local_irq_enable();
+ /*
+ * Go into low thread priority and possibly
+ * low power mode.
+ */
+ HMT_low();
+ HMT_very_low();
}
+
+ HMT_medium();
+ ppc64_runlatch_on();
}
int powersave_nap;
Index: linux-2.6/arch/powerpc/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/smp.c
+++ linux-2.6/arch/powerpc/kernel/smp.c
@@ -669,7 +669,7 @@ __cpuinit void start_secondary(void *unu
local_irq_enable();
- cpu_idle();
+ cpu_startup_entry(CPUHP_ONLINE);
BUG();
}
On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: Benjamin Herrenschmidt <[email protected]>
> ---
[...]
> Index: linux-2.6/arch/powerpc/kernel/idle.c
> ===================================================================
> --- linux-2.6.orig/arch/powerpc/kernel/idle.c
> +++ linux-2.6/arch/powerpc/kernel/idle.c
> @@ -50,64 +50,30 @@ static int __init powersave_off(char *ar
> }
> __setup("powersave=off", powersave_off);
>
> -/*
> - * The body of the idle task.
> - */
> -void cpu_idle(void)
> +void arch_cpu_idle(void)
> {
> - set_thread_flag(TIF_POLLING_NRFLAG);
> - while (1) {
> - tick_nohz_idle_enter();
> - rcu_idle_enter();
> -
> - while (!need_resched() && !cpu_should_die()) {
> - ppc64_runlatch_off();
> -
> - if (ppc_md.power_save) {
> - clear_thread_flag(TIF_POLLING_NRFLAG);
> - /*
> - * smp_mb is so clearing of TIF_POLLING_NRFLAG
> - * is ordered w.r.t. need_resched() test.
> - */
> - smp_mb();
> - local_irq_disable();
> -
> - /* Don't trace irqs off for idle */
> - stop_critical_timings();
> -
> - /* check again after disabling irqs */
> - if (!need_resched() && !cpu_should_die())
> - ppc_md.power_save();
> -
> - start_critical_timings();
> -
> - /* Some power_save functions return with
> - * interrupts enabled, some don't.
> - */
> - if (irqs_disabled())
> - local_irq_enable();
> - set_thread_flag(TIF_POLLING_NRFLAG);
> -
> - } else {
> - /*
> - * Go into low thread priority and possibly
> - * low power mode.
> - */
> - HMT_low();
> - HMT_very_low();
> - }
> - }
> -
> - HMT_medium();
> - ppc64_runlatch_on();
> - rcu_idle_exit();
> - tick_nohz_idle_exit();
> - if (cpu_should_die()) {
> - sched_preempt_enable_no_resched();
> - cpu_die();
> - }
> - schedule_preempt_disabled();
> + ppc64_runlatch_off();
> +
> + if (ppc_md.power_save) {
> + ppc_md.power_save();
> + /*
> + * Some power_save functions return with
> + * interrupts enabled, some don't.
> + */
> + if (irqs_disabled())
> + local_irq_enable();
> + } else {
> + local_irq_enable();
> + /*
> + * Go into low thread priority and possibly
> + * low power mode.
> + */
> + HMT_low();
> + HMT_very_low();
> }
> +
> + HMT_medium();
> + ppc64_runlatch_on();
> }
>
The call to cpu_die() seems to be missing. And considering this commit,
commit a7c2bb8279d20d853e43c34584eaf2b039de8026
Author: Signed-off-by: Darren Hart <[email protected]>
Date: Wed Aug 4 18:28:33 2010 +0000
powerpc: Re-enable preemption before cpu_die()
we need to call it with preempt enabled. So how about folding the
following diff with this patch?
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index b751baa..e434fb9 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -33,11 +33,6 @@
#include <asm/runlatch.h>
#include <asm/smp.h>
-#ifdef CONFIG_HOTPLUG_CPU
-#define cpu_should_die() cpu_is_offline(smp_processor_id())
-#else
-#define cpu_should_die() 0
-#endif
unsigned long cpuidle_disable = IDLE_NO_OVERRIDE;
EXPORT_SYMBOL(cpuidle_disable);
@@ -50,6 +45,12 @@ static int __init powersave_off(char *arg)
}
__setup("powersave=off", powersave_off);
+void arch_cpu_idle_dead(void)
+{
+ sched_preempt_enable_no_resched();
+ cpu_die();
+}
+
void arch_cpu_idle(void)
{
ppc64_runlatch_off();
Regards,
Srivatsa S. Bhat
On 03/28/2013 09:10 PM, Srivatsa S. Bhat wrote:
> On 03/22/2013 03:23 AM, Thomas Gleixner wrote:
>> Signed-off-by: Thomas Gleixner <[email protected]>
>> Cc: Benjamin Herrenschmidt <[email protected]>
>> ---
> [...]
>> Index: linux-2.6/arch/powerpc/kernel/idle.c
>> ===================================================================
>> --- linux-2.6.orig/arch/powerpc/kernel/idle.c
>> +++ linux-2.6/arch/powerpc/kernel/idle.c
>> @@ -50,64 +50,30 @@ static int __init powersave_off(char *ar
>> }
>> __setup("powersave=off", powersave_off);
>>
>> -/*
>> - * The body of the idle task.
>> - */
>> -void cpu_idle(void)
>> +void arch_cpu_idle(void)
>> {
>> - set_thread_flag(TIF_POLLING_NRFLAG);
>> - while (1) {
>> - tick_nohz_idle_enter();
>> - rcu_idle_enter();
>> -
>> - while (!need_resched() && !cpu_should_die()) {
>> - ppc64_runlatch_off();
>> -
>> - if (ppc_md.power_save) {
>> - clear_thread_flag(TIF_POLLING_NRFLAG);
>> - /*
>> - * smp_mb is so clearing of TIF_POLLING_NRFLAG
>> - * is ordered w.r.t. need_resched() test.
>> - */
>> - smp_mb();
>> - local_irq_disable();
>> -
>> - /* Don't trace irqs off for idle */
>> - stop_critical_timings();
>> -
>> - /* check again after disabling irqs */
>> - if (!need_resched() && !cpu_should_die())
>> - ppc_md.power_save();
>> -
>> - start_critical_timings();
>> -
>> - /* Some power_save functions return with
>> - * interrupts enabled, some don't.
>> - */
>> - if (irqs_disabled())
>> - local_irq_enable();
>> - set_thread_flag(TIF_POLLING_NRFLAG);
>> -
>> - } else {
>> - /*
>> - * Go into low thread priority and possibly
>> - * low power mode.
>> - */
>> - HMT_low();
>> - HMT_very_low();
>> - }
>> - }
>> -
>> - HMT_medium();
>> - ppc64_runlatch_on();
>> - rcu_idle_exit();
>> - tick_nohz_idle_exit();
>> - if (cpu_should_die()) {
>> - sched_preempt_enable_no_resched();
>> - cpu_die();
>> - }
>> - schedule_preempt_disabled();
>> + ppc64_runlatch_off();
>> +
>> + if (ppc_md.power_save) {
>> + ppc_md.power_save();
>> + /*
>> + * Some power_save functions return with
>> + * interrupts enabled, some don't.
>> + */
>> + if (irqs_disabled())
>> + local_irq_enable();
>> + } else {
>> + local_irq_enable();
>> + /*
>> + * Go into low thread priority and possibly
>> + * low power mode.
>> + */
>> + HMT_low();
>> + HMT_very_low();
>> }
>> +
>> + HMT_medium();
>> + ppc64_runlatch_on();
>> }
>>
The below patch is essential to get hotplug working on POWER.
With that, generic idle loop works fine for PSERIES.
Tested-by: Deepthi Dharwar <[email protected]>
>
> The call to cpu_die() seems to be missing. And considering this commit,
>
> commit a7c2bb8279d20d853e43c34584eaf2b039de8026
> Author: Signed-off-by: Darren Hart <[email protected]>
> Date: Wed Aug 4 18:28:33 2010 +0000
>
> powerpc: Re-enable preemption before cpu_die()
>
> we need to call it with preempt enabled. So how about folding the
> following diff with this patch?
>
>
> diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
> index b751baa..e434fb9 100644
> --- a/arch/powerpc/kernel/idle.c
> +++ b/arch/powerpc/kernel/idle.c
> @@ -33,11 +33,6 @@
> #include <asm/runlatch.h>
> #include <asm/smp.h>
>
> -#ifdef CONFIG_HOTPLUG_CPU
> -#define cpu_should_die() cpu_is_offline(smp_processor_id())
> -#else
> -#define cpu_should_die() 0
> -#endif
>
> unsigned long cpuidle_disable = IDLE_NO_OVERRIDE;
> EXPORT_SYMBOL(cpuidle_disable);
> @@ -50,6 +45,12 @@ static int __init powersave_off(char *arg)
> }
> __setup("powersave=off", powersave_off);
>
> +void arch_cpu_idle_dead(void)
> +{
> + sched_preempt_enable_no_resched();
> + cpu_die();
> +}
> +
> void arch_cpu_idle(void)
> {
> ppc64_runlatch_off();
>
>
> Regards,
> Srivatsa S. Bhat
>
Commit-ID: 799fef06123f86ff69cf754f996219e6ad1678f8
Gitweb: http://git.kernel.org/tip/799fef06123f86ff69cf754f996219e6ad1678f8
Author: Thomas Gleixner <[email protected]>
AuthorDate: Thu, 21 Mar 2013 22:49:56 +0100
Committer: Thomas Gleixner <[email protected]>
CommitDate: Mon, 8 Apr 2013 17:39:27 +0200
powerpc: Use generic idle loop
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Rusty Russell <[email protected]>
Cc: Paul McKenney <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Reviewed-by: Cc: Srivatsa S. Bhat <[email protected]>
Cc: Magnus Damm <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/idle.c | 89 +++++++++++++++-------------------------------
arch/powerpc/kernel/smp.c | 2 +-
3 files changed, 31 insertions(+), 61 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ea5bb04..19de32c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -133,6 +133,7 @@ config PPC
select HAVE_ARCH_JUMP_LABEL
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select GENERIC_SMP_IDLE_THREAD
+ select GENERIC_IDLE_LOOP
select GENERIC_CMOS_UPDATE
select GENERIC_TIME_VSYSCALL_OLD
select GENERIC_CLOCKEVENTS
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index ea78761..939ea7e 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -33,11 +33,6 @@
#include <asm/runlatch.h>
#include <asm/smp.h>
-#ifdef CONFIG_HOTPLUG_CPU
-#define cpu_should_die() cpu_is_offline(smp_processor_id())
-#else
-#define cpu_should_die() 0
-#endif
unsigned long cpuidle_disable = IDLE_NO_OVERRIDE;
EXPORT_SYMBOL(cpuidle_disable);
@@ -50,64 +45,38 @@ static int __init powersave_off(char *arg)
}
__setup("powersave=off", powersave_off);
-/*
- * The body of the idle task.
- */
-void cpu_idle(void)
+#ifdef CONFIG_HOTPLUG_CPU
+void arch_cpu_idle_dead(void)
{
- set_thread_flag(TIF_POLLING_NRFLAG);
- while (1) {
- tick_nohz_idle_enter();
- rcu_idle_enter();
-
- while (!need_resched() && !cpu_should_die()) {
- ppc64_runlatch_off();
-
- if (ppc_md.power_save) {
- clear_thread_flag(TIF_POLLING_NRFLAG);
- /*
- * smp_mb is so clearing of TIF_POLLING_NRFLAG
- * is ordered w.r.t. need_resched() test.
- */
- smp_mb();
- local_irq_disable();
-
- /* Don't trace irqs off for idle */
- stop_critical_timings();
-
- /* check again after disabling irqs */
- if (!need_resched() && !cpu_should_die())
- ppc_md.power_save();
-
- start_critical_timings();
-
- /* Some power_save functions return with
- * interrupts enabled, some don't.
- */
- if (irqs_disabled())
- local_irq_enable();
- set_thread_flag(TIF_POLLING_NRFLAG);
-
- } else {
- /*
- * Go into low thread priority and possibly
- * low power mode.
- */
- HMT_low();
- HMT_very_low();
- }
- }
+ sched_preempt_enable_no_resched();
+ cpu_die();
+}
+#endif
- HMT_medium();
- ppc64_runlatch_on();
- rcu_idle_exit();
- tick_nohz_idle_exit();
- if (cpu_should_die()) {
- sched_preempt_enable_no_resched();
- cpu_die();
- }
- schedule_preempt_disabled();
+void arch_cpu_idle(void)
+{
+ ppc64_runlatch_off();
+
+ if (ppc_md.power_save) {
+ ppc_md.power_save();
+ /*
+ * Some power_save functions return with
+ * interrupts enabled, some don't.
+ */
+ if (irqs_disabled())
+ local_irq_enable();
+ } else {
+ local_irq_enable();
+ /*
+ * Go into low thread priority and possibly
+ * low power mode.
+ */
+ HMT_low();
+ HMT_very_low();
}
+
+ HMT_medium();
+ ppc64_runlatch_on();
}
int powersave_nap;
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 76bd9da..ee7ac5e 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -669,7 +669,7 @@ __cpuinit void start_secondary(void *unused)
local_irq_enable();
- cpu_idle();
+ cpu_startup_entry(CPUHP_ONLINE);
BUG();
}