Re: [PATCH v3 2/2] KVM: selftests: Create one VM with many vCPUs for each major PMU counters test
Sean Christopherson <[email protected]> Tue, 4 Aug 2026 14:21:16 -0700
| Newsgroups | dev.linux.lists.sashiko-reviews,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 04, 2026, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: > > + pr_info("Testing arch events, PMU version %u, perf_caps = %lx\n", > > + pmu_version, perf_capabilities); > > + > > + /* Testing arch events requires a vPMU (there are no negative tests). */ > > + if (!pmu_version) > > + return; > > + > > + vm = pmu_vm_create_with_vcpus((NR_INTEL_ARCH_EVENTS + 2) * (ARRAY_SIZE(unavailable_masks) - 1), > > + guest_test_arch_events, pmu_version, > > + perf_capabilities, &vcpus); > > [Severity: Medium] > Could this cause the test to assert on hosts with lower vCPU limits? > > This calculation requests up to 144 vCPUs per VM ((14 + 2) * (10 - 1)). If the > host has a KVM_CAP_MAX_VCPUS limit lower than 144 (which is common in nested > virtualization or lightweight VMs), No, it's not. Unless userspace overwrites the VM's max vCPUs, KVM x86's *minimum* value for KVM_CAP_MAX_VCPUS is 1024. case KVM_CAP_MAX_VCPUS: r = KVM_MAX_VCPUS; if (kvm) r = kvm->max_vcpus; break; #ifdef CONFIG_KVM_MAX_NR_VCPUS #define KVM_MAX_VCPUS CONFIG_KVM_MAX_NR_VCPUS #else #define KVM_MAX_VCPUS 1024 #endif config KVM_MAX_NR_VCPUS int "Maximum number of vCPUs per KVM guest" depends on KVM_X86 range 1024 4096 default 4096 if MAXSMP default 1024 KVM_CAP_NR_VCPUS incorporates the number of CPUs in the system, but that's purely a "suggestion" for userspace. case KVM_CAP_NR_VCPUS: r = min_t(unsigned int, num_online_cpus(), KVM_MAX_VCPUS); break; > vm_create_with_vcpus() might fail with a hard assertion. > > Should this check against the host limit and either skip via TEST_REQUIRE() > or batch the creations into smaller groups of vCPUs?