]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: selftests: Add infrastructure for getting vCPU binary stats
authorSean Christopherson <seanjc@google.com>
Sat, 11 Jan 2025 00:50:48 +0000 (16:50 -0800)
committerSean Christopherson <seanjc@google.com>
Fri, 14 Feb 2025 15:02:13 +0000 (07:02 -0800)
commit16fc7cb406a5108182852229abe6804ecbad8d06
treee5880e508b34e3acbb3416afbe093b0739a31d70
parent9b56532b8a593c3a3cbbd8b17fb87ffb4beee436
KVM: selftests: Add infrastructure for getting vCPU binary stats

Now that the binary stats cache infrastructure is largely scope agnostic,
add support for vCPU-scoped stats.  Like VM stats, open and cache the
stats FD when the vCPU is created so that it's guaranteed to be valid when
vcpu_get_stats() is invoked.

Account for the extra per-vCPU file descriptor in kvm_set_files_rlimit(),
so that tests that create large VMs don't run afoul of resource limits.

To sanity check that the infrastructure actually works, and to get a bit
of bonus coverage, add an assert in x86's xapic_ipi_test to verify that
the number of HLTs executed by the test matches the number of HLT exits
observed by KVM.

Tested-by: Manali Shukla <Manali.Shukla@amd.com>
Link: https://lore.kernel.org/r/20250111005049.1247555-9-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/include/kvm_util.h
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/x86/xapic_ipi_test.c