arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/Kconfig | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
Add a Kconfig entry to set the maximum number of vCPUs per KVM guest and
set the default value to 4096 when MAXSMP is enabled.
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---
arch/x86/include/asm/kvm_host.h | 2 +-
arch/x86/kvm/Kconfig | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 3bc146dfd38d..536317812b52 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -39,7 +39,7 @@
#define __KVM_HAVE_ARCH_VCPU_DEBUGFS
-#define KVM_MAX_VCPUS 1024
+#define KVM_MAX_VCPUS CONFIG_KVM_MAX_NR_VCPUS
/*
* In x86, the VCPU ID corresponds to the APIC ID, and APIC IDs
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 89ca7f4c1464..e730e8255e22 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -141,4 +141,15 @@ config KVM_XEN
config KVM_EXTERNAL_WRITE_TRACKING
bool
+config KVM_MAX_NR_VCPUS
+ int "Maximum number of vCPUs per KVM guest"
+ depends on KVM
+ range 1024 4096
+ default 4096 if MAXSMP
+ default 1024
+ help
+ Set the maximum number of vCPUs per KVM guest. Larger values will increase
+ the memory footprint of each KVM guest, regardless of how many vCPUs are
+ configured.
+
endif # VIRTUALIZATION
--
2.26.2
Hi Kyle,
kernel test robot noticed the following build errors:
[auto build test ERROR on kvm/queue]
[also build test ERROR on linus/master v6.5-rc7 next-20230823]
[cannot apply to kvm/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Kyle-Meyer/KVM-x86-Add-CONFIG_KVM_MAX_NR_VCPUS/20230824-034224
base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link: https://lore.kernel.org/r/20230823193842.2544394-1-kyle.meyer%40hpe.com
patch subject: [PATCH v2] KVM: x86: Add CONFIG_KVM_MAX_NR_VCPUS
config: i386-tinyconfig (https://download.01.org/0day-ci/archive/20230824/202308240540.9fQYjHB2-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230824/202308240540.9fQYjHB2-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308240540.9fQYjHB2-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/vdso/const.h:5,
from include/linux/const.h:4,
from include/uapi/linux/kernel.h:6,
from include/linux/cache.h:5,
from include/linux/slab.h:15,
from arch/x86/events/intel/core.c:14:
>> arch/x86/include/asm/kvm_host.h:42:23: error: 'CONFIG_KVM_MAX_NR_VCPUS' undeclared here (not in a function)
42 | #define KVM_MAX_VCPUS CONFIG_KVM_MAX_NR_VCPUS
| ^~~~~~~~~~~~~~~~~~~~~~~
include/uapi/linux/const.h:34:40: note: in definition of macro '__KERNEL_DIV_ROUND_UP'
34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
| ^
arch/x86/include/asm/kvm_host.h:1120:33: note: in expansion of macro 'BITS_TO_LONGS'
1120 | unsigned long poll_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)];
| ^~~~~~~~~~~~~
arch/x86/include/asm/kvm_host.h:1120:47: note: in expansion of macro 'KVM_MAX_VCPUS'
1120 | unsigned long poll_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)];
| ^~~~~~~~~~~~~
vim +/CONFIG_KVM_MAX_NR_VCPUS +42 arch/x86/include/asm/kvm_host.h
41
> 42 #define KVM_MAX_VCPUS CONFIG_KVM_MAX_NR_VCPUS
43
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.