Skip to contentSkip to conversation

x86: kvm: introduce CONFIG_KVM_MAX_VCPUS

PATCH In review Andrew Jones 2 participants 7 messages Sep 14, 2013 – Sep 16, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: kvm: introduce CONFIG_KVM_MAX_VCPUS

Take CONFIG_KVM_MAX_VCPUS from arm32, but set the default to 255.

---
 arch/x86/include/asm/kvm_host.h |  5 +++--
 arch/x86/kvm/Kconfig            | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +3 -2
index c76ff74a98f2e..e7e9b523a8f7e 100644
@@ -31,8 +31,9 @@
 #include <asm/msr-index.h>
 #include <asm/asm.h>
 
-#define KVM_MAX_VCPUS 255
-#define KVM_SOFT_MAX_VCPUS 160
+#define KVM_MAX_VCPUS CONFIG_KVM_MAX_VCPUS
+#define KVM_SOFT_MAX_VCPUS min(160, KVM_MAX_VCPUS)
+
 #define KVM_USER_MEM_SLOTS 125
 /* memory slots that are not exposed to userspace */
 #define KVM_PRIVATE_MEM_SLOTS 3
arch/x86/kvm/Kconfig +10 -0
index a47a3e54b964b..e9532c33527ee 100644
@@ -52,6 +52,16 @@ config KVM
 
 	  If unsure, say N.
 
+config KVM_MAX_VCPUS
+	int "Number maximum supported virtual CPUs per VM"
+	depends on KVM
+	default 255
+	help
+	  Static number of max supported virtual CPUs per VM.
+
+	  Set to a lower number to save some resources. Set to a higher
+	  number to test scalability.
+
 config KVM_INTEL
 	tristate "KVM for Intel processors support"
 	depends on KVM
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 32 lines · Andrew Jones

Take CONFIG_KVM_MAX_VCPUS from arm32, but set the default to 255.

---
 arch/x86/include/asm/kvm_host.h |  5 +++--
 arch/x86/kvm/Kconfig            | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +3 -2
index c76ff74a98f2e..e7e9b523a8f7e 100644
@@ -31,8 +31,9 @@
 #include <asm/msr-index.h>
 #include <asm/asm.h>
 
-#define KVM_MAX_VCPUS 255
-#define KVM_SOFT_MAX_VCPUS 160
+#define KVM_MAX_VCPUS CONFIG_KVM_MAX_VCPUS
+#define KVM_SOFT_MAX_VCPUS min(160, KVM_MAX_VCPUS)
+
 #define KVM_USER_MEM_SLOTS 125
 /* memory slots that are not exposed to userspace */
 #define KVM_PRIVATE_MEM_SLOTS 3
arch/x86/kvm/Kconfig +0 -0
index a47a3e54b964b..e9532c33527ee 100644
@@ -52,6 +52,16 @@ config KVM
 
 	  If unsure, say N.
 

arch/x86/kvm/Kconfig config KVM · line 64

Quoted 10 lines
arch/x86/kvm/Kconfig +10 -0
+config KVM_MAX_VCPUS
+	int "Number maximum supported virtual CPUs per VM"
+	depends on KVM
+	default 255
+	help
+	  Static number of max supported virtual CPUs per VM.
+
+	  Set to a lower number to save some resources. Set to a higher
+	  number to test scalability.
+

Maximum this can save is around 2K per VM. This is pretty insignificant considering overall memory footprint even smallest VM has.

Quoted 5 lines
arch/x86/kvm/Kconfig +0 -0
 config KVM_INTEL
 	tristate "KVM for Intel processors support"
 	depends on KVM
Signature · 1 line
1.8.1.4

--
Gleb.

#2 lore raw
Quoted 33 lines · Gleb Natapov
Quoted 32 lines · Andrew Jones

Take CONFIG_KVM_MAX_VCPUS from arm32, but set the default to 255.

---
 arch/x86/include/asm/kvm_host.h |  5 +++--
 arch/x86/kvm/Kconfig            | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +3 -2
index c76ff74a98f2e..e7e9b523a8f7e 100644
@@ -31,8 +31,9 @@
 #include <asm/msr-index.h>
 #include <asm/asm.h>
 
-#define KVM_MAX_VCPUS 255
-#define KVM_SOFT_MAX_VCPUS 160
+#define KVM_MAX_VCPUS CONFIG_KVM_MAX_VCPUS
+#define KVM_SOFT_MAX_VCPUS min(160, KVM_MAX_VCPUS)
+
 #define KVM_USER_MEM_SLOTS 125
 /* memory slots that are not exposed to userspace */
 #define KVM_PRIVATE_MEM_SLOTS 3
