linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] KVM: x86/pmu: Fix some corner cases including Intel PEBS
@ 2022-07-13 12:24 Like Xu
  2022-07-13 12:25 ` [PATCH 1/7] perf/x86/core: Update x86_pmu.pebs_capable for ICELAKE_{X,D} Like Xu
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Like Xu @ 2022-07-13 12:24 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: Jim Mattson, linux-kernel, kvm, Like Xu

Good well-designed tests can help us find more bugs, especially when
the test steps differ from the Linux kernel behaviour in terms of the
timing of access to virtualized hw resources.

A new guest PEBS kvm-unit-test constructs a number of typical and
corner use cases to demonstrate how fragile the earlier PEBS
enabling patch set is. I prefer to reveal these flaws and fix them
myself before we receive complaints from projects that rely on it.

In this patch series, there is one small optimization (006), one hardware
surprise (002), and most of these fixes have stepped on my little toes.

Please feel free to add more tests or share comments.

Like Xu (7):
  perf/x86/core: Update x86_pmu.pebs_capable for ICELAKE_{X,D}
  perf/x86/core: Completely disable guest PEBS via guest's global_ctrl
  KVM: x86/pmu: Avoid setting BIT_ULL(-1) to pmu->host_cross_mapped_mask
  KVM: x86/pmu: Not to generate PEBS records for emulated instructions
  KVM: x86/pmu: Avoid using PEBS perf_events for normal counters
  KVM: x86/pmu: Defer reprogram_counter() to kvm_pmu_handle_event()
  KVM: x86/pmu: Defer counter emulated overflow via pmc->stale_counter

 arch/x86/events/intel/core.c    |  4 ++-
 arch/x86/include/asm/kvm_host.h |  5 ++--
 arch/x86/kvm/pmu.c              | 43 +++++++++++++++++++++------------
 arch/x86/kvm/svm/pmu.c          |  2 +-
 arch/x86/kvm/vmx/pmu_intel.c    | 29 +++++++++++-----------
 5 files changed, 49 insertions(+), 34 deletions(-)

-- 
2.37.0


^ permalink raw reply	[flat|nested] 17+ messages in thread
* [PATCH v2 0/7] KVM: x86/pmu: Fix some corner cases including Intel PEBS
@ 2022-07-21 10:35 Like Xu
  2022-07-21 10:35 ` [kvm-unit-tests PATCH] x86: Add tests for Guest Processor Event Based Sampling (PEBS) Like Xu
  0 siblings, 1 reply; 17+ messages in thread
From: Like Xu @ 2022-07-21 10:35 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson; +Cc: Jim Mattson, linux-kernel, kvm

Good well-designed tests can help us find more bugs, especially when
the test steps differ from the Linux kernel behaviour in terms of the
timing of access to virtualized hw resources.

A new guest PEBS kvm-unit-test constructs a number of typical and
corner use cases to demonstrate how fragile the earlier PEBS
enabling patch set is. I prefer to reveal these flaws and fix them
myself before we receive complaints from projects that rely on it.

In this patch series, there is one small optimization (006), one hardware
surprise (002), and most of these fixes have stepped on my little toes.

Please feel free to run tests, add more or share comments.

Previous:
https://lore.kernel.org/kvm/20220713122507.29236-1-likexu@tencent.com/

V1 -> V2 Changelog:
- For 3/7, use "hw_idx > -1" and add comment; (Sean)
- For 4/7, refine commit message and add comment; (Sean)
- For 6/7, inline reprogram_counter() and restrict pmc->current_config;

Like Xu (7):
  perf/x86/core: Update x86_pmu.pebs_capable for ICELAKE_{X,D}
  perf/x86/core: Completely disable guest PEBS via guest's global_ctrl
  KVM: x86/pmu: Avoid setting BIT_ULL(-1) to pmu->host_cross_mapped_mask
  KVM: x86/pmu: Don't generate PEBS records for emulated instructions
  KVM: x86/pmu: Avoid using PEBS perf_events for normal counters
  KVM: x86/pmu: Defer reprogram_counter() to kvm_pmu_handle_event()
  KVM: x86/pmu: Defer counter emulated overflow via pmc->stale_counter

 arch/x86/events/intel/core.c    |  4 ++-
 arch/x86/include/asm/kvm_host.h |  6 +++--
 arch/x86/kvm/pmu.c              | 47 +++++++++++++++++++++------------
 arch/x86/kvm/pmu.h              |  6 ++++-
 arch/x86/kvm/svm/pmu.c          |  2 +-
 arch/x86/kvm/vmx/pmu_intel.c    | 30 ++++++++++-----------
 6 files changed, 58 insertions(+), 37 deletions(-)

-- 
2.37.1


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

end of thread, other threads:[~2022-07-28 11:32 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-13 12:24 [PATCH 0/7] KVM: x86/pmu: Fix some corner cases including Intel PEBS Like Xu
2022-07-13 12:25 ` [PATCH 1/7] perf/x86/core: Update x86_pmu.pebs_capable for ICELAKE_{X,D} Like Xu
2022-07-13 12:25 ` [PATCH 2/7] perf/x86/core: Completely disable guest PEBS via guest's global_ctrl Like Xu
2022-07-13 12:25 ` [PATCH 3/7] KVM: x86/pmu: Avoid setting BIT_ULL(-1) to pmu->host_cross_mapped_mask Like Xu
2022-07-21  0:45   ` Sean Christopherson
2022-07-21  2:02     ` Like Xu
2022-07-21 18:27       ` Sean Christopherson
2022-07-13 12:25 ` [PATCH 4/7] KVM: x86/pmu: Not to generate PEBS records for emulated instructions Like Xu
2022-07-21  0:51   ` Sean Christopherson
2022-07-21  2:22     ` Like Xu
2022-07-13 12:25 ` [PATCH 5/7] KVM: x86/pmu: Avoid using PEBS perf_events for normal counters Like Xu
2022-07-13 12:25 ` [PATCH 6/7] KVM: x86/pmu: Defer reprogram_counter() to kvm_pmu_handle_event() Like Xu
2022-07-13 12:25 ` [PATCH 7/7] KVM: x86/pmu: Defer counter emulated overflow via pmc->stale_counter Like Xu
2022-07-13 12:25 ` [kvm-unit-tests PATCH] x86: Add tests for Guest Processor Event Based Sampling (PEBS) Like Xu
  -- strict thread matches above, loose matches on Subject: below --
2022-07-21 10:35 [PATCH v2 0/7] KVM: x86/pmu: Fix some corner cases including Intel PEBS Like Xu
2022-07-21 10:35 ` [kvm-unit-tests PATCH] x86: Add tests for Guest Processor Event Based Sampling (PEBS) Like Xu
2022-07-27 22:42   ` Sean Christopherson
2022-07-28 11:31     ` Like Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).