[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220915073121.1038840-1-dapeng1.mi@intel.com>
Date: Thu, 15 Sep 2022 15:31:21 +0800
From: Dapeng Mi <dapeng1.mi@...el.com>
To: seanjc@...gle.com, pbonzini@...hat.com, tglx@...utronix.de,
mingo@...hat.com, dave.hansen@...ux.intel.com
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
zhenyuw@...ux.intel.com, Dapeng Mi <dapeng1.mi@...el.com>
Subject: [PATCH] KVM: x86: disable halt polling when powersave governor is used
Halt polling is enabled by default even through the CPU frequency
governor is configured to powersave. Generally halt polling would
consume extra power and this's not identical with the intent of
powersave governor.
disabling halt polling in powersave governor can save the precious
power in power critical case.
FIO random read test on Alder Lake platform shows halt polling
occupies ~17% CPU utilization and consume 7% extra CPU power.
After disabling halt polling, CPU has more chance to enter deeper
C-states (C1E%: 25.3% -> 33.4%, C10%: 4.4% -> 17.4%).
On Alder Lake platform, we don't find there are obvious performance
downgrade after disabling halt polling on FIO and Netperf cases.
Netperf UDP_RR case runs from two VMs locate on two different physical
machines.
FIO(MB/s) Base Disable-halt-polling Delta%
Rand-read 432.6 436.3 0.8%
Netperf Base Disable-halt-polling Delta%
UDP_RR 509.8 508.5 -0.3%
Signed-off-by: Dapeng Mi <dapeng1.mi@...el.com>
---
arch/x86/kvm/x86.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d7374d768296..c0eb6574cbbb 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -13015,7 +13015,22 @@ bool kvm_vector_hashing_enabled(void)
bool kvm_arch_no_poll(struct kvm_vcpu *vcpu)
{
- return (vcpu->arch.msr_kvm_poll_control & 1) == 0;
+ struct cpufreq_policy *policy = cpufreq_cpu_get(vcpu->cpu);
+ bool powersave = false;
+
+ /*
+ * Halt polling could consume much CPU power, if CPU frequency
+ * governor is set to "powersave", disable halt polling.
+ */
+ if (policy) {
+ if ((policy->policy == CPUFREQ_POLICY_POWERSAVE) ||
+ (policy->governor &&
+ !strncmp(policy->governor->name, "powersave",
+ CPUFREQ_NAME_LEN)))
+ powersave = true;
+ cpufreq_cpu_put(policy);
+ }
+ return ((vcpu->arch.msr_kvm_poll_control & 1) == 0) || powersave;
}
EXPORT_SYMBOL_GPL(kvm_arch_no_poll);
--
2.34.1
Powered by blists - more mailing lists