[PATCH] x86: Don't use MWAIT if explicitly requested

From: Zhenzhong Duan
Date: Fri Oct 18 2019 - 01:55:24 EST


If 'idle=nomwait' is specified or process matching what's in
processor_idle_dmi_table, we should't use MWAIT at bootup stage before
cpuidle driver loaded, even if it's preferred by default on Intel.

Add a check so that HALT instruction is used in those cases.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
arch/x86/kernel/process.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 5e94c43..37fc577 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -667,6 +667,10 @@ static void amd_e400_idle(void)
*/
static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
{
+ /* Don't use MWAIT-C1 if explicitly requested */
+ if (boot_option_idle_override == IDLE_NOMWAIT)
+ return 0;
+
if (c->x86_vendor != X86_VENDOR_INTEL)
return 0;

--
1.8.3.1