2013-03-21 21:59:50

by Thomas Gleixner

[permalink] [raw]
Subject: [patch 13/34] cris: Use generic idle loop

Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Jesper Nilsson <[email protected]>
---
arch/cris/Kconfig | 1 +
arch/cris/arch-v10/kernel/process.c | 3 ++-
arch/cris/arch-v32/kernel/process.c | 10 ++++------
arch/cris/arch-v32/kernel/smp.c | 4 +---
arch/cris/kernel/process.c | 24 ++----------------------
5 files changed, 10 insertions(+), 32 deletions(-)

Index: linux-2.6/arch/cris/Kconfig
===================================================================
--- linux-2.6.orig/arch/cris/Kconfig
+++ linux-2.6/arch/cris/Kconfig
@@ -48,6 +48,7 @@ config CRIS
select GENERIC_IRQ_SHOW
select GENERIC_IOMAP
select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32
+ select GENERIC_IDLE_LOOP
select GENERIC_CMOS_UPDATE
select MODULES_USE_ELF_RELA
select CLONE_BACKWARDS2
Index: linux-2.6/arch/cris/arch-v10/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/cris/arch-v10/kernel/process.c
+++ linux-2.6/arch/cris/arch-v10/kernel/process.c
@@ -30,8 +30,9 @@ void etrax_gpio_wake_up_check(void); /*
void default_idle(void)
{
#ifdef CONFIG_ETRAX_GPIO
- etrax_gpio_wake_up_check();
+ etrax_gpio_wake_up_check();
#endif
+ local_irq_enable();
}

/*
Index: linux-2.6/arch/cris/arch-v32/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/cris/arch-v32/kernel/process.c
+++ linux-2.6/arch/cris/arch-v32/kernel/process.c
@@ -23,12 +23,10 @@ extern void stop_watchdog(void);
/* We use this if we don't have any better idle routine. */
void default_idle(void)
{
- local_irq_disable();
- if (!need_resched()) {
- /* Halt until exception. */
- __asm__ volatile("ei \n\t"
- "halt ");
- }
+ /* Halt until exception. */
+ __asm__ volatile("ei \n\t"
+ "halt ");
+ /* CHECKME: Is this really needed ?? */
local_irq_enable();
}

Index: linux-2.6/arch/cris/arch-v32/kernel/smp.c
===================================================================
--- linux-2.6.orig/arch/cris/arch-v32/kernel/smp.c
+++ linux-2.6/arch/cris/arch-v32/kernel/smp.c
@@ -145,8 +145,6 @@ smp_boot_one_cpu(int cpuid, struct task_
* specific stuff such as the local timer and the MMU. */
void __init smp_callin(void)
{
- extern void cpu_idle(void);
-
int cpu = cpu_now_booting;
reg_intr_vect_rw_mask vect_mask = {0};

@@ -170,7 +168,7 @@ void __init smp_callin(void)
local_irq_enable();

set_cpu_online(cpu, true);
- cpu_idle();
+ cpu_startup_entry(CPUHP_ONLINE);
}

/* Stop execution on this CPU.*/
Index: linux-2.6/arch/cris/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/cris/kernel/process.c
+++ linux-2.6/arch/cris/kernel/process.c
@@ -34,29 +34,9 @@ extern void default_idle(void);
void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);

-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-
-void cpu_idle (void)
+void arch_cpu_idle(void)
{
- /* endless idle loop with no priority at all */
- while (1) {
- rcu_idle_enter();
- while (!need_resched()) {
- /*
- * Mark this as an RCU critical section so that
- * synchronize_kernel() in the unload path waits
- * for our completion.
- */
- default_idle();
- }
- rcu_idle_exit();
- schedule_preempt_disabled();
- }
+ default_idle();
}

void hard_reset_now (void);


2013-03-27 15:14:52

by Jesper Nilsson

[permalink] [raw]
Subject: Re: [patch 13/34] cris: Use generic idle loop


On Thu, Mar 21, 2013 at 09:53:06PM -0000, Thomas Gleixner wrote:
[snip]
> Index: linux-2.6/arch/cris/arch-v32/kernel/process.c
> ===================================================================
> --- linux-2.6.orig/arch/cris/arch-v32/kernel/process.c
> +++ linux-2.6/arch/cris/arch-v32/kernel/process.c
> @@ -23,12 +23,10 @@ extern void stop_watchdog(void);
> /* We use this if we don't have any better idle routine. */
> void default_idle(void)
> {
> - local_irq_disable();
> - if (!need_resched()) {
> - /* Halt until exception. */
> - __asm__ volatile("ei \n\t"
> - "halt ");
> - }
> + /* Halt until exception. */
> + __asm__ volatile("ei \n\t"
> + "halt ");
> + /* CHECKME: Is this really needed ?? */
> local_irq_enable();

No, that local_irq_enable() is redundant since we already enabled interrupts
in the assembler directive above.

> }

Looks good,

Acked-by: Jesper Nilsson <[email protected]>

