Re: [RFC][PATCH] Runtime switching to idle_poll (was: Re: 2.6.14-rt13)

From: Ingo Molnar
Date: Sat Nov 26 2005 - 08:22:35 EST



* Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> As a request from Ingo, I fixed up this patch a little to allow both
> x86_64 and i386 to switch to and from idle_poll at runtime. I noticed
> that the APCI driver in drivers/acpi/processor_idle.c may cause some
> race condition with this patch so I added some protection there.
> Basically, if the acpi code changes pm_idle, then you can't change to
> idle_poll, and vice-versa.
>
> What this patch does is creates an entry into
> /sys/kernel/idle/idle_poll. It will show whether or not the idle_poll
> is being used as a runtime idle routine. It is also used to set the
> runtime idle.
>
> with:
>
> # echo 1 > /sys/kernel/idle/idle_poll
> or
> # echo on > /sys/kernel/idle/idle_poll

find some minor cleanups below.

a more general question is, shouldnt the configuration method rather be
something like:

echo idle > /sys/kernel/idle

and there could also be a /sys/kernel/idle_methods which would enumerate
all the strings that are possible? This way we'd not hardcode
'idle-poll' in any way.

Ingo

Signed-off-by: Ingo Molnar <mingo@xxxxxxx>

arch/i386/kernel/process.c | 6 +++---
arch/x86_64/kernel/process.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)

Index: linux/arch/i386/kernel/process.c
===================================================================
--- linux.orig/arch/i386/kernel/process.c
+++ linux/arch/i386/kernel/process.c
@@ -65,11 +65,11 @@ static int hlt_counter;
unsigned long boot_option_idle_override = 0;
EXPORT_SYMBOL(boot_option_idle_override);

-spinlock_t pm_idle_switch_lock = SPIN_LOCK_UNLOCKED;
-EXPORT_SYMBOL(pm_idle_switch_lock);
+DEFINE_SPINLOCK(pm_idle_switch_lock);
+EXPORT_SYMBOL_GPL(pm_idle_switch_lock);

int pm_idle_locked = 0;
-EXPORT_SYMBOL(pm_idle_locked);
+EXPORT_SYMBOL_GPL(pm_idle_locked);

/*
* Return saved PC of a blocked thread.
Index: linux/arch/x86_64/kernel/process.c
===================================================================
--- linux.orig/arch/x86_64/kernel/process.c
+++ linux/arch/x86_64/kernel/process.c
@@ -61,11 +61,11 @@ static atomic_t hlt_counter = ATOMIC_INI
unsigned long boot_option_idle_override = 0;
EXPORT_SYMBOL(boot_option_idle_override);

-spinlock_t pm_idle_switch_lock = SPIN_LOCK_UNLOCKED;
-EXPORT_SYMBOL(pm_idle_switch_lock);
+DEFINE_SPINLOCK(pm_idle_switch_lock);
+EXPORT_SYMBOL_GPL(pm_idle_switch_lock);

int pm_idle_locked = 0;
-EXPORT_SYMBOL(pm_idle_locked);
+EXPORT_SYMBOL_GPL(pm_idle_locked);

/*
* Powermanagement idle function, if any..
-
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/