]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86/pmu: Open code pmc_event_is_allowed() in its callers
authorSean Christopherson <seanjc@google.com>
Tue, 5 Aug 2025 19:05:21 +0000 (12:05 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 19 Aug 2025 18:59:39 +0000 (11:59 -0700)
Open code pmc_event_is_allowed() in its callers, as kvm_pmu_trigger_event()
only needs to check the event filter (both global and local enables are
consulted outside of the loop).

No functional change intended.

Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://lore.kernel.org/r/20250805190526.1453366-14-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/pmu.c

index 55b995c3ed08bdbcda32073850607a08219bbe92..fa34645596987d5b5939640bbb6a410825f62a47 100644 (file)
@@ -491,12 +491,6 @@ static bool check_pmu_event_filter(struct kvm_pmc *pmc)
        return is_fixed_event_allowed(filter, pmc->idx);
 }
 
-static bool pmc_event_is_allowed(struct kvm_pmc *pmc)
-{
-       return pmc_is_globally_enabled(pmc) && pmc_is_locally_enabled(pmc) &&
-              check_pmu_event_filter(pmc);
-}
-
 static int reprogram_counter(struct kvm_pmc *pmc)
 {
        struct kvm_pmu *pmu = pmc_to_pmu(pmc);
@@ -507,7 +501,8 @@ static int reprogram_counter(struct kvm_pmc *pmc)
 
        emulate_overflow = pmc_pause_counter(pmc);
 
-       if (!pmc_event_is_allowed(pmc))
+       if (!pmc_is_globally_enabled(pmc) || !pmc_is_locally_enabled(pmc) ||
+           !check_pmu_event_filter(pmc))
                return 0;
 
        if (emulate_overflow)
@@ -979,7 +974,8 @@ static void kvm_pmu_trigger_event(struct kvm_vcpu *vcpu,
                return;
 
        kvm_for_each_pmc(pmu, pmc, i, bitmap) {
-               if (!pmc_event_is_allowed(pmc) || !cpl_is_matched(pmc))
+               if (!pmc_is_globally_enabled(pmc) || !pmc_is_locally_enabled(pmc) ||
+                   !check_pmu_event_filter(pmc) || !cpl_is_matched(pmc))
                        continue;
 
                kvm_pmu_incr_counter(pmc);