pm_idle, default_idle cleanup
Subsystems (11)
Len Brown
reviewercover pm_idle, default_idle cleanup
The 1st three patches in this series are specific to x86. With an ack from the x86 crew (the main patch still has Ingo's ack from 16 months ago) I think they could be 3.6-rc1 cleanup candidates.
The 4th patch is enabled by the first 3 -- removing pm_idle() from pm.h touches 10 architectures. That one will need a bunch of acks and post rc1 linux-next build testing to make sure it doesn't break 3.7.
thanks,
Len Brown, Intel Open Source Technology Center
Len Brown
reviewerPATCH 1/4 Revert "x86 idle APM: deprecate CONFIG_APM_CPU_IDLE" to prepare for actual removal
From: Len Brown <[email protected]>
Remove warning that perplex users about removal of CONFIG_APM_CPU_IDLE in 2012. This allows applying the original removal patch cleanly.
In retrospect, adding this warning was a mistake. We should have shipped the removal patch 16 months ago.
--- Documentation/feature-removal-schedule.txt | 10 ++++++++++ arch/x86/kernel/apm_32.c | 2 ++ 2 files changed, 12 insertions(+)
Documentation/feature-removal-schedule.txt +10 -0
@@ -14,6 +14,16 @@ Who: Len Brown <[email protected]> --------------------------- +What: CONFIG_APM_CPU_IDLE, and its ability to call APM BIOS in idle +When: 2012 +Why: This optional sub-feature of APM is of dubious reliability, + and ancient APM laptops are likely better served by calling HLT. + Deleting CONFIG_APM_CPU_IDLE allows x86 to stop exporting + the pm_idle function pointer to modules. +Who: Len Brown <[email protected]> + +---------------------------- + What: x86_32 "no-hlt" cmdline param When: 2012
arch/x86/kernel/apm_32.c +2 -0
@@ -359,6 +359,7 @@ struct apm_user {* idle percentage above which bios idle calls are done */ #ifdef CONFIG_APM_CPU_IDLE +#warning deprecated CONFIG_APM_CPU_IDLE will be deleted in 2012#define DEFAULT_IDLE_THRESHOLD 95#else #define DEFAULT_IDLE_THRESHOLD 100
@@ -902,6 +903,7 @@ static void apm_cpu_idle(void)unsigned int jiffies_since_last_check = jiffies - last_jiffies;unsigned int bucket; +WARN_ONCE (1 ,"deprecated apm_cpu_idle will be deleted in 2012" ); recalc:if (jiffies_since_last_check >IDLE_CALC_LIMIT ) { use_apm_idle =0 ;
--
1.7.12.rc0
--- Documentation/feature-removal-schedule.txt | 10 ---------- arch/x86/kernel/apm_32.c | 2 -- 2 files changed, 12 deletions(-)
Documentation/feature-removal-schedule.txt +0 -10
@@ -13,16 +13,6 @@ Who: Jim Cromie <[email protected]>, Jason Baron <[email protected]> --------------------------- -What: CONFIG_APM_CPU_IDLE, and its ability to call APM BIOS in idle -When: 2012 -Why: This optional sub-feature of APM is of dubious reliability, - and ancient APM laptops are likely better served by calling HLT. - Deleting CONFIG_APM_CPU_IDLE allows x86 to stop exporting - the pm_idle function pointer to modules. -Who: Len Brown <[email protected]> - ----------------------------- - What: x86_32 "no-hlt" cmdline param When: 2012 Why: remove a branch from idle path, simplify code used by everybody.
arch/x86/kernel/apm_32.c +0 -2
@@ -358,7 +358,6 @@ struct apm_user {* idle percentage above which bios idle calls are done */ #ifdef CONFIG_APM_CPU_IDLE -#warning deprecated CONFIG_APM_CPU_IDLE will be deleted in 2012#define DEFAULT_IDLE_THRESHOLD 95#else #define DEFAULT_IDLE_THRESHOLD 100
@@ -902,7 +901,6 @@ static void apm_cpu_idle(void)unsigned int jiffies_since_last_check = jiffies - last_jiffies;unsigned int bucket; -WARN_ONCE (1 ,"deprecated apm_cpu_idle will be deleted in 2012" ); recalc:if (jiffies_since_last_check >IDLE_CALC_LIMIT ) { use_apm_idle =0 ;
Signature · 1 line
1.7.12.rc0
Len Brown
reviewerPATCH 2/4 x86 idle APM: delete apm_cpu_idle()
In reply to Len BrownFrom: Len Brown <[email protected]>
The APM idle feature to call into the BIOS
is known to break some machines, and it has dubious benefit on the (decades old) machines it doesn't break.
After this patch, systems running in APM mode will simply run default_idle() and HALT, rather than calling into the BIOS from their idle loop.
This also deletes the last modular use use of (pm_idle)() and default_idle().
--- arch/x86/Kconfig | 11 --- arch/x86/kernel/apm_32.c | 232 ----------------------------------------------- 2 files changed, 243 deletions(-)
arch/x86/Kconfig +0 -11
@@ -1847,17 +1847,6 @@ config APM_DO_ENABLE T400CDT. This is off by default since most machines do fine without this feature. -config APM_CPU_IDLE - bool "Make CPU Idle calls when idle" - ---help--- - Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop. - On some machines, this can activate improved power savings, such as - a slowed CPU clock rate, when the machine is idle. These idle calls - are made after the idle loop has run for some length of time (e.g., - 333 mS). On some machines, this will cause a hang at boot time or - whenever the CPU becomes idle. (On machines with more than one CPU, - this option does nothing.) - config APM_DISPLAY_BLANK bool "Enable console blanking using APM" ---help---
arch/x86/kernel/apm_32.c +0 -232
304 lines not on this page · raw message
Signature · 1 line
1.7.12.rc0
Len Brown
reviewerPATCH 3/4 x86, idle: make default_idle() static
In reply to Len BrownFrom: Len Brown <[email protected]>
default_idle() was public and exported to modules for the benefit of APM. But APM no longer touches default_idle(), so default_idle() can now be private.
--- arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/process.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-)
arch/x86/include/asm/processor.h +0 -1
@@ -979,7 +979,6 @@ extern bool cpu_has_amd_erratum(const int *);extern unsigned long arch_align_stack (unsigned long sp);extern void free_init_pages (char *what,unsigned long begin,unsigned long end); -void default_idle (void );bool set_pm_idle_to_default (void );void stop_this_cpu (void *dummy);
arch/x86/kernel/process.c +1 -4
@@ -479,7 +479,7 @@ void cpu_idle(void)* We use this if we don't have any better * idle routine.. */ -void default_idle (void ) +static void default_idle (void ) {if (hlt_use_halt ()) {trace_power_start_rcuidle (POWER_CSTATE ,1 ,smp_processor_id ());
@@ -504,9 +504,6 @@ void default_idle(void)cpu_relax (); } } -#ifdef CONFIG_APM_MODULE -EXPORT_SYMBOL (default_idle); -#endif bool set_pm_idle_to_default (void ) {
Signature · 1 line
1.7.12.rc0
Len Brown
reviewerPATCH 4/4 PM: cleanup: stop mandating that platforms export (pm_idle)()
In reply to Len BrownFrom: Len Brown <[email protected]>
(pm_idle)() was originally used on x86 to vector bewteen ACPI and APM. With the advent of CPU_IDLE, that reason for pm_idle to exist vanished.
But x86 APM still scribbled on pm_idle from a module, so pm_idle didn't go away. Worse, it was declared in pm.h, and so it spread to other architectures as dead code.
But today, APM no longer scribbles on pm_idle, so x86 no longer requires pm_idle to be visible to modules, or global at all.
Here we remove pm_idle from pm.h, to stop the mandate that all architectures define it.
This deletes dead code from most architectures, while some continue using their own internal pm_idle.
At the end of the day, pm_idle...
becomes static in sh, was global
becomes static in x86, was EXPORT_SYMBOL becomes as global in sparc, was EXPORT_SYMBOL continues as static in m32r (no pm.h use there) and is deleted from all other places in the kernel.
--- arch/arm/kernel/process.c | 12 +++--------- arch/blackfin/kernel/process.c | 9 +-------- arch/cris/kernel/process.c | 17 ++--------------- arch/ia64/include/asm/processor.h | 2 -- arch/ia64/kernel/process.c | 10 ++-------- arch/ia64/kernel/setup.c | 1 - arch/microblaze/kernel/process.c | 8 +------- arch/mn10300/kernel/process.c | 16 ++-------------- arch/openrisc/kernel/idle.c | 5 ----- arch/sh/kernel/idle.c | 2 +- arch/sparc/include/asm/setup.h | 1 + arch/sparc/kernel/process_32.c | 1 - arch/unicore32/kernel/process.c | 5 ----- arch/x86/kernel/process.c | 5 +---- include/linux/pm.h | 1 - kernel/smp.c | 4 ++-- 16 files changed, 16 insertions(+), 83 deletions(-)
arch/arm/kernel/process.c +3 -9
@@ -172,14 +172,8 @@ static void default_idle(void)local_irq_enable (); } -void (*pm_idle)(void ) = default_idle; -EXPORT_SYMBOL (pm_idle); -/* -* The idle thread, has rather strange semantics for calling pm_idle, -* but this is what x86 does and we need to do the same, so that -* things like cpuidle get called in the same way. The only difference -* is that we always respect 'hlt_counter' to prevent low power idle. +* Respect 'hlt_counter' to prevent low power idle. */ void cpu_idle (void ) {
@@ -210,10 +204,10 @@ void cpu_idle(void) }else if (!need_resched ()) {stop_critical_timings ();if (cpuidle_idle_call ()) -pm_idle (); +default_idle ();start_critical_timings ();/* -* pm_idle functions must always +* idle functions must always * return with IRQs enabled. */ WARN_ON (irqs_disabled ());
arch/blackfin/kernel/process.c +1 -8
@@ -42,9 +42,6 @@ unsigned long l1_stack_len;/* * Powermanagement idle function, if any.. */ -void (*pm_idle)(void ) =NULL ; -EXPORT_SYMBOL (pm_idle); -void (*pm_power_off)(void ) =NULL ;EXPORT_SYMBOL (pm_power_off);
@@ -81,18 +78,14 @@ void cpu_idle(void) {/* endless idle loop with no priority at all */ while (1 ) { -void (*idle)(void ) = pm_idle; -#ifdef CONFIG_HOTPLUG_CPU if (cpu_is_offline (smp_processor_id ()))cpu_die ();#endif -if (!idle) - idle = default_idle;tick_nohz_idle_enter ();rcu_idle_enter ();while (!need_resched ()) -idle (); +default_idle ();rcu_idle_exit ();tick_nohz_idle_exit ();preempt_enable_no_resched ();
arch/cris/kernel/process.c +2 -15
@@ -54,12 +54,8 @@ void enable_hlt(void)EXPORT_SYMBOL (enable_hlt);/* -* The following aren't currently used. +* The following is currently used. */ -void (*pm_idle)(void ); - -extern void default_idle (void ); -void (*pm_power_off)(void );EXPORT_SYMBOL (pm_power_off);
@@ -75,16 +71,7 @@ void cpu_idle (void)/* endless idle loop with no priority at all */ while (1 ) {while (!need_resched ()) { -void (*idle)(void ); -/* -* Mark this as an RCU critical section so that -* synchronize_kernel() in the unload path waits -* for our completion. -*/ - idle = pm_idle; -if (!idle) - idle = default_idle; -idle (); +default_idle (); }schedule_preempt_disabled (); }
arch/ia64/include/asm/processor.h +0 -2
@@ -717,8 +717,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 default_idle (void ); -#define ia64_platform_is (x) (strcmp(x, platform_name) == 0)#endif /* !__ASSEMBLY__ */
arch/ia64/kernel/process.c +2 -8
@@ -56,8 +56,6 @@ void (*ia64_mark_idle)(int);unsigned long boot_option_idle_override =IDLE_NO_OVERRIDE ;EXPORT_SYMBOL (boot_option_idle_override); -void (*pm_idle) (void ); -EXPORT_SYMBOL (pm_idle);void (*pm_power_off) (void );EXPORT_SYMBOL (pm_power_off);
@@ -229,7 +227,7 @@ update_pal_halt_status(int status)/* * We use this if we don't have any better idle routine.. */ -void +static void default_idle (void ) {local_irq_enable ();
@@ -291,7 +289,6 @@ cpu_idle (void) }if (!need_resched ()) { -void (*idle)(void );#ifdef CONFIG_SMP min_xtp ();#endif
@@ -299,10 +296,7 @@ cpu_idle (void)if (mark_idle) (*mark_idle)(1 ); - idle = pm_idle; -if (!idle) - idle = default_idle; - (*idle)(); +default_idle ();if (mark_idle) (*mark_idle)(0 );#ifdef CONFIG_SMP
arch/ia64/kernel/setup.c +0 -1
@@ -1051,7 +1051,6 @@ cpu_init (void) max_num_phys_stacked = num_phys_stacked; }platform_cpu_init (); - pm_idle = default_idle; }void __init
arch/microblaze/kernel/process.c +1 -7
@@ -40,7 +40,6 @@ void show_regs(struct pt_regs *regs) regs->msr, regs->ear, regs->esr, regs->fsr); } -void (*pm_idle)(void );void (*pm_power_off)(void ) =NULL ;EXPORT_SYMBOL (pm_power_off);
@@ -97,15 +96,10 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) { -void (*idle)(void ) = pm_idle; - -if (!idle) - idle = default_idle; -tick_nohz_idle_enter ();rcu_idle_enter ();while (!need_resched ()) -idle (); +default_idle ();rcu_idle_exit ();tick_nohz_idle_exit ();
arch/mn10300/kernel/process.c +2 -14
@@ -36,12 +36,6 @@#include "internal.h" /* -* power management idle function, if any.. -*/ -void (*pm_idle)(void ); -EXPORT_SYMBOL (pm_idle); - -/* * return saved PC of a blocked thread. */ unsigned long thread_saved_pc (struct task_struct *tsk)
@@ -108,18 +102,12 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ for (;;) {while (!need_resched ()) { -void (*idle)(void ); -smp_rmb (); - idle = pm_idle; -if (!idle) {#if defined(CONFIG_SMP ) && !defined(CONFIG_HOTPLUG_CPU ) - idle = poll_idle; +poll_idle ();#else /* CONFIG_SMP && !CONFIG_HOTPLUG_CPU */ - idle = default_idle; +default_idle ();#endif /* CONFIG_SMP && !CONFIG_HOTPLUG_CPU */ - } -idle (); }schedule_preempt_disabled ();
arch/openrisc/kernel/idle.c +0 -5
@@ -39,11 +39,6 @@void (*powersave) (void ) =NULL ; -static inline void pm_idle (void ) -{ -barrier (); -} -void cpu_idle (void ) {set_thread_flag (TIF_POLLING_NRFLAG );
arch/sh/kernel/idle.c +1 -1
@@ -22,7 +22,7 @@#include <asm/smp.h> #include <asm/bl_bit.h> -void (*pm_idle)(void ); +static void (*pm_idle)(void );static int hlt_counter;
arch/sparc/include/asm/setup.h +1 -0
@@ -34,6 +34,7 @@ extern void sun_do_break(void);extern int stop_a_enabled;extern int scons_pwroff; +extern void (*pm_idle)(void );#endif /* __KERNEL__ */ #endif /* _SPARC_SETUP_H */
arch/sparc/kernel/process_32.c +0 -1
@@ -44,7 +44,6 @@* Set in pm platform drivers (apc.c and pmc.c) */ void (*pm_idle)(void ); -EXPORT_SYMBOL (pm_idle);/* * Power-off handler instantiation for pm.h compliance
arch/unicore32/kernel/process.c +0 -5
@@ -45,11 +45,6 @@ static const char * const processor_modes[] = { "UK18", "UK19", "UK1A", "EXTN", "UK1C", "UK1D", "UK1E", "SUSR" }; -/* -* The idle thread, has rather strange semantics for calling pm_idle, -* but this is what x86 does and we need to do the same, so that -* things like cpuidle get called in the same way. -*/ void cpu_idle (void ) {/* endless idle loop with no priority at all */
arch/x86/kernel/process.c +1 -4
@@ -372,10 +372,7 @@ EXPORT_SYMBOL(boot_option_idle_override);/* * Powermanagement idle function, if any.. */ -void (*pm_idle)(void ); -#ifdef CONFIG_APM_MODULE -EXPORT_SYMBOL (pm_idle); -#endif +static void (*pm_idle)(void );static inline int hlt_use_halt (void ) {
include/linux/pm.h +0 -1
@@ -31,7 +31,6 @@/* * Callbacks for platform drivers to implement. */ -extern void (*pm_idle)(void );extern void (*pm_power_off)(void );extern void (*pm_power_off_prepare)(void );
kernel/smp.c +2 -2
@@ -803,11 +803,11 @@ 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 +* Used to synchronize the update of 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 +* left the idle function which had been called via idle function * pointer. So it's guaranteed that nothing uses the previous pointer * anymore. */
Signature · 1 line
1.7.12.rc0
Alan Cox
NAKRe: [PATCH 2/4] x86 idle APM: delete apm_cpu_idle()
In reply to Len BrownQuoted 5 lines · On Fri, 27 Jul 2012 18:42:53 -0400 Len Brown <[email protected]> wrote:
From: Len Brown <[email protected]>
The APM idle feature to call into the BIOS
is known to break some machines, and it has dubious benefit on the (decades old) machines it doesn't break.
You mean "doesn't fit my current plan" I think. I see almost no bugzilla APM reports. It's been solid for years.
It makes a big difference on older systems as it drops the clock. If we are going to drop this we should probaly also drop APM support entirely and 386/486 support.
If not IMHO it should stay. Various embedded platforms are still using ancient hardware setups.
This is a small stable piece of code that has required no maintainance in years
Furthermore we have a feature removal process. Mark it down to be removed in July 2013 if there are no objections, and then wait as per proper process.
NAK
Alan
Len Brown
reviewerRe: [PATCH 2/4] x86 idle APM: delete apm_cpu_idle()
Quoted 11 lines · Alan Cox
Quoted 5 lines · On Fri, 27 Jul 2012 18:42:53 -0400 Len Brown <[email protected]> wrote:
From: Len Brown <[email protected]>
The APM idle feature to call into the BIOS
is known to break some machines, and it has dubious benefit on the (decades old) machines it doesn't break.You mean "doesn't fit my current plan" I think. I see almost no bugzilla APM reports. It's been solid for years.
Hm, I thought it was actually you that mentioned that this particular feature of APM caused some systems to fail...
Unfortunately quiet bugzilla doesn't tell us the difference between "solid as a rock and used by millions of users every day" and "nobody anywhere running new software on this old hardware".
Quoted 3 lines
It makes a big difference on older systems as it drops the clock. If we are going to drop this we should probaly also drop APM support entirely and 386/486 support.
Do you have an APM system that boots a 2012 kernel? Are you willing to test new kernels on it?
Quoted 11 lines
If not IMHO it should stay. Various embedded platforms are still using ancient hardware setups.
This is a small stable piece of code that has required no maintainance in years
Furthermore we have a feature removal process. Mark it down to be removed in July 2013 if there are no objections, and then wait as per proper process.
NAK
At your request 16 months ago, we did exactly that. Further, we added build-time and run-time warnings and all they did was cause distro mis-merges and requests to remove the warnings.
16 months ago we came within inches of dropping APM entirely, as Stephen said he hadn't maintained it for a long time. Jiri volunteered to look after it, and Pavel offered that he had 1 surviving machine someplace that actually supports APM, though I don't know if boots.
I don't dispute that there may be some APM systems running someplace, but if nobody is going to test a 2012 kernel on such hardware, then we are kidding ourselves if we say we "support" today's kernel on it. Also, the whole idea was even if we do support such HW, this patch is supposed to make that HW more stable, not less stable.
-Len
Re: [linux-pm] [PATCH 4/4] PM: cleanup: stop mandating that platforms export (pm_idle)()
In reply to Len Brown+ linux-arm-kernel
Quoted 39 lines · Len Brown
From: Len Brown <[email protected]>
(pm_idle)() was originally used on x86 to vector bewteen ACPI and APM. With the advent of
CPU_IDLE, that reason forpm_idleto exist vanished.But x86 APM still scribbled on
pm_idlefrom a module, sopm_idledidn't go away. Worse, it was declared inpm.h, and so it spread to other architectures as dead code.But today, APM no longer scribbles on
pm_idle, so x86 no longer requirespm_idleto be visible to modules, or global at all.Here we remove
pm_idlefrompm.h, to stop the mandate that all architectures define it.This deletes dead code from most architectures, while some continue using their own internal
pm_idle.At the end of the day,
pm_idle...
becomes static in sh, was global
becomes static in x86, wasEXPORT_SYMBOLbecomes as global in sparc, wasEXPORT_SYMBOLcontinues as static in m32r (nopm.huse there) and is deleted from all other places in the kernel.Signed-off-by Len Brown <[email protected]>Cc x86 at kernel.org # x86Cc Mike Frysinger <[email protected]> # blackfinCc Jonas Bonn <[email protected]> # openriscCc Tony Luck <[email protected]> # ia64Cc David Howells <[email protected]> # mn10300Cc Mikael Starvik <[email protected]> # crisCc Michal Simek <[email protected]> # microblazeCc Paul Mundt <[email protected]> # shCc David S. Miller <[email protected]> # sparcCc Russell King <[email protected]> # ARMCc Rafael J. Wysocki <[email protected]> # PM
Quoted 2 lines
--- arch/arm/kernel/process.c | 12 +++---------
Just looking at the ARM changes, it looks good to me. I tested it with and without CPUidle on my ARM-based TI/OMAP platforms (3430/n900, 4430/Panda)
So for the arch/arm changes:
Kevin