All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] KVM: x86/pmu: Count two basic events for emulated instructions
@ 2021-11-30  7:42 Like Xu
  2021-11-30  7:42 ` [PATCH v2 1/6] KVM: x86/pmu: Setup pmc->eventsel for fixed PMCs Like Xu
                   ` (6 more replies)
  0 siblings, 7 replies; 45+ messages in thread
From: Like Xu @ 2021-11-30  7:42 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, kvm, linux-kernel, Like Xu

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/20211112235235.1125060-2-jmattson@google.com/

[1] https://lore.kernel.org/kvm/20211119064856.77948-1-likexu@tencent.com/

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(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2022-02-16 11:25 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30  7:42 [PATCH v2 0/6] KVM: x86/pmu: Count two basic events for emulated instructions Like Xu
2021-11-30  7:42 ` [PATCH v2 1/6] KVM: x86/pmu: Setup pmc->eventsel for fixed PMCs Like Xu
2021-12-06 19:57   ` Jim Mattson
2021-12-09 18:49     ` Paolo Bonzini
2021-12-09 18:53       ` Jim Mattson
2021-12-09 18:57         ` Paolo Bonzini
2021-12-10 10:20       ` Like Xu
     [not found]   ` <CALMp9eTq8H_bJOVKwi_7j3Kum9RvW6o-G3zCLUFco1A1cvNrkQ@mail.gmail.com>
2021-12-07  6:07     ` Like Xu
2021-12-07 17:42       ` Jim Mattson
2021-11-30  7:42 ` [PATCH v2 2/6] KVM: x86/pmu: Refactoring find_arch_event() to pmc_perf_hw_id() Like Xu
2021-12-09  3:52   ` Jim Mattson
2021-12-09  8:11     ` Like Xu
2021-12-09 19:24     ` Paolo Bonzini
2022-02-05  1:55   ` Jim Mattson
2022-02-09  9:00     ` Like Xu
2022-02-09 19:30       ` Jim Mattson
2022-02-10 11:28         ` Like Xu
2022-02-11  9:56           ` Ravi Bangoria
2022-02-11 18:16             ` Jim Mattson
2022-02-14 10:14               ` Ravi Bangoria
2022-02-16  7:44                 ` Like Xu
2022-02-16 11:24                   ` Ravi Bangoria
2021-11-30  7:42 ` [PATCH v2 3/6] KVM: x86/pmu: Reuse pmc_perf_hw_id() and drop find_fixed_event() Like Xu
2021-12-09  3:58   ` Jim Mattson
2021-11-30  7:42 ` [PATCH v2 4/6] KVM: x86/pmu: Add pmc->intr to refactor kvm_perf_overflow{_intr}() Like Xu
2021-12-09  4:25   ` Jim Mattson
2021-12-09  8:28     ` Like Xu
2021-12-10  0:54       ` Jim Mattson
2021-12-10  9:35         ` Paolo Bonzini
2021-12-10 10:11           ` Like Xu
2021-12-10 22:55           ` Jim Mattson
2021-12-10 22:59             ` Paolo Bonzini
2021-12-10 23:31               ` Jim Mattson
2021-12-12  4:56                 ` Jim Mattson
2021-12-13  6:37                   ` Jim Mattson
2021-12-16  9:57                     ` Like Xu
2021-12-16 17:52                       ` Jim Mattson
2021-11-30  7:42 ` [PATCH v2 5/6] KVM: x86: Update vPMCs when retiring instructions Like Xu
2021-12-09  4:33   ` Jim Mattson
2021-12-09  8:44     ` Like Xu
2021-12-09  9:23       ` Like Xu
2021-11-30  7:42 ` [PATCH v2 6/6] KVM: x86: Update vPMCs when retiring branch instructions Like Xu
2021-12-09  4:40   ` Jim Mattson
2021-12-09 19:30 ` [PATCH v2 0/6] KVM: x86/pmu: Count two basic events for emulated instructions Paolo Bonzini
2021-12-16 10:14   ` Like Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.