arch/x86/kvm/Kconfig +0 -0
index a47a3e54b964b..e9532c33527ee 100644
@@ -52,6 +52,16 @@ config KVM
 
 	  If unsure, say N.
 
Quoted 12 lines

arch/x86/kvm/Kconfig config KVM · line 64

Quoted 10 lines
arch/x86/kvm/Kconfig +10 -0
+config KVM_MAX_VCPUS
+	int "Number maximum supported virtual CPUs per VM"
+	depends on KVM
+	default 255
+	help
+	  Static number of max supported virtual CPUs per VM.
+
+	  Set to a lower number to save some resources. Set to a higher
+	  number to test scalability.
+

Maximum this can save is around 2K per VM. This is pretty insignificant considering overall memory footprint even smallest VM has.

Should I reword this, dropping all 'save resources' verbiage, in order to avoid sending a message that this option can affect resource consumption? Or just leave it as it is, because even though it's insignificant, it's still true and balances out the 'Set to a higher' part.

drew

Quoted 9 lines
Quoted 6 lines
arch/x86/kvm/Kconfig +0 -0
 config KVM_INTEL
 	tristate "KVM for Intel processors support"
 	depends on KVM
Signature · 1 line
1.8.1.4

--
Gleb.

#3 lore raw
Quoted 47 lines · Andrew Jones
Quoted 33 lines · Gleb Natapov
Quoted 32 lines · Andrew Jones

Take CONFIG_KVM_MAX_VCPUS from arm32, but set the default to 255.

---
 arch/x86/include/asm/kvm_host.h |  5 +++--
 arch/x86/kvm/Kconfig            | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +3 -2
index c76ff74a98f2e..e7e9b523a8f7e 100644
@@ -31,8 +31,9 @@
 #include <asm/msr-index.h>
 #include <asm/asm.h>
 
-#define KVM_MAX_VCPUS 255
-#define KVM_SOFT_MAX_VCPUS 160
+#define KVM_MAX_VCPUS CONFIG_KVM_MAX_VCPUS
+#define KVM_SOFT_MAX_VCPUS min(160, KVM_MAX_VCPUS)
+
 #define KVM_USER_MEM_SLOTS 125
 /* memory slots that are not exposed to userspace */
 #define KVM_PRIVATE_MEM_SLOTS 3
arch/x86/kvm/Kconfig +0 -0
index a47a3e54b964b..e9532c33527ee 100644
@@ -52,6 +52,16 @@ config KVM
 
 	  If unsure, say N.
 
Quoted 12 lines

arch/x86/kvm/Kconfig config KVM · line 64

Quoted 10 lines
arch/x86/kvm/Kconfig +10 -0
+config KVM_MAX_VCPUS
+	int "Number maximum supported virtual CPUs per VM"
+	depends on KVM
+	default 255
+	help
+	  Static number of max supported virtual CPUs per VM.
+
+	  Set to a lower number to save some resources. Set to a higher
+	  number to test scalability.
+

Maximum this can save is around 2K per VM. This is pretty insignificant considering overall memory footprint even smallest VM has.

Quoted 5 lines

Should I reword this, dropping all 'save resources' verbiage, in order to avoid sending a message that this option can affect resource consumption? Or just leave it as it is, because even though it's insignificant, it's still true and balances out the 'Set to a higher' part.

I do not think config option is necessary. The overhead is so insignificant that there is no point in additional user visible knob, at least while only 255 vcpu are supported. Is there a reason for anyone to configure less them 255 vcpus here? OTOH what prevents someone from configuring more then 255 vcpus?

--
Gleb.

#4 lore raw
Quoted 53 lines · Gleb Natapov
Quoted 47 lines · Andrew Jones
Quoted 33 lines · Gleb Natapov
Quoted 32 lines · Andrew Jones

Take CONFIG_KVM_MAX_VCPUS from arm32, but set the default to 255.

---
 arch/x86/include/asm/kvm_host.h |  5 +++--
 arch/x86/kvm/Kconfig            | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +3 -2
index c76ff74a98f2e..e7e9b523a8f7e 100644
@@ -31,8 +31,9 @@
 #include <asm/msr-index.h>
 #include <asm/asm.h>
 
-#define KVM_MAX_VCPUS 255
-#define KVM_SOFT_MAX_VCPUS 160
+#define KVM_MAX_VCPUS CONFIG_KVM_MAX_VCPUS
+#define KVM_SOFT_MAX_VCPUS min(160, KVM_MAX_VCPUS)
+
 #define KVM_USER_MEM_SLOTS 125
 /* memory slots that are not exposed to userspace */
 #define KVM_PRIVATE_MEM_SLOTS 3
