x86: simplify idle selection
authorThomas Gleixner <tglx@linutronix.de>
Mon, 9 Jun 2008 14:59:53 +0000 (16:59 +0200)
committerIngo Molnar <mingo@elte.hu>
Tue, 10 Jun 2008 13:52:01 +0000 (15:52 +0200)
default_idle is selected in cpu_idle(), when no other idle routine is
selected. Select it in select_idle_routine() when mwait is not
selected.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/process.c
arch/x86/kernel/process_32.c
arch/x86/kernel/process_64.c

index ba370dc8685bf8f9bf31e9100f78c4e800ea755e..b3078f4ce25b537f49bbfbc3ac876ee78f17bc0a 100644 (file)
@@ -139,27 +139,23 @@ static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
 
 void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
 {
-       static int selected;
-
-       if (selected)
-               return;
 #ifdef CONFIG_X86_SMP
        if (pm_idle == poll_idle && smp_num_siblings > 1) {
                printk(KERN_WARNING "WARNING: polling idle and HT enabled,"
                        " performance may degrade.\n");
        }
 #endif
+       if (pm_idle)
+               return;
+
        if (cpu_has(c, X86_FEATURE_MWAIT) && mwait_usable(c)) {
                /*
-                * Skip, if setup has overridden idle.
                 * One CPU supports mwait => All CPUs supports mwait
                 */
-               if (!pm_idle) {
-                       printk(KERN_INFO "using mwait in idle threads.\n");
-                       pm_idle = mwait_idle;
-               }
-       }
-       selected = 1;
+               printk(KERN_INFO "using mwait in idle threads.\n");
+               pm_idle = mwait_idle;
+       } else
+               pm_idle = default_idle;
 }
 
 static int __init idle_setup(char *str)
index f8476dfbb60d9818f5da08d3a5b95a223930964f..ee4ab461c50d4522184a0e9b21ab20ce794db270 100644 (file)
@@ -168,24 +168,19 @@ void cpu_idle(void)
        while (1) {
                tick_nohz_stop_sched_tick();
                while (!need_resched()) {
-                       void (*idle)(void);
 
                        check_pgt_cache();
                        rmb();
-                       idle = pm_idle;
 
                        if (rcu_pending(cpu))
                                rcu_check_callbacks(cpu, 0);
 
-                       if (!idle)
-                               idle = default_idle;
-
                        if (cpu_is_offline(cpu))
                                play_dead();
 
                        local_irq_disable();
                        __get_cpu_var(irq_stat).idle_timestamp = jiffies;
-                       idle();
+                       pm_idle();
                }
                tick_nohz_restart_sched_tick();
                preempt_enable_no_resched();
index e2319f39988b042f364a73174a0d2ac254a5b60d..db3d89a04399e91096f675ebe633bf6e1e47fac7 100644 (file)
@@ -150,12 +150,9 @@ void cpu_idle(void)
        while (1) {
                tick_nohz_stop_sched_tick();
                while (!need_resched()) {
-                       void (*idle)(void);
 
                        rmb();
-                       idle = pm_idle;
-                       if (!idle)
-                               idle = default_idle;
+
                        if (cpu_is_offline(smp_processor_id()))
                                play_dead();
                        /*
@@ -165,7 +162,7 @@ void cpu_idle(void)
                         */
                        local_irq_disable();
                        enter_idle();
-                       idle();
+                       pm_idle();
                        /* In many cases the interrupt that ended idle
                           has already called exit_idle. But some idle
                           loops can be woken up without interrupt. */