kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: disable halt polling when powersave governor is used
@ 2022-09-15  7:31 Dapeng Mi
  2022-10-07 17:51 ` Sean Christopherson
  0 siblings, 1 reply; 5+ messages in thread
From: Dapeng Mi @ 2022-09-15  7:31 UTC (permalink / raw)
  To: seanjc, pbonzini, tglx, mingo, dave.hansen
  Cc: kvm, linux-kernel, zhenyuw, Dapeng Mi

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@intel.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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-15  6:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15  7:31 [PATCH] KVM: x86: disable halt polling when powersave governor is used Dapeng Mi
2022-10-07 17:51 ` Sean Christopherson
2022-10-08  9:40   ` Mi, Dapeng1
2022-10-25 17:06     ` Sean Christopherson
2022-11-15  6:25       ` Mi, Dapeng1

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).