Re: [PATCH v9 05/12] KVM: x86/pmu: Support PERF_METRICS MSR in mediated vPMU
From: Chen, Zide
Date: Thu Oct 29 2026 - 19:17:29 EST
On 10/29/2026 5:06 PM, Yosry Ahmed wrote:
>> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
>> index 448044a2b121..f4d3801b97bc 100644
>> --- a/arch/x86/kvm/pmu.c
>> +++ b/arch/x86/kvm/pmu.c
>> @@ -806,9 +806,16 @@ static bool kvm_need_any_pmc_intercept(struct kvm_vcpu *vcpu)
>> pmu->nr_arch_fixed_counters != kvm_host_pmu.num_counters_fixed;
>> }
>>
>> +static bool kvm_need_perf_metrics_intercept(struct kvm_vcpu *vcpu)
>
> The name is confusing, this doesn't control the intercept of
> PERF_METRICS (and it wouldn't be correct to use it for that AFAICT).
Right, these two APIs do not directly determine whether the mentioned
resources need interception:
kvm_need_any_pmc_intercept()
kvm_need_perf_metrics_intercept()
This is different from kvm_need_perf_global_ctrl_intercept() and
kvm_need_rdpmc_intercept().
How about change them to something like these?
kvm_pmu_has_unexposed_pmcs()
kvm_pmu_has_unexposed_perf_metrics()
Or merge them into one single API? kvm_pmu_has_unexposed_resources()
>
>> +{
>> + return (kvm_host.perf_capabilities & PERF_CAP_PERF_METRICS) &&
>> + !kvm_vcpu_has_perf_metrics(vcpu);
>> +}
>>