arch/x86/kvm/Kconfig +0 -0
index a47a3e54b964b..e9532c33527ee 100644
@@ -52,6 +52,16 @@ config KVM
 
 	  If unsure, say N.
 
Quoted 12 lines

arch/x86/kvm/Kconfig config KVM · line 64

Quoted 10 lines
arch/x86/kvm/Kconfig +10 -0
+config KVM_MAX_VCPUS
+	int "Number maximum supported virtual CPUs per VM"
+	depends on KVM
+	default 255
+	help
+	  Static number of max supported virtual CPUs per VM.
+
+	  Set to a lower number to save some resources. Set to a higher
+	  number to test scalability.
+

Maximum this can save is around 2K per VM. This is pretty insignificant considering overall memory footprint even smallest VM has.

Quoted 5 lines

Should I reword this, dropping all 'save resources' verbiage, in order to avoid sending a message that this option can affect resource consumption? Or just leave it as it is, because even though it's insignificant, it's still true and balances out the 'Set to a higher' part.

Quoted 5 lines

I do not think config option is necessary. The overhead is so insignificant that there is no point in additional user visible knob, at least while only 255 vcpu are supported. Is there a reason for anyone to configure less them 255 vcpus here? OTOH what prevents someone from configuring more then 255 vcpus?

The reason to configure less is to be able to compile a hard limit, without having to muck with the source. E.g. if you really don't want to allow more than KVM_SOFT_MAX_VCPUS to be configured, then you can compile with CONFIG_KVM_MAX_VCPUS == KVM_SOFT_MAX_VCPUS.

Nothing prevents someone from configuring more than the max in userspace, but if they try to create/use more than the max (kvm_vm_ioctl_create_vcpu), it'll fail (EINVAL).

I see this as a step towards getting rid of KVM_SOFT_MAX_VCPUS. I.e. compile with whatever maximum limit you want (can support), and return online/possible cpus for the recommended number. Only configure the kernel with more than your typical maximum (was KVM_SOFT_MAX_VCPUS) for development/testing purposes.

drew

#5 lore raw
Quoted 60 lines · Andrew Jones
Quoted 53 lines · Gleb Natapov
Quoted 47 lines · Andrew Jones
Quoted 33 lines · Gleb Natapov
Quoted 32 lines · Andrew Jones

Take CONFIG_KVM_MAX_VCPUS from arm32, but set the default to 255.

---
 arch/x86/include/asm/kvm_host.h |  5 +++--
 arch/x86/kvm/Kconfig            | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +3 -2
index c76ff74a98f2e..e7e9b523a8f7e 100644
@@ -31,8 +31,9 @@
 #include <asm/msr-index.h>
 #include <asm/asm.h>
 
-#define KVM_MAX_VCPUS 255
-#define KVM_SOFT_MAX_VCPUS 160
+#define KVM_MAX_VCPUS CONFIG_KVM_MAX_VCPUS
+#define KVM_SOFT_MAX_VCPUS min(160, KVM_MAX_VCPUS)
+
 #define KVM_USER_MEM_SLOTS 125
 /* memory slots that are not exposed to userspace */
 #define KVM_PRIVATE_MEM_SLOTS 3
arch/x86/kvm/Kconfig +0 -0
index a47a3e54b964b..e9532c33527ee 100644
@@ -52,6 +52,16 @@ config KVM
 
 	  If unsure, say N.
 
Quoted 12 lines

arch/x86/kvm/Kconfig config KVM · line 64

Quoted 10 lines
arch/x86/kvm/Kconfig +10 -0
+config KVM_MAX_VCPUS
+	int "Number maximum supported virtual CPUs per VM"
+	depends on KVM
+	default 255
+	help
+	  Static number of max supported virtual CPUs per VM.
+
+	  Set to a lower number to save some resources. Set to a higher
+	  number to test scalability.
+

Maximum this can save is around 2K per VM. This is pretty insignificant considering overall memory footprint even smallest VM has.

Quoted 5 lines

Should I reword this, dropping all 'save resources' verbiage, in order to avoid sending a message that this option can affect resource consumption? Or just leave it as it is, because even though it's insignificant, it's still true and balances out the 'Set to a higher' part.

Quoted 5 lines

I do not think config option is necessary. The overhead is so insignificant that there is no point in additional user visible knob, at least while only 255 vcpu are supported. Is there a reason for anyone to configure less them 255 vcpus here? OTOH what prevents someone from configuring more then 255 vcpus?

Quoted 9 lines

The reason to configure less is to be able to compile a hard limit, without having to muck with the source. E.g. if you really don't want to allow more than KVM_SOFT_MAX_VCPUS to be configured, then you can compile with CONFIG_KVM_MAX_VCPUS == KVM_SOFT_MAX_VCPUS.

