KVM: x86/pmu: Stop calling kvm_pmu_reset() at RESET (it's redundant)
authorSean Christopherson <seanjc@google.com>
Fri, 3 Nov 2023 23:05:38 +0000 (16:05 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 30 Nov 2023 20:52:54 +0000 (12:52 -0800)
Drop kvm_vcpu_reset()'s call to kvm_pmu_reset(), the call is performed
only for RESET, which is really just the same thing as vCPU creation,
and kvm_arch_vcpu_create() *just* called kvm_pmu_init(), i.e. there can't
possibly be any work to do.

Unlike Intel, AMD's amd_pmu_refresh() does fill all_valid_pmc_idx even if
guest CPUID is empty, but everything that is at all dynamic is guaranteed
to be '0'/NULL, e.g. it should be impossible for KVM to have already
created a perf event.

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

index dc8e8e907cfbfbc0013fde4f3ad67842c74cc5b5..458e836c6efee0639866679adb5d49e6a286ae35 100644 (file)
@@ -657,7 +657,7 @@ int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
        return 0;
 }
 
-void kvm_pmu_reset(struct kvm_vcpu *vcpu)
+static void kvm_pmu_reset(struct kvm_vcpu *vcpu)
 {
        struct kvm_pmu *pmu = vcpu_to_pmu(vcpu);
        struct kvm_pmc *pmc;
index a46aa9b25150f5a034839a7b99123c5e96b97f9a..db9a12c0a2ef23badd61ee9f61fc91ff6d5ab9d8 100644 (file)
@@ -243,7 +243,6 @@ bool kvm_pmu_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr);
 int kvm_pmu_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info);
 int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info);
 void kvm_pmu_refresh(struct kvm_vcpu *vcpu);
-void kvm_pmu_reset(struct kvm_vcpu *vcpu);
 void kvm_pmu_init(struct kvm_vcpu *vcpu);
 void kvm_pmu_cleanup(struct kvm_vcpu *vcpu);
 void kvm_pmu_destroy(struct kvm_vcpu *vcpu);
index 6d0772b47041345119d0b69dbecaa952de0eb3fe..33c071cd95b2e4f91dc875126502acd1ad6d1414 100644 (file)
@@ -12221,7 +12221,6 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
        }
 
        if (!init_event) {
-               kvm_pmu_reset(vcpu);
                vcpu->arch.smbase = 0x30000;
 
                vcpu->arch.msr_misc_features_enables = 0;