Skip to content

KVM: x86/pmu: Optimize triggering of emulated events

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Applied to kvm-x86 pmu, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 4 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/10KVM: x86/pmu: Zero out PMU metadata on AMD if PMU is disabledarch/x86/kvm/pmu.c arch/x86/kvm/vmx/pmu_intel.c+20 -160 replies
2/10KVM: x86/pmu: Add common define to capture fixed counters offsetarch/x86/kvm/pmu.c arch/x86/kvm/pmu.h arch/x86/kvm/vmx/pmu_intel.c+13 -110 replies
3/10KVM: x86/pmu: Move pmc_idx => pmc translation helper to common codearch/x86/include/asm/kvm-x86-pmu-ops.h arch/x86/kvm/pmu.c arch/x86/kvm/pmu.h +2 more+36 -240 replies
4/10KVM: x86/pmu: Snapshot and clear reprogramming bitmap before reprogrammingarch/x86/include/asm/kvm_host.h arch/x86/kvm/pmu.c+30 -230 replies
5/10KVM: x86/pmu: Add macros to iterate over all PMCs given a bitmaparch/x86/kvm/pmu.c arch/x86/kvm/pmu.h arch/x86/kvm/vmx/pmu_intel.c+15 -240 replies
6/10KVM: x86/pmu: Process only enabled PMCs when emulating events in softwarearch/x86/kvm/pmu.c+10 -10 replies
7/10KVM: x86/pmu: Snapshot event selectors that KVM emulates in softwarearch/x86/kvm/pmu.c arch/x86/kvm/pmu.h arch/x86/kvm/vmx/nested.c +1 more+24 -140 replies
8/10KVM: x86/pmu: Expand the comment about what bits are check emulating eventsarch/x86/kvm/pmu.c+14 -10 replies
9/10KVM: x86/pmu: Check eventsel first when emulating (branch) insns retiredarch/x86/kvm/pmu.c+3 -60 replies
10/10KVM: x86/pmu: Avoid CPL lookup if PMC enabline for USER and KERNEL is the samearch/x86/kvm/pmu.c+7 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/10] KVM: x86/pmu: Optimize triggering of emulated events

Optimize code used by, or which impacts, kvm_pmu_trigger_event() to try and make a dent in the overhead of emulating PMU events in software, which is quite noticeable due to it kicking in anytime the guest has a vPMU and KVM is skipping an instruction.

Note, Jim has a proposal/idea[*] (that I supported) to make kvm_pmu_trigger_event() even more performant. I opted not to do that as it's a bit more invasive, and I started chewing on this not so much because I care _that_ much about performance, but because it irritates me that the PMU code makes things way harder than they need to be.

Note #2, this applies on top of my other two PMU series:

https://lore.kernel.org/all/[email protected]
https://lore.kernel.org/all/[email protected]

Those series fix actual functional issues, i.e. I'll definitely apply them first (there's definitely no rush on this one).

[*] https://lore.kernel.org/all/CALMp9eQGqqo66fQGwFJMc3y+9XdUrL7ageE8kvoAOV6NJGfJpw@mail.gmail.com

Sean Christopherson (10):
KVM: x86/pmu: Zero out PMU metadata on AMD if PMU is disabled
KVM: x86/pmu: Add common define to capture fixed counters offset
KVM: x86/pmu: Move pmc_idx => pmc translation helper to common code
KVM: x86/pmu: Snapshot and clear reprogramming bitmap before
reprogramming
KVM: x86/pmu: Add macros to iterate over all PMCs given a bitmap
KVM: x86/pmu: Process only enabled PMCs when emulating events in
software
KVM: x86/pmu: Snapshot event selectors that KVM emulates in software
KVM: x86/pmu: Expand the comment about what bits are check emulating
events
KVM: x86/pmu: Check eventsel first when emulating (branch) insns
retired
KVM: x86/pmu: Avoid CPL lookup if PMC enabline for USER and KERNEL is
the same

 arch/x86/include/asm/kvm-x86-pmu-ops.h |   1 -
 arch/x86/include/asm/kvm_host.h        |   1 +
 arch/x86/kvm/pmu.c                     | 143 +++++++++++++++----------
 arch/x86/kvm/pmu.h                     |  52 ++++++++-
 arch/x86/kvm/svm/pmu.c                 |   7 +-
 arch/x86/kvm/vmx/nested.c              |   2 +-
 arch/x86/kvm/vmx/pmu_intel.c           |  44 ++------
 arch/x86/kvm/x86.c                     |   6 +-
 8 files changed, 154 insertions(+), 102 deletions(-)

base-commit: ef1883475d4a24d8eaebb84175ed46206a688103

Signature · 1 line
2.42.0.869.gea05f2083d-goog