Skip to content

x86/pmu: Test case optimization, fixes and additions

Like Xu kvm 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest24 patches 10 repliesIn review
  2. v313 patches 25 repliesSuperseded
  3. v25 patches 0 repliesSuperseded

Changes in v4 from the cover letter

- Add more helpers to the new lib/x86/pmu.h and lib/x86/pmu.c; (pmu_cap, perf_capabilities other pmu related stuff)
- Refine commit message and report_ messages;
- Code style fixes (curly braces, #defeine, GENMASK_ULL, ternary operator);
- Add more message for "the expected init cnt.count for fixed counter 0" (measure_for_overflow() is applied);
- Rename PC_VECTOR to PMI_VECTOR;
- Snapshot pebs_has_baseline() to avoid RDMSR on every touch;
- Drop the idea about is_the_count_reproducible() for AMD;
- Add X86_FEATURE_* in the KUT world;

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/24x86/pmu: Add PDCM check before accessing PERF_CAP registerlib/x86/processor.h x86/pmu.c x86/pmu_lbr.c+10 -20 replies
2/24x86/pmu: Test emulation instructions on full-width countersx86/pmu.c+3 -30 replies
3/24x86/pmu: Pop up FW prefix to avoid out-of-context propagationx86/pmu.c+1 -00 replies
4/24x86/pmu: Report SKIP when testing Intel LBR on AMD platformsx86/pmu_lbr.c+1 -10 replies
5/24x86/pmu: Fix printed messages for emulated instruction testx86/pmu.c+2 -20 replies
6/24x86/pmu: Introduce __start_event() to drop all of the manual zeroingx86/pmu.c+16 -151 reply
7/24x86/pmu: Introduce multiple_{one, many}() to improve readabilityx86/pmu.c+10 -50 replies
8/24x86/pmu: Reset the expected count of the fixed counter 0 when i386x86/pmu.c+18 -40 replies
9/24x86: create pmu group for quick pmu-scope testingx86/unittests.cfg+2 -00 replies
10/24x86/pmu: Refine info to clarify the current supportx86/pmu.c+1 -10 replies
11/24x86/pmu: Update rdpmc testcase to cover #GP pathlib/x86/processor.h x86/pmu.c+28 -31 reply
12/24x86/pmu: Rename PC_VECTOR to PMI_VECTOR for better readabilityx86/pmu.c+6 -40 replies
13/24x86/pmu: Add lib/x86/pmu.[c.h] and move common code to header fileslib/x86/msr.h lib/x86/pmu.c lib/x86/pmu.h +5 more+112 -980 replies
14/24x86/pmu: Read cpuid(10) in the pmu_init() to reduce VM-Exitlib/x86/pmu.c lib/x86/pmu.h lib/x86/smp.c+22 -131 reply
15/24x86/pmu: Initialize PMU perf_capabilities at pmu_init()lib/x86/pmu.c lib/x86/pmu.h x86/pmu.c +1 more+21 -91 reply
16/24x86/pmu: Add GP counter related helperslib/x86/pmu.c lib/x86/pmu.h x86/pmu.c+73 -261 reply
17/24x86/pmu: Add GP/Fixed counters reset helperslib/x86/pmu.c lib/x86/pmu.h x86/pmu.c+40 -11 reply
18/24x86/pmu: Add a set of helpers related to global registerslib/x86/pmu.c lib/x86/pmu.h x86/pmu.c+49 -181 reply
19/24x86: Add tests for Guest Processor Event Based Sampling (PEBS)lib/x86/msr.h lib/x86/pmu.h x86/Makefile.x86_64 +2 more+472 -00 replies
20/24x86/pmu: Add global helpers to cover Intel Arch PMU Version 1lib/x86/pmu.c lib/x86/pmu.h x86/pmu.c+41 -190 replies
21/24x86/pmu: Add gp_events pointer to route different event tablesx86/pmu.c+12 -70 replies
22/24x86/pmu: Add nr_gp_counters to limit the number of test counterslib/x86/pmu.c lib/x86/pmu.h+9 -10 replies
23/24x86/pmu: Update testcases to cover AMD PMUlib/x86/msr.h lib/x86/pmu.c lib/x86/pmu.h +2 more+117 -232 replies
24/24x86/pmu: Add AMD Guest PerfMonV2 testcaseslib/x86/msr.h lib/x86/pmu.c lib/x86/pmu.h +1 more+19 -30 replies

Reviews trailers per patch

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

PatchSean ChristophersonSandipan Das
1/24
2/24
3/24R-b
4/24R-b
5/24
6/24
7/24
8/24
9/24R-b
10/24
11/24
12/24
13/24
14/24
15/24
16/24
17/24
18/24
19/24
20/24
21/24
22/24
23/24R-b
24/24

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

Read the v4 thread

Cover letter [kvm-unit-tests PATCH v4 00/24] x86/pmu: Test case optimization, fixes and additions

The patch set includes all the changes on my side (SPR PEBS and AMD PerfMonV2 are included, except for Arch lbr), which helps to keep the review time focused.

There are no major changes in the test logic. A considerable number of helpers have been added to lib/x86/pmu.[c,h], which really helps the readability of the code, while hiding some hardware differentiation details.

These are divided into three parts, the first part (01 - 08) is bug fixing, the second part (09 - 18) is code refactoring, and the third part is the addition of new test cases. It may also be good to split up and merge in sequence. They get passed on AMD Zen3/4, Intel ICX/SPR machines.

Please feel free to test them in your own CI environment.

v3: https://lore.kernel.org/kvm/[email protected]/
v3 -> v4 Changelog:
- Add more helpers to the new lib/x86/pmu.h and lib/x86/pmu.c; (pmu_cap, perf_capabilities other pmu related stuff)
- Refine commit message and report_ messages;
- Code style fixes (curly braces, #defeine, GENMASK_ULL, ternary operator);
- Add more message for "the expected init cnt.count for fixed counter 0" (measure_for_overflow() is applied);
- Rename PC_VECTOR to PMI_VECTOR;
- Snapshot pebs_has_baseline() to avoid RDMSR on every touch;
- Drop the idea about is_the_count_reproducible() for AMD;
- Add X86_FEATURE_* in the KUT world;

Like Xu (24):
x86/pmu: Add PDCM check before accessing PERF_CAP register x86/pmu: Test emulation instructions on full-width counters x86/pmu: Pop up FW prefix to avoid out-of-context propagation x86/pmu: Report SKIP when testing Intel LBR on AMD platforms x86/pmu: Fix printed messages for emulated instruction test x86/pmu: Introduce __start_event() to drop all of the manual zeroing x86/pmu: Introduce multiple_{one, many}() to improve readability x86/pmu: Reset the expected count of the fixed counter 0 when i386
x86: create pmu group for quick pmu-scope testing x86/pmu: Refine info to clarify the current support x86/pmu: Update rdpmc testcase to cover #GP path
x86/pmu: Rename PC_VECTOR to PMI_VECTOR for better readability x86/pmu: Add lib/x86/pmu.[c.h] and move common code to header files x86/pmu: Read cpuid(10) in the pmu_init() to reduce VM-Exit x86/pmu: Initialize PMU perf_capabilities at pmu_init() x86/pmu: Add GP counter related helpers
x86/pmu: Add GP/Fixed counters reset helpers
x86/pmu: Add a set of helpers related to global registers
x86: Add tests for Guest Processor Event Based Sampling (PEBS) x86/pmu: Add global helpers to cover Intel Arch PMU Version 1 x86/pmu: Add gp_events pointer to route different event tables x86/pmu: Add nr_gp_counters to limit the number of test counters x86/pmu: Update testcases to cover AMD PMU
x86/pmu: Add AMD Guest PerfMonV2 testcases

 lib/x86/msr.h       |  30 +++
 lib/x86/pmu.c       |  36 ++++
 lib/x86/pmu.h       | 306 +++++++++++++++++++++++++++++++
 lib/x86/processor.h |  80 ++------
 lib/x86/smp.c       |   2 +
 x86/Makefile.common |   1 +
 x86/Makefile.x86_64 |   1 +
 x86/pmu.c           | 297 ++++++++++++++++++------------
 x86/pmu_lbr.c       |  20 +-
 x86/pmu_pebs.c      | 433 ++++++++++++++++++++++++++++++++++++++++++++
 x86/unittests.cfg   |  10 +
 x86/vmx_tests.c     |   1 +
 12 files changed, 1022 insertions(+), 195 deletions(-)
 create mode 100644 lib/x86/pmu.c
 create mode 100644 lib/x86/pmu.h
 create mode 100644 x86/pmu_pebs.c
Signature · 1 line
2.38.1