Re: [PATCH v2 02/16] KVM: x86/pmu: Rename all_valid_pmc_idx to pmc_exists

From: Mi, Dapeng

Date: Mon Aug 31 2026 - 22:16:10 EST


Reviewed-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>


On 8/28/2026 6:37 AM, Zide Chen wrote:
> all_valid_pmc_idx is a bitmap of valid PMC indices, not an index
> itself; rename it to pmc_exists to better reflect what it holds and
> keep the name consistent with other fields in the same struct.
>
> No functional change intended.
>
> Signed-off-by: Zide Chen <zide.chen@xxxxxxxxx>
> ---
> v2:
> - Pick the name pmc_exists other than all_valid_pmc_mask. (Sean)
> ---
> arch/x86/include/asm/kvm_host.h | 2 +-
> arch/x86/kvm/pmu.c | 10 +++++-----
> arch/x86/kvm/vmx/pmu_intel.c | 2 +-
> 3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 283847619ff8..e473796da7d9 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -594,7 +594,7 @@ struct kvm_pmu {
> DECLARE_BITMAP(reprogram_pmi, X86_PMC_IDX_MAX);
> atomic64_t __reprogram_pmi;
> };
> - DECLARE_BITMAP(all_valid_pmc_idx, X86_PMC_IDX_MAX);
> + DECLARE_BITMAP(pmc_exists, X86_PMC_IDX_MAX);
> DECLARE_BITMAP(pmc_in_use, X86_PMC_IDX_MAX);
>
> DECLARE_BITMAP(pmc_counting_instructions, X86_PMC_IDX_MAX);
> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
> index a7d60c8785cd..8f2effee3b7b 100644
> --- a/arch/x86/kvm/pmu.c
> +++ b/arch/x86/kvm/pmu.c
> @@ -950,7 +950,7 @@ static void kvm_pmu_reset(struct kvm_vcpu *vcpu)
> bitmap_zero(pmu->reprogram_pmi, X86_PMC_IDX_MAX);
> bitmap_zero(pmu->pmc_has_mode_specific_enables, X86_PMC_IDX_MAX);
>
> - kvm_for_each_pmc(pmu, pmc, i, pmu->all_valid_pmc_idx) {
> + kvm_for_each_pmc(pmu, pmc, i, pmu->pmc_exists) {
> pmc_stop_counter(pmc);
> pmc->counter = 0;
> pmc->emulated_counter = 0;
> @@ -996,7 +996,7 @@ void kvm_pmu_refresh(struct kvm_vcpu *vcpu)
> pmu->fixed_ctr_ctrl_rsvd = ~0ull;
> pmu->pebs_enable_rsvd = ~0ull;
> pmu->pebs_data_cfg_rsvd = ~0ull;
> - bitmap_zero(pmu->all_valid_pmc_idx, X86_PMC_IDX_MAX);
> + bitmap_zero(pmu->pmc_exists, X86_PMC_IDX_MAX);
>
> if (!vcpu->kvm->arch.enable_pmu)
> return;
> @@ -1017,8 +1017,8 @@ void kvm_pmu_refresh(struct kvm_vcpu *vcpu)
> if (kvm_vcpu_has_mediated_pmu(vcpu))
> kvm_pmu_call(write_global_ctrl)(pmu->global_ctrl);
>
> - bitmap_set(pmu->all_valid_pmc_idx, 0, pmu->nr_arch_gp_counters);
> - bitmap_set(pmu->all_valid_pmc_idx, KVM_FIXED_PMC_BASE_IDX,
> + bitmap_set(pmu->pmc_exists, 0, pmu->nr_arch_gp_counters);
> + bitmap_set(pmu->pmc_exists, KVM_FIXED_PMC_BASE_IDX,
> pmu->nr_arch_fixed_counters);
> }
>
> @@ -1040,7 +1040,7 @@ void kvm_pmu_cleanup(struct kvm_vcpu *vcpu)
>
> pmu->need_cleanup = false;
>
> - bitmap_andnot(bitmask, pmu->all_valid_pmc_idx,
> + bitmap_andnot(bitmask, pmu->pmc_exists,
> pmu->pmc_in_use, X86_PMC_IDX_MAX);
>
> kvm_for_each_pmc(pmu, pmc, i, bitmask) {
> diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
> index e71ddd51ae56..322a3ad580dd 100644
> --- a/arch/x86/kvm/vmx/pmu_intel.c
> +++ b/arch/x86/kvm/vmx/pmu_intel.c
> @@ -557,7 +557,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
> lbr_desc->records.nr = 0;
>
> if (lbr_desc->records.nr)
> - bitmap_set(pmu->all_valid_pmc_idx, INTEL_PMC_IDX_FIXED_VLBR, 1);
> + bitmap_set(pmu->pmc_exists, INTEL_PMC_IDX_FIXED_VLBR, 1);
>
> if (pmu->version == 1)
> return;