Skip to content

KVM: x86/pmu: Count two basic events for emulated instructions

Like Xu kvm linux-perf-users lkml 3 versions – Applied

Status from this message: Queued patches 1-4, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest posting 2/26 patches 38 repliesApplied
  2. v2 posting 1/24 patches 0 repliesSuperseded
  3. v14 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- Include the patch set [1] and drop the intel_find_fixed_event(); [Paolo] (we will fix the misleading Intel CPUID events in another patch set)
- Drop checks for pmc->perf_event or event state or event type;
- Increase a counter once its umask bits and the first 8 select bits are matched;
- Rewrite kvm_pmu_incr_counter() with a less invasive approach to the host perf;
- Rename kvm_pmu_record_event to kvm_pmu_trigger_event;
- Add counter enable check for kvm_pmu_trigger_event();
- Add vcpu CPL check for kvm_pmu_trigger_event(); [Jim]

Patches in v2 posting 2/2 Applied

#Subject and filesSizeRepliesApplied
1/6KVM: x86/pmu: Setup pmc->eventsel for fixed PMCsarch/x86/kvm/vmx/pmu_intel.c+16 -07 replies
2/6KVM: x86/pmu: Refactoring find_arch_event() to pmc_perf_hw_id()arch/x86/kvm/pmu.c arch/x86/kvm/pmu.h arch/x86/kvm/svm/pmu.c +1 more+11 -1712 replies
3/6KVM: x86/pmu: Reuse pmc_perf_hw_id() and drop find_fixed_event()arch/x86/kvm/pmu.c arch/x86/kvm/pmu.h arch/x86/kvm/svm/pmu.c +1 more+8 -251 reply
4/6KVM: x86/pmu: Add pmc->intr to refactor kvm_perf_overflow{_intr}()arch/x86/include/asm/kvm_host.h arch/x86/kvm/pmu.c+29 -3012 replies
5/6KVM: x86: Update vPMCs when retiring instructionsarch/x86/kvm/pmu.c arch/x86/kvm/pmu.h arch/x86/kvm/x86.c+64 -03 replies
6/6KVM: x86: Update vPMCs when retiring branch instructionsarch/x86/kvm/emulate.c arch/x86/kvm/kvm_emulate.h arch/x86/kvm/vmx/nested.c +1 more+39 -261 reply

Reviews trailers per patch

4 of 6 patches have a Reviewed-by or Acked-by.

PatchJim Mattson
1/6
2/6R-b
3/6R-b
4/6R-b
5/6
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/6] KVM: x86/pmu: Count two basic events for emulated instructions

Hi,

[ Jim is on holiday, so I'm here to continue this work. ]

Some cloud customers need accurate virtualization of two basic PMU events on x86 hardware: "instructions retired" and "branch instructions retired". The existing PMU virtualization code fails to account for instructions (e.g, CPUID) that are emulated by KVM.

Accurately virtualizing all PMU events for all microarchitectures is a herculean task, let's just stick to the two events covered by this set.

Eric Hankland wrote this code originally, but his plate is full, so Jim and I volunteered to shepherd the changes through upstream acceptance.

Thanks,

v1 -> v2 Changelog:
- Include the patch set [1] and drop the intel_find_fixed_event(); [Paolo] (we will fix the misleading Intel CPUID events in another patch set)
- Drop checks for pmc->perf_event or event state or event type;
- Increase a counter once its umask bits and the first 8 select bits are matched;
- Rewrite kvm_pmu_incr_counter() with a less invasive approach to the host perf;
- Rename kvm_pmu_record_event to kvm_pmu_trigger_event;
- Add counter enable check for kvm_pmu_trigger_event();
- Add vcpu CPL check for kvm_pmu_trigger_event(); [Jim]

Previous:
https://lore.kernel.org/kvm/[email protected]/

[1] https://lore.kernel.org/kvm/[email protected]/

Jim Mattson (1):
KVM: x86: Update vPMCs when retiring branch instructions

Like Xu (5):
KVM: x86/pmu: Setup pmc->eventsel for fixed PMCs
KVM: x86/pmu: Refactoring find_arch_event() to pmc_perf_hw_id()
KVM: x86/pmu: Reuse pmc_perf_hw_id() and drop find_fixed_event()
KVM: x86/pmu: Add pmc->intr to refactor kvm_perf_overflow{_intr}()
KVM: x86: Update vPMCs when retiring instructions

 arch/x86/include/asm/kvm_host.h |   1 +
 arch/x86/kvm/emulate.c          |  55 ++++++++------
 arch/x86/kvm/kvm_emulate.h      |   1 +
 arch/x86/kvm/pmu.c              | 128 ++++++++++++++++++++++----------
 arch/x86/kvm/pmu.h              |   5 +-
 arch/x86/kvm/svm/pmu.c          |  19 ++---
 arch/x86/kvm/vmx/nested.c       |   7 +-
 arch/x86/kvm/vmx/pmu_intel.c    |  44 ++++++-----
 arch/x86/kvm/x86.c              |   5 ++
 9 files changed, 167 insertions(+), 98 deletions(-)
Signature · 1 line
2.33.1