cpuidle-haltpoll: Replace default_idle() with arch_cpu_idle()
authorLi RongQing <lirongqing@baidu.com>
Fri, 6 Jan 2023 04:03:42 +0000 (12:03 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 20 Jan 2023 16:33:52 +0000 (17:33 +0100)
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>
arch/x86/kernel/process.c
drivers/cpuidle/cpuidle-haltpoll.c

index 40d156a31676e66dd0f3c694f4ea670d67742c38..00a831d56c5009540d4443d1a76bd97f0c50d317 100644 (file)
@@ -721,6 +721,7 @@ void arch_cpu_idle(void)
 {
        x86_idle();
 }
+EXPORT_SYMBOL_GPL(arch_cpu_idle);
 
 /*
  * We use this if we don't have any better idle routine..
index 3a39a7f48b7712632d65515a79cb1f6ebec95cdc..e66df22f96955fed1aac9745875794cb74eecf6c 100644 (file)
@@ -32,7 +32,7 @@ static int default_enter_idle(struct cpuidle_device *dev,
                local_irq_enable();
                return index;
        }
-       default_idle();
+       arch_cpu_idle();
        return index;
 }