diff mbox

[1/3] arm: kvm: clamp NR_VCPUS to MAX_VCPUS

Message ID 1379160656-28050-2-git-send-email-drjones@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Jones Sept. 14, 2013, 12:10 p.m. UTC
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 arch/arm/kvm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Graf Sept. 14, 2013, 12:14 p.m. UTC | #1
Am 14.09.2013 um 07:10 schrieb Andrew Jones <drjones@redhat.com>:

> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
> arch/arm/kvm/arm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
> index 741f66a2edbd7..9ebf8ac3a12ff 100644
> --- a/arch/arm/kvm/arm.c
> +++ b/arch/arm/kvm/arm.c
> @@ -201,7 +201,7 @@ int kvm_dev_ioctl_check_extension(long ext)
>        r = 1;
>        break;
>    case KVM_CAP_NR_VCPUS:
> -        r = num_online_cpus();
> +        r = min(num_online_cpus(), KVM_MAX_VCPUS);

Is there any real reason to prohibit overcommit?

Alex

>        break;
>    case KVM_CAP_MAX_VCPUS:
>        r = KVM_MAX_VCPUS;
> -- 
> 1.8.1.4
> 
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
Marc Zyngier Sept. 14, 2013, 12:22 p.m. UTC | #2
On 2013-09-14 13:14, Alexander Graf wrote:
> Am 14.09.2013 um 07:10 schrieb Andrew Jones <drjones@redhat.com>:
>
>> Signed-off-by: Andrew Jones <drjones@redhat.com>
>> ---
>> arch/arm/kvm/arm.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
>> index 741f66a2edbd7..9ebf8ac3a12ff 100644
>> --- a/arch/arm/kvm/arm.c
>> +++ b/arch/arm/kvm/arm.c
>> @@ -201,7 +201,7 @@ int kvm_dev_ioctl_check_extension(long ext)
>>        r = 1;
>>        break;
>>    case KVM_CAP_NR_VCPUS:
>> -        r = num_online_cpus();
>> +        r = min(num_online_cpus(), KVM_MAX_VCPUS);
>
> Is there any real reason to prohibit overcommit?

I don't think this affects overcommit. This is the "recommended" limit, 
and you can still go up to KVM_MAX_CPUS.

         M.
Andrew Jones Sept. 14, 2013, 12:23 p.m. UTC | #3
On Sat, Sep 14, 2013 at 07:14:02AM -0500, Alexander Graf wrote:
> 
> 
> Am 14.09.2013 um 07:10 schrieb Andrew Jones <drjones@redhat.com>:
> 
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > ---
> > arch/arm/kvm/arm.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
> > index 741f66a2edbd7..9ebf8ac3a12ff 100644
> > --- a/arch/arm/kvm/arm.c
> > +++ b/arch/arm/kvm/arm.c
> > @@ -201,7 +201,7 @@ int kvm_dev_ioctl_check_extension(long ext)
> >        r = 1;
> >        break;
> >    case KVM_CAP_NR_VCPUS:
> > -        r = num_online_cpus();
> > +        r = min(num_online_cpus(), KVM_MAX_VCPUS);
> 
> Is there any real reason to prohibit overcommit?

This doesn't prohibit it. Users can attempt to configure anything they'd
like, but only selections KVM_MAX_VCPUS and below will work.

drew

> 
> Alex
> 
> >        break;
> >    case KVM_CAP_MAX_VCPUS:
> >        r = KVM_MAX_VCPUS;
> > -- 
> > 1.8.1.4
> > 
> > _______________________________________________
> > kvmarm mailing list
> > kvmarm@lists.cs.columbia.edu
> > https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
diff mbox

Patch

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 741f66a2edbd7..9ebf8ac3a12ff 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -201,7 +201,7 @@  int kvm_dev_ioctl_check_extension(long ext)
 		r = 1;
 		break;
 	case KVM_CAP_NR_VCPUS:
-		r = num_online_cpus();
+		r = min(num_online_cpus(), KVM_MAX_VCPUS);
 		break;
 	case KVM_CAP_MAX_VCPUS:
 		r = KVM_MAX_VCPUS;