Re: [PATCH v3 8/9] KVM: VMX: Drop a redundant pmu->global_ctrl check when processing pebs_enable
From: Mi, Dapeng
Date: Tue May 12 2026 - 01:00:50 EST
On 5/9/2026 7:13 AM, Sean Christopherson wrote:
> Drop a redundant check that a PMC is globally enabled when looking for
> PEBS counters that are cross-mapped between the guest and the host. The
> for-loop explicitly iterates over pmu->global_ctrl, and since PEBS requires
> PMU v2+, kvm_pmu_has_perf_global_ctrl() must be true, and thus
> pmc_is_globally_enabled() is simply checking that the bit is set in
> pmu->global_ctrl.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---
> arch/x86/kvm/vmx/pmu_intel.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
> index e65adb3dc066..659fe097b904 100644
> --- a/arch/x86/kvm/vmx/pmu_intel.c
> +++ b/arch/x86/kvm/vmx/pmu_intel.c
> @@ -752,8 +752,7 @@ u64 intel_pmu_get_cross_mapped_mask(struct kvm_pmu *pmu)
> host_cross_mapped_mask = 0;
>
> kvm_for_each_pmc(pmu, pmc, bit, (unsigned long *)&pmu->global_ctrl) {
> - if (!pmc_is_locally_enabled(pmc) ||
> - !pmc_is_globally_enabled(pmc) || !pmc->perf_event)
> + if (!pmc_is_locally_enabled(pmc) || !pmc->perf_event)
> continue;
>
> /*
Reviewed-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>