Re: [PATCH v8 3/8] KVM: x86/pmu: Rename and move vcpu_get_perf_capabilities() to pmu.h
"Chen, Zide" <[email protected]>
| Newsgroups | dev.linux.lists.sashiko-reviews,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
On 8/17/2026 1:52 PM, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [Low] Header files pmu.h and pmu_intel.h lack required includes, violating self-contained header practices. > -- > > --- Patch [3]: [PATCH v8 3/8] KVM: x86/pmu: Rename and move vcpu_get_perf_capabilities() to pmu.h --- > commit 7eb009fb5328b80368e10acda6cfe621b3e1e1c0 > Author: Zide Chen <[email protected]> > > KVM: x86/pmu: Rename and move vcpu_get_perf_capabilities() to pmu.h > > This commit renames vcpu_get_perf_capabilities() to kvm_vcpu_get_perf_caps() > and moves it to the common x86 PMU header. This prepares the function to be > called from common x86 code to check the guest's PERF_METRICS capability. > >> diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h >> index 090c9bbb74f48..82f955e5a4507 100644 >> --- a/arch/x86/kvm/pmu.h >> +++ b/arch/x86/kvm/pmu.h > [ ... ] >> @@ -271,6 +271,14 @@ static inline bool kvm_pmu_is_fastpath_emulation_allowed(struct kvm_vcpu *vcpu) >> X86_PMC_IDX_MAX); >> } >> >> +static inline u64 kvm_vcpu_get_perf_caps(struct kvm_vcpu *vcpu) >> +{ >> + if (!guest_cpu_cap_has(vcpu, X86_FEATURE_PDCM)) >> + return 0; > > [Severity: Low] > Does this file need to include cpuid.h? guest_cpu_cap_has() is used here, > but pmu.h does not include the header that defines it. Copied from my reply in v7 review: It sounds reasonable, but I'd prefer to keep it as-is. Adding cpuid.h to pmu.h would make pmu.h more self-contained, but it would also naturally lead to removing now-redundant cpuid.h includes from PMU-related files such as vmx/pmu_intel.c, svm/pmu.c, and potentially others. I'd like to keep the current patch focused on the functional change and avoid mixing it with include dependency cleanup. >> + >> + return vcpu->arch.perf_capabilities; >> +} >> + >> void kvm_pmu_deliver_pmi(struct kvm_vcpu *vcpu); > [ ... ] >> diff --git a/arch/x86/kvm/vmx/pmu_intel.h b/arch/x86/kvm/vmx/pmu_intel.h >> index 5d9357640aa18..dd447d8b6fdde 100644 >> --- a/arch/x86/kvm/vmx/pmu_intel.h >> +++ b/arch/x86/kvm/vmx/pmu_intel.h >> @@ -4,19 +4,9 @@ >> >> #include <linux/kvm_host.h> >> >> -#include "cpuid.h" >> - >> -static inline u64 vcpu_get_perf_capabilities(struct kvm_vcpu *vcpu) >> -{ >> - if (!guest_cpu_cap_has(vcpu, X86_FEATURE_PDCM)) >> - return 0; >> - >> - return vcpu->arch.perf_capabilities; >> -} >> - >> static inline bool fw_writes_is_enabled(struct kvm_vcpu *vcpu) >> { >> - return (vcpu_get_perf_capabilities(vcpu) & PERF_CAP_FW_WRITES) != 0; >> + return (kvm_vcpu_get_perf_caps(vcpu) & PERF_CAP_FW_WRITES) != 0; > > [Severity: Low] > Should pmu_intel.h include pmu.h? It calls kvm_vcpu_get_perf_caps() which > is now defined in pmu.h, but the include appears to be missing. > >> } >> >> bool intel_pmu_lbr_is_enabled(struct kvm_vcpu *vcpu); >