Done either at bootup or dynamically:

arch/x86/kernel/process.c:

577 static int __init idle_setup(char *str)
578 {
579         if (!str)
580                 return -EINVAL;
581
582         if (!strcmp(str, "poll")) {
583                 printk("using polling idle threads.\n");
584                 pm_idle = poll_idle;
585         } else if (!strcmp(str, "mwait"))
586                 force_mwait = 1;
587         else if (!strcmp(str, "halt")) {
588                 /*
589                  * When the boot option of idle=halt is added, halt is
590                  * forced to be used for CPU idle. In such case CPU C2/C3
591                  * won't be used again.
592                  * To continue to load the CPU idle driver, don't touch
593                  * the boot_option_idle_override.
594                  */
595                 pm_idle = default_idle;
596                 idle_halt = 1;
597                 return 0;
598         } else if (!strcmp(str, "nomwait")) {
599                 /*
600                  * If the boot option of "idle=nomwait" is added,
601                  * it means that mwait will be disabled for CPU C2/C3
602                  * states. In such case it won't touch the variable
603                  * of boot_option_idle_override.
604                  */
605                 idle_nomwait = 1;
606                 return 0;
607         } else
608                 return -1;
609
610         boot_option_idle_override = 1;
611         return 0;
612 }
613 early_param("idle", idle_setup);



544 void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
545 {
546 #ifdef CONFIG_SMP
547         if (pm_idle == poll_idle && smp_num_siblings > 1) {
548                 printk(KERN_WARNING "WARNING: polling idle and HT enabled,"
549                         " performance may degrade.\n");
550         }
551 #endif
552         if (pm_idle)
553                 return;
554
555         if (cpu_has(c, X86_FEATURE_MWAIT) && mwait_usable(c)) {
556                 /*
557                  * One CPU supports mwait => All CPUs supports mwait
558                  */
559                 printk(KERN_INFO "using mwait in idle threads.\n");
560                 pm_idle = mwait_idle;
561         } else if (check_c1e_idle(c)) {
562                 printk(KERN_INFO "using C1E aware idle routine\n");
563                 pm_idle = c1e_idle;
564         } else
565                 pm_idle = default_idle;
566 }
567

Reply via email to