Skip to content

Commit 6b6f1ad

Browse files
committed
KVM: x86/pmu: Rename pmc_speculative_in_use() to pmc_is_locally_enabled()
Rename pmc_speculative_in_use() to pmc_is_locally_enabled() to better capture what it actually tracks, and to show its relationship to pmc_is_globally_enabled(). While neither AMD nor Intel refer to event selectors or the fixed counter control MSR as "local", it's the obvious name to pair with "global". As for "speculative", there's absolutely nothing speculative about the checks. E.g. for PMUs without PERF_GLOBAL_CTRL, from the guest's perspective, the counters are "in use" without any qualifications. No functional change intended. Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Link: https://lore.kernel.org/r/20250805190526.1453366-13-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 5dfd498 commit 6b6f1ad

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

arch/x86/kvm/pmu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ static bool check_pmu_event_filter(struct kvm_pmc *pmc)
493493

494494
static bool pmc_event_is_allowed(struct kvm_pmc *pmc)
495495
{
496-
return pmc_is_globally_enabled(pmc) && pmc_speculative_in_use(pmc) &&
496+
return pmc_is_globally_enabled(pmc) && pmc_is_locally_enabled(pmc) &&
497497
check_pmu_event_filter(pmc);
498498
}
499499

@@ -572,7 +572,7 @@ void kvm_pmu_recalc_pmc_emulation(struct kvm_pmu *pmu, struct kvm_pmc *pmc)
572572
* omitting a PMC from a bitmap could result in a missed event if the
573573
* filter is changed to allow counting the event.
574574
*/
575-
if (!pmc_speculative_in_use(pmc))
575+
if (!pmc_is_locally_enabled(pmc))
576576
return;
577577

578578
if (pmc_is_event_match(pmc, kvm_pmu_eventsel.INSTRUCTIONS_RETIRED))
@@ -912,7 +912,7 @@ void kvm_pmu_cleanup(struct kvm_vcpu *vcpu)
912912
pmu->pmc_in_use, X86_PMC_IDX_MAX);
913913

914914
kvm_for_each_pmc(pmu, pmc, i, bitmask) {
915-
if (pmc->perf_event && !pmc_speculative_in_use(pmc))
915+
if (pmc->perf_event && !pmc_is_locally_enabled(pmc))
916916
pmc_stop_counter(pmc);
917917
}
918918

arch/x86/kvm/pmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static inline struct kvm_pmc *get_fixed_pmc(struct kvm_pmu *pmu, u32 msr)
160160
return NULL;
161161
}
162162

163-
static inline bool pmc_speculative_in_use(struct kvm_pmc *pmc)
163+
static inline bool pmc_is_locally_enabled(struct kvm_pmc *pmc)
164164
{
165165
struct kvm_pmu *pmu = pmc_to_pmu(pmc);
166166

arch/x86/kvm/vmx/pmu_intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ void intel_pmu_cross_mapped_check(struct kvm_pmu *pmu)
762762
int bit, hw_idx;
763763

764764
kvm_for_each_pmc(pmu, pmc, bit, (unsigned long *)&pmu->global_ctrl) {
765-
if (!pmc_speculative_in_use(pmc) ||
765+
if (!pmc_is_locally_enabled(pmc) ||
766766
!pmc_is_globally_enabled(pmc) || !pmc->perf_event)
767767
continue;
768768

0 commit comments

Comments
 (0)