Nothing prevents someone from configuring more than the max in userspace, but if they try to create/use more than the max (kvm_vm_ioctl_create_vcpu), it'll fail (EINVAL).

I was talking about configuring more then 255 vcus in kernel config. You should have "range 1 255" there.

Quoted 6 lines

I see this as a step towards getting rid of KVM_SOFT_MAX_VCPUS. I.e. compile with whatever maximum limit you want (can support), and return online/possible cpus for the recommended number. Only configure the kernel with more than your typical maximum (was KVM_SOFT_MAX_VCPUS) for development/testing purposes.

The idea behind soft/hard limit was to allow people easily check scalability without need to recompile the kernel. If custom build will be needed most people will not bother.

--
Gleb.

#6 lore raw
Quoted 66 lines · Gleb Natapov
Quoted 65 lines · Andrew Jones
Quoted 53 lines · Gleb Natapov
Quoted 47 lines · Andrew Jones
Quoted 33 lines · Gleb Natapov
Quoted 32 lines · Andrew Jones

Take CONFIG_KVM_MAX_VCPUS from arm32, but set the default to 255.

---
 arch/x86/include/asm/kvm_host.h |  5 +++--
 arch/x86/kvm/Kconfig            | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +3 -2
index c76ff74a98f2e..e7e9b523a8f7e 100644
@@ -31,8 +31,9 @@
 #include <asm/msr-index.h>
 #include <asm/asm.h>
 
-#define KVM_MAX_VCPUS 255
-#define KVM_SOFT_MAX_VCPUS 160
+#define KVM_MAX_VCPUS CONFIG_KVM_MAX_VCPUS
+#define KVM_SOFT_MAX_VCPUS min(160, KVM_MAX_VCPUS)
+
 #define KVM_USER_MEM_SLOTS 125
 /* memory slots that are not exposed to userspace */
 #define KVM_PRIVATE_MEM_SLOTS 3
arch/x86/kvm/Kconfig +0 -0
index a47a3e54b964b..e9532c33527ee 100644
@@ -52,6 +52,16 @@ config KVM
 
 	  If unsure, say N.
 
Quoted 12 lines

arch/x86/kvm/Kconfig config KVM · line 64

Quoted 10 lines
arch/x86/kvm/Kconfig +10 -0
+config KVM_MAX_VCPUS
+	int "Number maximum supported virtual CPUs per VM"
+	depends on KVM
+	default 255
+	help
+	  Static number of max supported virtual CPUs per VM.
+
+	  Set to a lower number to save some resources. Set to a higher
+	  number to test scalability.
+

Maximum this can save is around 2K per VM. This is pretty insignificant considering overall memory footprint even smallest VM has.

Quoted 5 lines

Should I reword this, dropping all 'save resources' verbiage, in order to avoid sending a message that this option can affect resource consumption? Or just leave it as it is, because even though it's insignificant, it's still true and balances out the 'Set to a higher' part.

Quoted 5 lines

I do not think config option is necessary. The overhead is so insignificant that there is no point in additional user visible knob, at least while only 255 vcpu are supported. Is there a reason for anyone to configure less them 255 vcpus here? OTOH what prevents someone from configuring more then 255 vcpus?

The reason to configure less is to be able to compile a hard limit, without having to muck with the source. E.g. if you really don't want to allow more than KVM_SOFT_MAX_VCPUS to be configured, then you can compile with CONFIG_KVM_MAX_VCPUS == KVM_SOFT_MAX_VCPUS.

Quoted 6 lines
Quoted 4 lines

Nothing prevents someone from configuring more than the max in userspace, but if they try to create/use more than the max (kvm_vm_ioctl_create_vcpu), it'll fail (EINVAL).

I was talking about configuring more then 255 vcus in kernel config. You should have "range 1 255" there.

Ah, I assumed one could configure this higher if they wanted to test something higher. Other than requiring another word in a bitmap, I didn't see what would change going beyond that boundary.

Quoted 10 lines
Quoted 7 lines

I see this as a step towards getting rid of KVM_SOFT_MAX_VCPUS. I.e. compile with whatever maximum limit you want (can support), and return online/possible cpus for the recommended number. Only configure the kernel with more than your typical maximum (was KVM_SOFT_MAX_VCPUS) for development/testing purposes.

The idea behind soft/hard limit was to allow people easily check scalability without need to recompile the kernel. If custom build will be needed most people will not bother.

Keeping the default 255 wouldn't have changed anything we have today, other than making it easier to adjust for scalability testing beyond 255 (assuming they could go beyond). However, as I just wrote in the other thread, you've convinced me to keep a constant soft limit definition, but since the soft limit is a custom concept, then I believe it belongs in the config.

drew