On Tue, Sep 22, 2026, Ritesh Harjani (IBM) wrote:
> diff --git a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c 
> b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
> index 59ddc3757943..45a9d8b369b5 100644
> --- a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
> +++ b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
> @@ -20,16 +20,29 @@
>  void test_vcpu_creation(int first_vcpu_id, int num_vcpus)
>  {
>       struct kvm_vm *vm;
> -     int i;
> +     struct kvm_vcpu *vcpu;
> +     int i, created = 0;
>  
>       pr_info("Testing creating %d vCPUs, with IDs %d...%d.\n",
>               num_vcpus, first_vcpu_id, first_vcpu_id + num_vcpus - 1);
>  
>       vm = vm_create_barebones();
>  
> -     for (i = first_vcpu_id; i < first_vcpu_id + num_vcpus; i++)
> -             /* This asserts that the vCPU was created. */
> -             __vm_vcpu_add(vm, i);
> +     for (i = first_vcpu_id; i < first_vcpu_id + num_vcpus; i++) {
> +             vcpu = __vm_vcpu_try_add(vm, i);
> +             if (vcpu) {
> +                     created++;
> +                     continue;
> +             }

Oof.  I dislike this, to put it very mildly.  Is this the KVM_CAP_PPC_SMT thing
again, or something else?

Assuming it's KVM_CAP_PPC_SMT, is there really no way userspace can pre-probe 
the
"real" limit?  Or modify the test to enable KVM_CAP_PPC_SMT and do the proper
striding?  Eating -ENOMEM is all kinds of gross, and I really don't want to add
__vm_vcpu_try_add().

Reply via email to