Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpuidle-haltpoll: Replace default_idle() with arch_cpu_idle()

When a KVM guest has MWAIT, mwait_idle() is used as the default idle
function.

However, the cpuidle-haltpoll driver calls default_idle() from
default_enter_idle() directly and that one uses HLT instead of MWAIT,
which may affect performance adversely, because MWAIT is preferred to
HLT as explained by the changelog of commit aebef63cf7ff ("x86: Remove
vendor checks from prefer_mwait_c1_over_halt").

Make default_enter_idle() call arch_cpu_idle(), which can use MWAIT,
instead of default_idle() to address this issue.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
[ rjw: Changelog rewrite ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Li RongQing and committed by
Rafael J. Wysocki
716ff71a 4edc13ae

+2 -1
+1
arch/x86/kernel/process.c
··· 721 721 { 722 722 x86_idle(); 723 723 } 724 + EXPORT_SYMBOL_GPL(arch_cpu_idle); 724 725 725 726 /* 726 727 * We use this if we don't have any better idle routine..
+1 -1
drivers/cpuidle/cpuidle-haltpoll.c
··· 32 32 local_irq_enable(); 33 33 return index; 34 34 } 35 - default_idle(); 35 + arch_cpu_idle(); 36 36 return index; 37 37 } 38 38