From aa49539d5f735b9199afa5eeb80e63540a6c34cc Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 17 Oct 2024 14:56:31 -0400 Subject: [PATCH] x86_cstates: Call arch_cpu_pause() if wait is disabled. This wait() routine is called by cpu_wait(), which is what spinlocks use in their critical loops. If there is no CPU idle module, then cpu_wait() just calls arch_cpu_pause(). As "wait" is only enabled in power-saving mode, we should do the same here to retain the same behavior (and potentially save some power even in "high-performance" mode.) Tested on bare metal; performance difference for a compile job (while on battery) may be 5% lower, or that could just be noise. --- src/add-ons/kernel/power/cpuidle/x86_cstates/x86_cstates.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/power/cpuidle/x86_cstates/x86_cstates.cpp b/src/add-ons/kernel/power/cpuidle/x86_cstates/x86_cstates.cpp index cc0dfa0380..d421f1cfbb 100644 --- a/src/add-ons/kernel/power/cpuidle/x86_cstates/x86_cstates.cpp +++ b/src/add-ons/kernel/power/cpuidle/x86_cstates/x86_cstates.cpp @@ -109,8 +109,10 @@ cstates_idle(void) static void cstates_wait(int32* variable, int32 test) { - if (!sEnableWait) + if (!sEnableWait) { + arch_cpu_pause(); return; + } InterruptsLocker _; x86_monitor(variable, 0, 0);