public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: Don't fall over when only one CPU
@ 2025-10-07 19:12 Brendan Jackman
  2025-10-15 18:02 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Brendan Jackman @ 2025-10-07 19:12 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Shuah Khan
  Cc: kvm, linux-kselftest, linux-kernel, Brendan Jackman

Running this test on a system with only one CPU is not a recipe for
success. However, there's no clear-cut reason why it absolutely
shouldn't work, so the test shouldn't completely reject such a platform.

At present, the *3/4 calculation will return zero on these platforms and
the test fails. So, instead just skip that calculation.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 tools/testing/selftests/kvm/mmu_stress_test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/mmu_stress_test.c b/tools/testing/selftests/kvm/mmu_stress_test.c
index 6a437d2be9fa444b34c2a73308a9d1c7ff3cc4f5..b5bd6fbad32a9ad5247a52ecf811b29293763e2e 100644
--- a/tools/testing/selftests/kvm/mmu_stress_test.c
+++ b/tools/testing/selftests/kvm/mmu_stress_test.c
@@ -263,8 +263,10 @@ static void calc_default_nr_vcpus(void)
 	TEST_ASSERT(!r, "sched_getaffinity failed, errno = %d (%s)",
 		    errno, strerror(errno));
 
-	nr_vcpus = CPU_COUNT(&possible_mask) * 3/4;
+	nr_vcpus = CPU_COUNT(&possible_mask);
 	TEST_ASSERT(nr_vcpus > 0, "Uh, no CPUs?");
+	if (nr_vcpus >= 2)
+		nr_vcpus = nr_vcpus * 3/4;
 }
 
 int main(int argc, char *argv[])

---
base-commit: 6b36119b94d0b2bb8cea9d512017efafd461d6ac
change-id: 20251007-b4-kvm-mmu-stresstest-1proc-e6157c13787a

Best regards,
-- 
Brendan Jackman <jackmanb@google.com>


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

* Re: [PATCH] KVM: selftests: Don't fall over when only one CPU
  2025-10-07 19:12 [PATCH] KVM: selftests: Don't fall over when only one CPU Brendan Jackman
@ 2025-10-15 18:02 ` Sean Christopherson
  2025-10-20 16:32   ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2025-10-15 18:02 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, Shuah Khan, Brendan Jackman
  Cc: kvm, linux-kselftest, linux-kernel

On Tue, 07 Oct 2025 19:12:31 +0000, Brendan Jackman wrote:
> Running this test on a system with only one CPU is not a recipe for
> success. However, there's no clear-cut reason why it absolutely
> shouldn't work, so the test shouldn't completely reject such a platform.
> 
> At present, the *3/4 calculation will return zero on these platforms and
> the test fails. So, instead just skip that calculation.
> 
> [...]

Applied to kvm-x86 selftests, thanks!

[1/1] KVM: selftests: Don't fall over when only one CPU
      https://github.com/kvm-x86/linux/commit/98dea1b75186

--
https://github.com/kvm-x86/linux/tree/next

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

* Re: [PATCH] KVM: selftests: Don't fall over when only one CPU
  2025-10-15 18:02 ` Sean Christopherson
@ 2025-10-20 16:32   ` Sean Christopherson
  0 siblings, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2025-10-20 16:32 UTC (permalink / raw)
  To: Paolo Bonzini, Shuah Khan, Brendan Jackman
  Cc: kvm, linux-kselftest, linux-kernel

On Wed, Oct 15, 2025, Sean Christopherson wrote:
> On Tue, 07 Oct 2025 19:12:31 +0000, Brendan Jackman wrote:
> > Running this test on a system with only one CPU is not a recipe for
> > success. However, there's no clear-cut reason why it absolutely
> > shouldn't work, so the test shouldn't completely reject such a platform.
> > 
> > At present, the *3/4 calculation will return zero on these platforms and
> > the test fails. So, instead just skip that calculation.
> > 
> > [...]
> 
> Applied to kvm-x86 selftests, thanks!
> 
> [1/1] KVM: selftests: Don't fall over when only one CPU
>       https://github.com/kvm-x86/linux/commit/98dea1b75186

FYI, I rebased this onto 6.18-rc2 so that I could apply selftests changes that
conflicted with fixes that went into -rc2 (yet another lesson learned about the
dangers of using -rc1 as a base).  New hash:

[1/1] KVM: selftests: Don't fall over in mmu_stress_test when only one CPU is present
      https://github.com/kvm-x86/linux/commit/b146b289f759

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

end of thread, other threads:[~2025-10-20 16:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 19:12 [PATCH] KVM: selftests: Don't fall over when only one CPU Brendan Jackman
2025-10-15 18:02 ` Sean Christopherson
2025-10-20 16:32   ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox