From: Dapeng Mi <dapeng1.mi@intel.com>
To: seanjc@google.com, pbonzini@redhat.com, tglx@linutronix.de,
mingo@redhat.com, dave.hansen@linux.intel.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
zhenyuw@linux.intel.com, Dapeng Mi <dapeng1.mi@intel.com>
Subject: [PATCH] KVM: x86: disable halt polling when powersave governor is used
Date: Thu, 15 Sep 2022 15:31:21 +0800 [thread overview]
Message-ID: <20220915073121.1038840-1-dapeng1.mi@intel.com> (raw)
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
next reply other threads:[~2022-09-15 7:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 7:31 Dapeng Mi [this message]
2022-10-07 17:51 ` [PATCH] KVM: x86: disable halt polling when powersave governor is used Sean Christopherson
2022-10-08 9:40 ` Mi, Dapeng1
2022-10-25 17:06 ` Sean Christopherson
2022-11-15 6:25 ` Mi, Dapeng1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220915073121.1038840-1-dapeng1.mi@intel.com \
--to=dapeng1.mi@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=zhenyuw@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).