summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorWanpeng Li <wanpengli@tencent.com>2020-03-13 11:55:18 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2020-03-16 17:58:58 +0100
commit041bc42ce2d0efac3b85bbb81dea8c74b81f4ef9 (patch)
treea77a59dc86fd997e0b105ab004edc9b86d63a625 /arch/x86/kvm
parent331b4de9a7e780f9648ced959c08f4d593aa2e7b (diff)
downloadlinux-041bc42ce2d0efac3b85bbb81dea8c74b81f4ef9.tar.gz
linux-041bc42ce2d0efac3b85bbb81dea8c74b81f4ef9.tar.bz2
linux-041bc42ce2d0efac3b85bbb81dea8c74b81f4ef9.zip
KVM: VMX: Micro-optimize vmexit time when not exposing PMU
PMU is not exposed to guest by most of products from cloud providers since the bad performance of PMU emulation and security concern. However, it calls perf_guest_switch_get_msrs() and clear_atomic_switch_msr() unconditionally even if PMU is not exposed to the guest before each vmentry. ~2% vmexit time reduced can be observed by kvm-unit-tests/vmexit.flat on my SKX server. Before patch: vmcall 1559 After patch: vmcall 1529 Signed-off-by: Wanpeng Li <wanpengli@tencent.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/vmx/vmx.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index e961633182f8..b447d66f44e6 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6549,7 +6549,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
pt_guest_enter(vmx);
- atomic_switch_perf_msrs(vmx);
+ if (vcpu_to_pmu(vcpu)->version)
+ atomic_switch_perf_msrs(vmx);
atomic_switch_umwait_control_msr(vmx);
if (enable_preemption_timer)