Re: [PATCH RFC] KVM: x86: Drop arbitraty KVM_SOFT_MAX_VCPUS
From: Vitaly Kuznetsov
Date: Thu Nov 11 2021 - 09:44:44 EST
Sean Christopherson <seanjc@xxxxxxxxxx> writes:
> On Thu, Nov 11, 2021, Paolo Bonzini wrote:
>> On 11/11/21 14:47, Vitaly Kuznetsov wrote:
>> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> > index ac83d873d65b..91ef1b872b90 100644
>> > --- a/arch/x86/kvm/x86.c
>> > +++ b/arch/x86/kvm/x86.c
>> > @@ -4137,7 +4137,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>> > r = !static_call(kvm_x86_cpu_has_accelerated_tpr)();
>> > break;
>> > case KVM_CAP_NR_VCPUS:
>> > - r = KVM_SOFT_MAX_VCPUS;
>> > + r = num_online_cpus();
>
> I doubt it matters much in practice, but this really should be
>
> r = min(num_online_cpus(), KVM_MAX_VCPUS);
>
Nice catch, actually! It makes no sense to recommend > KVM_MAX_VCPUS. We
should fix this across all arches though, I'll take that as an action
item.
--
Vitaly