Re: [PATCH] KVM: vPMU: Don't program counter for interrupt-based event sampling w/o lapic_in_kernel

From: Paolo Bonzini
Date: Mon Oct 25 2021 - 12:45:05 EST


On 25/10/21 18:31, Sean Christopherson wrote:
vPMU depends on in-kernel lapic to deliver pmi interrupt, there is a
lot of overhead when creating/maintaining perf_event object,
locking/unlocking perf_event_ctx etc for vPMU. It silently fails to
deliver pmi interrupt if w/o in-kernel lapic currently. Let's not
program counter for interrupt-based event sampling w/o in-kernel
lapic support to avoid the whole bothering.

This feels all kinds of wrong. AFAIK, there's no way for KVM to enumerate to
the guest that the vPMU isn't capable of generating interrupts. I.e. any setup
that exposes a vPMU to the guest without an in-kernel local APIC is either
inherently broken or requires a paravirtualized guest. I don't think KVM's bugs
should be optimized.

Yeah, if it simplified the code it would be a different story, but here there's even not one but two new checks.

Paolo