[PATCH v3 0/2] KVM: selftests: Reduce PMC test runtime by ~17x

Sean Christopherson posted 2 patches 1 month, 4 weeks ago
.../testing/selftests/kvm/include/test_util.h |   4 +-
tools/testing/selftests/kvm/lib/test_util.c   |  22 +-
.../selftests/kvm/x86/pmu_counters_test.c     | 229 ++++++++++--------
3 files changed, 149 insertions(+), 106 deletions(-)
[PATCH v3 0/2] KVM: selftests: Reduce PMC test runtime by ~17x
Posted by Sean Christopherson 1 month, 4 weeks ago
Reduce the runtime of the PMU counters test on an Emerald Rapids system from
~85 seconds to ~5 seconds by (a) testing one random GP counter in the arch
events test instead of every GP counter and (b) creating one large VM per
"major" test and then running each subtest with a different vCPUs, versus
creating a new single-vCPU VM for every subtest.

AFAICT, there aren't any bugs anywhere in the VM creation flow, there's just
a lot of work to be done.  And VM creation isn't even that slow, but creating
something like 1000+ VMs for the test adds up.

v3:
 - Allocate an array of vCPU pointers, not an array of vCPUs. [Sashiko]
 - Fix a copy+paste goof that caused the GP counters test to always run with
   the maximum number of GP counters. [Sashiko]
 - Fix a (benign) off-by-one error in the arch events tests. [Sashiko]

v2:
 - Fail hard.  Pretend this version doesn't exist.
 - https://lore.kernel.org/all/20260804204048.3401810-1-seanjc@google.com

v1: https://lore.kernel.org/all/20260804173437.3339269-1-seanjc@google.com


Sean Christopherson (2):
  KVM: selftests: Test one random GP counter in PMU arch events testcase
  KVM: selftests: Create one VM with many vCPUs for each major PMU
    counters test

 .../testing/selftests/kvm/include/test_util.h |   4 +-
 tools/testing/selftests/kvm/lib/test_util.c   |  22 +-
 .../selftests/kvm/x86/pmu_counters_test.c     | 229 ++++++++++--------
 3 files changed, 149 insertions(+), 106 deletions(-)


base-commit: 2dfab80a305700a45bd947350dae253ba4e30c41
-- 
2.55.0.571.g244d577d93-goog
Re: [PATCH v3 0/2] KVM: selftests: Reduce PMC test runtime by ~17x
Posted by Sean Christopherson 1 month, 3 weeks ago
On Tue, 04 Aug 2026 14:00:44 -0700, Sean Christopherson wrote:
> Reduce the runtime of the PMU counters test on an Emerald Rapids system from
> ~85 seconds to ~5 seconds by (a) testing one random GP counter in the arch
> events test instead of every GP counter and (b) creating one large VM per
> "major" test and then running each subtest with a different vCPUs, versus
> creating a new single-vCPU VM for every subtest.
> 
> AFAICT, there aren't any bugs anywhere in the VM creation flow, there's just
> a lot of work to be done.  And VM creation isn't even that slow, but creating
> something like 1000+ VMs for the test adds up.
> 
> [...]

Applied to kvm-x86 selftests2, thanks!

[1/2] KVM: selftests: Test one random GP counter in PMU arch events testcase
      https://github.com/kvm-x86/linux/commit/a53d1602e3bf
[2/2] KVM: selftests: Create one VM with many vCPUs for each major PMU counters test
      https://github.com/kvm-x86/linux/commit/f6e01d4fa1e8

--
https://github.com/kvm-x86/linux/tree/next
Re: [PATCH v3 0/2] KVM: selftests: Reduce PMC test runtime by ~17x
Posted by Sean Christopherson 1 month, 3 weeks ago
On Fri, Aug 07, 2026, Sean Christopherson wrote:
> On Tue, 04 Aug 2026 14:00:44 -0700, Sean Christopherson wrote:
> > Reduce the runtime of the PMU counters test on an Emerald Rapids system from
> > ~85 seconds to ~5 seconds by (a) testing one random GP counter in the arch
> > events test instead of every GP counter and (b) creating one large VM per
> > "major" test and then running each subtest with a different vCPUs, versus
> > creating a new single-vCPU VM for every subtest.
> > 
> > AFAICT, there aren't any bugs anywhere in the VM creation flow, there's just
> > a lot of work to be done.  And VM creation isn't even that slow, but creating
> > something like 1000+ VMs for the test adds up.
> > 
> > [...]
> 
> Applied to kvm-x86 selftests2, thanks!
> 
> [1/2] KVM: selftests: Test one random GP counter in PMU arch events testcase
>       https://github.com/kvm-x86/linux/commit/a53d1602e3bf
> [2/2] KVM: selftests: Create one VM with many vCPUs for each major PMU counters test
>       https://github.com/kvm-x86/linux/commit/f6e01d4fa1e8

Squashed a fixup for patch 2.  I meant to drop the unused perf_capabilities param
reported by Sashiko, but forgot to do so when applying.  New hash:

[2/2] KVM: selftests: Create one VM with many vCPUs for each major PMU counters test
      https://github.com/kvm-x86/linux/commit/4fe8b4e1545a