Commit 9254beaa authored by Like Xu's avatar Like Xu Committed by Paolo Bonzini

KVM: vmx/pmu: Reduce the overhead of LBR pass-through or cancellation

When the LBR records msrs has already been pass-through, there is no
need to call vmx_update_intercept_for_lbr_msrs() again and again, and
vice versa.
Signed-off-by: default avatarLike Xu <like.xu@linux.intel.com>
Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
Message-Id: <20210201051039.255478-8-like.xu@linux.intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 1b5ac322
...@@ -557,6 +557,7 @@ static void intel_pmu_init(struct kvm_vcpu *vcpu) ...@@ -557,6 +557,7 @@ static void intel_pmu_init(struct kvm_vcpu *vcpu)
vcpu->arch.perf_capabilities = vmx_get_perf_capabilities(); vcpu->arch.perf_capabilities = vmx_get_perf_capabilities();
lbr_desc->records.nr = 0; lbr_desc->records.nr = 0;
lbr_desc->event = NULL; lbr_desc->event = NULL;
lbr_desc->msr_passthrough = false;
} }
static void intel_pmu_reset(struct kvm_vcpu *vcpu) static void intel_pmu_reset(struct kvm_vcpu *vcpu)
...@@ -603,12 +604,24 @@ static void vmx_update_intercept_for_lbr_msrs(struct kvm_vcpu *vcpu, bool set) ...@@ -603,12 +604,24 @@ static void vmx_update_intercept_for_lbr_msrs(struct kvm_vcpu *vcpu, bool set)
static inline void vmx_disable_lbr_msrs_passthrough(struct kvm_vcpu *vcpu) static inline void vmx_disable_lbr_msrs_passthrough(struct kvm_vcpu *vcpu)
{ {
struct lbr_desc *lbr_desc = vcpu_to_lbr_desc(vcpu);
if (!lbr_desc->msr_passthrough)
return;
vmx_update_intercept_for_lbr_msrs(vcpu, true); vmx_update_intercept_for_lbr_msrs(vcpu, true);
lbr_desc->msr_passthrough = false;
} }
static inline void vmx_enable_lbr_msrs_passthrough(struct kvm_vcpu *vcpu) static inline void vmx_enable_lbr_msrs_passthrough(struct kvm_vcpu *vcpu)
{ {
struct lbr_desc *lbr_desc = vcpu_to_lbr_desc(vcpu);
if (lbr_desc->msr_passthrough)
return;
vmx_update_intercept_for_lbr_msrs(vcpu, false); vmx_update_intercept_for_lbr_msrs(vcpu, false);
lbr_desc->msr_passthrough = true;
} }
/* /*
......
...@@ -113,6 +113,9 @@ struct lbr_desc { ...@@ -113,6 +113,9 @@ struct lbr_desc {
* The records may be inaccurate if the host reclaims the LBR. * The records may be inaccurate if the host reclaims the LBR.
*/ */
struct perf_event *event; struct perf_event *event;
/* True if LBRs are marked as not intercepted in the MSR bitmap */
bool msr_passthrough;
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment