Re: [PATCH v8 5/7] KVM: arm64: PMU: Implement fixed-counters-only emulation
From: Oliver Upton
Date: Tue Jul 07 2026 - 14:03:03 EST
On Tue, Jul 07, 2026 at 09:52:49PM +0900, Akihiko Odaki wrote:
> On 2026/07/07 20:23, Akihiko Odaki wrote:
> > On 2026/07/07 3:23, Oliver Upton wrote:
> > > Just detect the changing PMU implementation here, KVM_REQ_RELOAD_PMU
> > > will need to detect the PMCs that require an update anyway. Stash the
> > > last cpu in kvm_arch_vcpu_load() and pass it to this:
> > >
> > > void kvm_vcpu_load_pmu(struct kvm_vcpu *vcpu, int last_cpu)
> > > {
> > > if (!kvm_pmu_fixed_counters_only(vcpu->kvm) || vcpu->cpu == last_cpu)
> > > return;
> > >
> > > if (kvm_pmu_probe_armpmu(vcpu->cpu) !=
> > > kvm_pmu_probe_armpmu(last_cpu))
> > > kvm_make_request(KVM_REQ_RELOAD_PMU);
> > > }
> >
> > It is a nice way to simplify the code and to avoid hardcoding
> > ARMV8_PMU_INSTR_IDX. I'll use the code for the next version.
>
> I tried this but unfortunately it doesn't seem to work. kvm_arch_vcpu_put()
> sets vcpu->cpu to -1 so we cannot simply read it to get the last cpu in
> kvm_arch_vcpu_load().
Urgh, there's no reason for doing that any more. Let's fix it, I want a
straightforward way to detect pCPU migrations. There may be other
reasons for using it in the future.
Untested, but could you give this a whirl?