On Wed, Oct 11, 2023, Peter Zijlstra wrote: > On Wed, Oct 04, 2023 at 02:50:46PM -0700, Sean Christopherson wrote: > > > Thinking about this more, what if we do a blend of KVM's FPU swapping and debug > > register swapping? > > > > A. Load guest PMU state in vcpu_enter_guest() after IRQs are disabled > > B. Put guest PMU state (and load host state) in vcpu_enter_guest() before IRQs > > are enabled, *if and only if* the current CPU has one or perf events that > > wants to use the hardware PMU > > C. Put guest PMU state at vcpu_put() > > D. Add a perf callback that is invoked from IRQ context when perf wants to > > configure a new PMU-based events, *before* actually programming the MSRs, > > and have KVM's callback put the guest PMU state > > > > No real objection, but I would suggest arriving at that solution by > first building the simple-stupid thing and then making it more > complicated in additinoal patches. Hmm? Yeah, for sure.