From: Len Brown <lenb@kernel.org>
To: linux-pm@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Len Brown <len.brown@intel.com>,
x86@kernel.org, Kevin Hilman <khilman@deeprootsystems.com>,
Paul Mundt <lethal@linux-sh.org>
Subject: [PATCH 11/18] cpuidle: stop using pm_idle
Date: Sat, 02 Apr 2011 02:22:53 -0400 [thread overview]
Message-ID: <5f8cf82855ca448698efe66f48779972ad08ffc0.1301724243.git.len.brown@intel.com> (raw)
In-Reply-To: <1301725380-10579-1-git-send-email-lenb@kernel.org>
In-Reply-To: <c82cf78992a66bfa7f0c82aeb20ba6922127463b.1301724243.git.len.brown@intel.com>
From: Len Brown <len.brown@intel.com>
pm_idle does not scale as an idle handler registration mechanism.
Don't use it for cpuidle. Instead, call cpuidle directly, and
allow architectures to use pm_idle as an arch-specific default
if they need it. ie.
cpu_idle()
...
if(cpuidle_call_idle())
pm_idle();
cc: x86@kernel.org
cc: Kevin Hilman <khilman@deeprootsystems.com>
cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Len Brown <len.brown@intel.com>
---
arch/arm/kernel/process.c | 4 +++-
arch/sh/kernel/idle.c | 6 ++++--
arch/x86/kernel/process_32.c | 4 +++-
arch/x86/kernel/process_64.c | 4 +++-
drivers/cpuidle/cpuidle.c | 38 ++++++++++++++++++--------------------
include/linux/cpuidle.h | 2 ++
6 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 94bbedb..dc9d685 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -30,6 +30,7 @@
#include <linux/uaccess.h>
#include <linux/random.h>
#include <linux/hw_breakpoint.h>
+#include <linux/cpuidle.h>
#include <asm/cacheflush.h>
#include <asm/leds.h>
@@ -196,7 +197,8 @@ void cpu_idle(void)
cpu_relax();
} else {
stop_critical_timings();
- pm_idle();
+ if (cpuidle_call_idle())
+ pm_idle();
start_critical_timings();
/*
* This will eventually be removed - pm_idle
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index 425d604..9c7099e 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -16,12 +16,13 @@
#include <linux/thread_info.h>
#include <linux/irqflags.h>
#include <linux/smp.h>
+#include <linux/cpuidle.h>
#include <asm/pgalloc.h>
#include <asm/system.h>
#include <asm/atomic.h>
#include <asm/smp.h>
-void (*pm_idle)(void) = NULL;
+static void (*pm_idle)(void);
static int hlt_counter;
@@ -100,7 +101,8 @@ void cpu_idle(void)
local_irq_disable();
/* Don't trace irqs off for idle */
stop_critical_timings();
- pm_idle();
+ if (cpuidle_call_idle())
+ pm_idle();
/*
* Sanity check to ensure that pm_idle() returns
* with IRQs enabled
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 8d12878..61fadbe 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -38,6 +38,7 @@
#include <linux/uaccess.h>
#include <linux/io.h>
#include <linux/kdebug.h>
+#include <linux/cpuidle.h>
#include <asm/pgtable.h>
#include <asm/system.h>
@@ -109,7 +110,8 @@ void cpu_idle(void)
local_irq_disable();
/* Don't trace irqs off for idle */
stop_critical_timings();
- pm_idle();
+ if (cpuidle_idle_call())
+ pm_idle();
start_critical_timings();
}
tick_nohz_restart_sched_tick();
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index bd387e8..210641a 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -37,6 +37,7 @@
#include <linux/uaccess.h>
#include <linux/io.h>
#include <linux/ftrace.h>
+#include <linux/cpuidle.h>
#include <asm/pgtable.h>
#include <asm/system.h>
@@ -136,7 +137,8 @@ void cpu_idle(void)
enter_idle();
/* Don't trace irqs off for idle */
stop_critical_timings();
- pm_idle();
+ if (cpuidle_idle_call())
+ pm_idle();
start_critical_timings();
/* In many cases the interrupt that ended idle
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 041df0b..d4c5423 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -25,10 +25,10 @@ DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
DEFINE_MUTEX(cpuidle_lock);
LIST_HEAD(cpuidle_detected_devices);
-static void (*pm_idle_old)(void);
static int enabled_devices;
static int off __read_mostly;
+static int initialized __read_mostly;
int cpuidle_disabled(void)
{
@@ -56,25 +56,23 @@ static int __cpuidle_register_device(struct cpuidle_device *dev);
* cpuidle_idle_call - the main idle loop
*
* NOTE: no locks or semaphores should be used here
+ * return non-zero on failure
*/
-static void cpuidle_idle_call(void)
+int cpuidle_idle_call(void)
{
struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
struct cpuidle_state *target_state;
int next_state;
+ if (off)
+ return -ENODEV;
+
+ if (!initialized)
+ return -ENODEV;
+
/* check if the device is ready */
- if (!dev || !dev->enabled) {
- if (pm_idle_old)
- pm_idle_old();
- else
-#if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE)
- default_idle();
-#else
- local_irq_enable();
-#endif
- return;
- }
+ if (!dev || !dev->enabled)
+ return -EBUSY;
#if 0
/* shows regressions, re-enable for 2.6.29 */
@@ -99,7 +97,7 @@ static void cpuidle_idle_call(void)
next_state = cpuidle_curr_governor->select(dev);
if (need_resched()) {
local_irq_enable();
- return;
+ return 0;
}
target_state = &dev->states[next_state];
@@ -124,6 +122,8 @@ static void cpuidle_idle_call(void)
/* give the governor an opportunity to reflect on the outcome */
if (cpuidle_curr_governor->reflect)
cpuidle_curr_governor->reflect(dev);
+
+ return 0;
}
/**
@@ -131,10 +131,10 @@ static void cpuidle_idle_call(void)
*/
void cpuidle_install_idle_handler(void)
{
- if (enabled_devices && (pm_idle != cpuidle_idle_call)) {
+ if (enabled_devices) {
/* Make sure all changes finished before we switch to new idle */
smp_wmb();
- pm_idle = cpuidle_idle_call;
+ initialized = 1;
}
}
@@ -143,8 +143,8 @@ void cpuidle_install_idle_handler(void)
*/
void cpuidle_uninstall_idle_handler(void)
{
- if (enabled_devices && pm_idle_old && (pm_idle != pm_idle_old)) {
- pm_idle = pm_idle_old;
+ if (enabled_devices) {
+ initialized = 0;
cpuidle_kick_cpus();
}
}
@@ -440,8 +440,6 @@ static int __init cpuidle_init(void)
if (cpuidle_disabled())
return -ENODEV;
- pm_idle_old = pm_idle;
-
ret = cpuidle_add_class_sysfs(&cpu_sysdev_class);
if (ret)
return ret;
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index b89f67d..b51629e 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -123,6 +123,7 @@ struct cpuidle_driver {
#ifdef CONFIG_CPU_IDLE
extern void disable_cpuidle(void);
+extern int cpuidle_idle_call(void);
extern int cpuidle_register_driver(struct cpuidle_driver *drv);
struct cpuidle_driver *cpuidle_get_driver(void);
@@ -137,6 +138,7 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);
#else
static inline void disable_cpuidle(void) { }
+static inline int cpuidle_idle_call(void) { return -ENODEV; }
static inline int cpuidle_register_driver(struct cpuidle_driver *drv)
{return -ENODEV; }
--
1.7.5.rc0
next prev parent reply other threads:[~2011-04-02 7:02 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 7:08 [PATCH 0/5] x86 idle cruft removal Len Brown
2011-03-24 7:08 ` [PATCH 1/5] x86 idle: remove "no-hlt" cmdline param Len Brown
2011-03-24 7:08 ` [PATCH 2/5] x86 idle: remove NOP cpuinfo_x86.hlt_works_ok flag Len Brown
2011-03-24 7:08 ` [PATCH 3/5] x86 idle: remove NOP halt_works() Len Brown
2011-03-24 7:08 ` [PATCH 4/5] x86 idle floppy: delete disable_hlt()/enable_hlt() Len Brown
2011-03-24 15:58 ` Andi Kleen
2011-03-24 7:08 ` [PATCH 5/5] x86 idle: remove NOP hlt_use_halt() Len Brown
2011-03-25 19:02 ` [linux-pm] " Vaidyanathan Srinivasan
2011-03-31 6:03 ` [PATCH 0/9] x86 idle cruft removal - v2 Len Brown
2011-03-31 6:03 ` [PATCH 1/9] x86 idle: remove "no-hlt" cmdline param Len Brown
2011-03-31 6:03 ` [PATCH 2/9] x86 idle: remove NOP cpuinfo_x86.hlt_works_ok flag Len Brown
2011-03-31 6:12 ` Ingo Molnar
2011-03-31 7:02 ` Len Brown
2011-03-31 8:18 ` Ingo Molnar
2011-03-31 9:23 ` Alan Cox
2011-03-31 9:27 ` Ingo Molnar
2011-03-31 9:33 ` Alan Cox
2011-03-31 9:35 ` Ingo Molnar
2011-03-31 14:19 ` H. Peter Anvin
2011-03-31 14:41 ` Alan Cox
2011-03-31 15:09 ` H. Peter Anvin
2011-03-31 18:07 ` Len Brown
2011-03-31 18:28 ` H. Peter Anvin
2011-03-31 6:03 ` [PATCH 3/9] x86 idle: remove NOP halt_works() Len Brown
2011-03-31 6:03 ` [PATCH 4/9] x86 idle floppy: delete disable_hlt()/enable_hlt() Len Brown
2011-03-31 6:03 ` [PATCH 5/9] x86 idle: remove NOP hlt_use_halt() Len Brown
2011-03-31 6:03 ` [PATCH 6/9] x86 idle APM: delete apm_cpu_idle(), and its use of (pm_idle)() Len Brown
2011-03-31 6:03 ` [PATCH 7/9] x86 idle: do not EXPORT_SYMBOL pm_idle and default_idle Len Brown
2011-03-31 6:03 ` [PATCH 8/9] x86 idle: move mwait_idle_with_hints() to where it is used Len Brown
2011-03-31 6:03 ` [PATCH 9/9] x86 idle: delete mwait_idle() Len Brown
2011-04-01 11:02 ` Andreas Herrmann
2011-03-31 6:39 ` [linux-pm] [PATCH 0/9] x86 idle cruft removal - v2 Trinabh Gupta
2011-03-31 7:21 ` Len Brown
2011-03-31 9:45 ` Alan Cox
2011-03-31 10:28 ` Ingo Molnar
2011-04-01 4:24 ` Len Brown
2011-04-01 9:38 ` [linux-pm] " Trinabh Gupta
2011-04-01 18:33 ` Len Brown
2011-04-02 6:22 ` idle cleanup - v3 Len Brown
2011-04-02 6:22 ` [PATCH 01/18] cpuidle: menu: fixed wrapping timers at 4.294 seconds Len Brown
2011-04-02 6:22 ` [PATCH 02/18] x86 idle floppy: deprecate disable_hlt() Len Brown
2011-04-02 6:22 ` [PATCH 03/18] x86 idle APM: deprecate CONFIG_APM_CPU_IDLE Len Brown
2011-04-02 11:28 ` Alan Cox
2011-04-02 18:28 ` Len Brown
2011-04-02 19:44 ` Alan Cox
2011-04-08 6:22 ` Pavel Machek
2011-04-02 6:22 ` [PATCH 04/18] x86 idle: EXPORT_SYMBOL(default_idle, pm_idle) only when APM demands it Len Brown
2011-04-02 11:28 ` Alan Cox
2011-04-02 12:21 ` [linux-pm] " Trinabh Gupta
2011-04-02 6:22 ` [PATCH 05/18] x86 idle: deprecate "no-hlt" cmdline param Len Brown
2011-04-02 6:22 ` [PATCH 06/18] x86 idle: deprecate mwait_idle() and "idle=mwait" " Len Brown
2011-04-02 6:22 ` [PATCH 07/18] x86 idle: clarify AMD erratum 400 workaround Len Brown
2011-04-02 8:23 ` Borislav Petkov
2011-04-02 19:19 ` Len Brown
2011-04-02 19:22 ` [PATCH 07/18] x86 idle: clarify AMD erratum 400 workaround -v2 Len Brown
2011-04-03 9:00 ` Borislav Petkov
2011-04-02 6:22 ` [PATCH 08/18] cpuidle: create bootparam "cpuidle.off=1" Len Brown
2011-07-15 11:27 ` [linux-pm] " Deepthi Dharwar
2011-04-02 6:22 ` [PATCH 09/18] cpuidle: replace xen access to x86 pm_idle and default_idle Len Brown
2011-04-04 15:33 ` [Xen-devel] " Konrad Rzeszutek Wilk
2011-04-02 6:22 ` [PATCH 10/18] x86 idle: move mwait_idle_with_hints() to where it is used Len Brown
2011-04-02 6:22 ` Len Brown [this message]
2011-04-25 10:41 ` [linux-pm] [PATCH 11/18] cpuidle: stop using pm_idle Trinabh Gupta
2011-04-02 6:22 ` [PATCH 12/18] 2.6.40: x86 idle: remove deprecated "no-hlt" cmdline param Len Brown
2011-04-02 6:22 ` [PATCH 13/18] 2.6.40: x86 idle: remove deprecated "hlt_bug: no" in 32-bit /proc/cpuinfo Len Brown
2011-04-02 6:22 ` [PATCH 14/18] 2.6.40: x86 idle floppy: remove deprecated disable_hlt()/enable_hlt() Len Brown
2011-04-02 6:22 ` [PATCH 15/18] 2.6.40: x86 idle: remove deprecated hlt_use_halt() Len Brown
2011-04-02 6:22 ` [PATCH 16/18] 2.6.40: x86 idle APM: remove deprecated apm_cpu_idle() Len Brown
2011-04-02 11:40 ` Alan Cox
2011-04-02 19:44 ` Len Brown
2011-04-02 21:00 ` Alan Cox
2011-04-03 2:48 ` [linux-pm] " Trinabh Gupta
2011-04-04 10:05 ` Alan Cox
2011-04-02 6:22 ` [PATCH 17/18] 2.6.40: x86 idle: do not export default_idle() and (pm_idle)() Len Brown
2011-04-02 6:23 ` [PATCH 18/18] 2.6.40: x86 idle: remove deprecated mwait_idle() Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f8cf82855ca448698efe66f48779972ad08ffc0.1301724243.git.len.brown@intel.com \
--to=lenb@kernel.org \
--cc=khilman@deeprootsystems.com \
--cc=len.brown@intel.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®