/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]

2013-03-27 17:10:24

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [patch 13/34] cris: Use generic idle loop

On Wed, 27 Mar 2013, Jesper Nilsson wrote:
>
> On Thu, Mar 21, 2013 at 09:53:06PM -0000, Thomas Gleixner wrote:
> [snip]
> > Index: linux-2.6/arch/cris/arch-v32/kernel/process.c
> > ===================================================================
> > --- linux-2.6.orig/arch/cris/arch-v32/kernel/process.c
> > +++ linux-2.6/arch/cris/arch-v32/kernel/process.c
> > @@ -23,12 +23,10 @@ extern void stop_watchdog(void);
> > /* We use this if we don't have any better idle routine. */
> > void default_idle(void)
> > {
> > - local_irq_disable();
> > - if (!need_resched()) {
> > - /* Halt until exception. */
> > - __asm__ volatile("ei \n\t"
> > - "halt ");
> > - }
> > + /* Halt until exception. */
> > + __asm__ volatile("ei \n\t"
> > + "halt ");
> > + /* CHECKME: Is this really needed ?? */
> > local_irq_enable();
>
> No, that local_irq_enable() is redundant since we already enabled interrupts
> in the assembler directive above.

That's what I thought:) Will remove it.

Thanks,

tglx

Subject: [tip:smp/hotplug] cris: Use generic idle loop

Commit-ID: 8dc7c5ecd8d0f739728d844ee794c4fae169f9c2
Gitweb: http://git.kernel.org/tip/8dc7c5ecd8d0f739728d844ee794c4fae169f9c2
Author: Thomas Gleixner <[email protected]>
AuthorDate: Thu, 21 Mar 2013 22:49:43 +0100
Committer: Thomas Gleixner <[email protected]>
CommitDate: Mon, 8 Apr 2013 17:39:25 +0200

cris: 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]>
Acked-by: Jesper Nilsson <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>

---
arch/cris/Kconfig | 1 +
arch/cris/arch-v10/kernel/process.c | 3 ++-
arch/cris/arch-v32/kernel/process.c | 10 +++-------
arch/cris/arch-v32/kernel/smp.c | 4 +---
arch/cris/kernel/process.c | 24 ++----------------------
5 files changed, 9 insertions(+), 33 deletions(-)

diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 06dd026..1dd3635 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -48,6 +48,7 @@ config CRIS
select GENERIC_IRQ_SHOW
select GENERIC_IOMAP
select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32
+ select GENERIC_IDLE_LOOP
select GENERIC_CMOS_UPDATE
select MODULES_USE_ELF_RELA
select CLONE_BACKWARDS2
diff --git a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c
index b101875..2ba23c1 100644
--- a/arch/cris/arch-v10/kernel/process.c
+++ b/arch/cris/arch-v10/kernel/process.c
@@ -30,8 +30,9 @@ void etrax_gpio_wake_up_check(void); /* drivers/gpio.c */
void default_idle(void)
{
#ifdef CONFIG_ETRAX_GPIO
- etrax_gpio_wake_up_check();
+ etrax_gpio_wake_up_check();
#endif
+ local_irq_enable();
}

/*
diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c
index 4857933..57451fa 100644
--- a/arch/cris/arch-v32/kernel/process.c
+++ b/arch/cris/arch-v32/kernel/process.c
@@ -23,13 +23,9 @@ extern void stop_watchdog(void);
/* We use this if we don't have any better idle routine. */
void default_idle(void)
{
- local_irq_disable();
- if (!need_resched()) {
- /* Halt until exception. */
- __asm__ volatile("ei \n\t"
- "halt ");
- }
- local_irq_enable();
+ /* Halt until exception. */
+ __asm__ volatile("ei \n\t"
+ "halt ");
}

/*
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 04a16ed..cdd1202 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -145,8 +145,6 @@ smp_boot_one_cpu(int cpuid, struct task_struct idle)
* specific stuff such as the local timer and the MMU. */
void __init smp_callin(void)
{
- extern void cpu_idle(void);
-
int cpu = cpu_now_booting;
reg_intr_vect_rw_mask vect_mask = {0};

@@ -170,7 +168,7 @@ void __init smp_callin(void)
local_irq_enable();

set_cpu_online(cpu, true);
- cpu_idle();
+ cpu_startup_entry(CPUHP_ONLINE);
}

/* Stop execution on this CPU.*/
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 508c9cd..b78498e 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -34,29 +34,9 @@ extern void default_idle(void);
void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);

-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-
-void cpu_idle (void)
+void arch_cpu_idle(void)
{
- /* endless idle loop with no priority at all */
- while (1) {
- rcu_idle_enter();
- while (!need_resched()) {
- /*
- * Mark this as an RCU critical section so that
- * synchronize_kernel() in the unload path waits
- * for our completion.
- */
- default_idle();
- }
- rcu_idle_exit();
- schedule_preempt_disabled();
- }
+ default_idle();
}

void hard_reset_now (void);