Skip to contentSkip to conversation

pc: q35: Bump max_cpus to 4096 vcpus

PATCH Superseded Ani Sinha 3 participants 4 messages Feb 21, 2024 – Feb 28, 2024

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Ani Sinha

author
#0 lore raw

PATCH v4 1/1 pc: q35: Bump max_cpus to 4096 vcpus

Since commit f10a570b093e6 ("KVM: x86: Add CONFIG_KVM_MAX_NR_VCPUS to allow up to 4096 vCPUs") Linux kernel can support upto a maximum number of 4096 vCPUS when MAXSMP is enabled in the kernel. At present, QEMU has been tested to correctly boot a linux guest with 4096 vcpus with edk2 pending various upstream EDK2 fixes
which will probably be in the 2024-05 release to be released in the coming months. With current seabios firmware, it boots fine with 4096 vcpus already. So bump up the value max_cpus to 4096 for q35 machines versions 9 and newer. Q35 machines versions 8.2 and older continue to support 1024 maximum vcpus
as before for compatibility reasons.

If KVM is not able to support the specified number of vcpus, QEMU would return the following error messages:

$ ./qemu-system-x86_64 -cpu host -accel kvm -machine q35 -smp 1728
qemu-system-x86_64: -accel kvm: warning: Number of SMP cpus requested (1728) exceeds the recommended cpus supported by KVM (12)
qemu-system-x86_64: -accel kvm: warning: Number of hotpluggable cpus requested (1728) exceeds the recommended cpus supported by KVM (12)
Number of SMP cpus requested (1728) exceeds the maximum cpus supported by KVM (1024)
Cc Daniel P. Berrangé <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Julia Suvorova <[email protected]>
---
 hw/i386/pc_q35.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Changelog:
v4: tweaked commit message as per suggestion from danpb explicitly stating that 4096 vcpus work with edk2 fixes that are going to be available in the coming edk2 release.
v3: bump up to 4096 vcpus. It has now been tested to work with edk2. See RH Jira: https://issues.redhat.com/browse/RHEL-22202
v2: bump up the vcpu number to 1856. Add failure messages from ekd2 in the commit description.

hw/i386/pc_q35.c +2 -1
index d346fa3b1d..ae60e6b919 100644
@@ -366,7 +366,7 @@ static void pc_q35_machine_options(MachineClass *m)
     m->default_nic = "e1000e";
     m->default_kernel_irqchip_split = false;
     m->no_floppy = 1;
-    m->max_cpus = 1024;
+    m->max_cpus = 4096;
     m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE);
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE);
@@ -387,6 +387,7 @@ static void pc_q35_8_2_machine_options(MachineClass *m)
 {
     pc_q35_9_0_machine_options(m);
     m->alias = NULL;
+    m->max_cpus = 1024;
     compat_props_add(m->compat_props, hw_compat_8_2, hw_compat_8_2_len);
     compat_props_add(m->compat_props, pc_compat_8_2, pc_compat_8_2_len);
 }
Signature · 1 line
2.42.0
Reviewed-by on v4 1/1
#1 lore raw
Quoted 18 lines · On Wed, 21 Feb 2024 19:32:27 +0530 Ani Sinha <[email protected]> wrote:

Since commit f10a570b093e6 ("KVM: x86: Add CONFIG_KVM_MAX_NR_VCPUS to allow up to 4096 vCPUs") Linux kernel can support upto a maximum number of 4096 vCPUS when MAXSMP is enabled in the kernel. At present, QEMU has been tested to correctly boot a linux guest with 4096 vcpus with edk2 pending various upstream EDK2 fixes
which will probably be in the 2024-05 release to be released in the coming months. With current seabios firmware, it boots fine with 4096 vcpus already. So bump up the value max_cpus to 4096 for q35 machines versions 9 and newer. Q35 machines versions 8.2 and older continue to support 1024 maximum vcpus
as before for compatibility reasons.

If KVM is not able to support the specified number of vcpus, QEMU would return the following error messages:

$ ./qemu-system-x86_64 -cpu host -accel kvm -machine q35 -smp 1728
qemu-system-x86_64: -accel kvm: warning: Number of SMP cpus requested (1728) exceeds the recommended cpus supported by KVM (12)
qemu-system-x86_64: -accel kvm: warning: Number of hotpluggable cpus requested (1728) exceeds the recommended cpus supported by KVM (12)
Number of SMP cpus requested (1728) exceeds the maximum cpus supported by KVM (1024)
Quoted 7 lines
Cc Daniel P. Berrangé <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Julia Suvorova <[email protected]>

From ACPI point of view, it can support upto 4096 logical cpus (for more we would need to reconsider how to generate CPU descriptions as well as hotplug).

Quoted 35 lines
---
 hw/i386/pc_q35.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Changelog:
v4: tweaked commit message as per suggestion from danpb explicitly stating that 4096 vcpus work with edk2 fixes that are going to be available in the coming edk2 release.
v3: bump up to 4096 vcpus. It has now been tested to work with edk2. See RH Jira: https://issues.redhat.com/browse/RHEL-22202
v2: bump up the vcpu number to 1856. Add failure messages from ekd2 in the commit description.

hw/i386/pc_q35.c +2 -1
index d346fa3b1d..ae60e6b919 100644
@@ -366,7 +366,7 @@ static void pc_q35_machine_options(MachineClass *m)
     m->default_nic = "e1000e";
     m->default_kernel_irqchip_split = false;
     m->no_floppy = 1;
-    m->max_cpus = 1024;
+    m->max_cpus = 4096;
     m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE);
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE);
@@ -387,6 +387,7 @@ static void pc_q35_8_2_machine_options(MachineClass *m)
 {
     pc_q35_9_0_machine_options(m);
     m->alias = NULL;
+    m->max_cpus = 1024;
     compat_props_add(m->compat_props, hw_compat_8_2, hw_compat_8_2_len);
     compat_props_add(m->compat_props, pc_compat_8_2, pc_compat_8_2_len);
 }
Reviewed-by on v4 1/1
#2 lore raw
In reply to Ani Sinha
Quoted 5 lines · Ani Sinha

Since commit f10a570b093e6 ("KVM: x86: Add CONFIG_KVM_MAX_NR_VCPUS to allow up to 4096 vCPUs") Linux kernel can support upto a maximum number of 4096 vCPUS when MAXSMP is enabled in the kernel. At present, QEMU has been tested to correctly boot a linux guest with 4096 vcpus with edk2 pending various upstream EDK2 fixes
which will probably be in the 2024-05 release to be released in the coming

Merged meanwhile, so 2024-05 release is a sure thing and latest edk2 master branch is good too.

You might refine the commit message saying so.
With or without that:

take care,
Gerd

author
#3 lore raw
Quoted 11 lines · Gerd Hoffmann
Quoted 5 lines · Ani Sinha

Since commit f10a570b093e6 ("KVM: x86: Add CONFIG_KVM_MAX_NR_VCPUS to allow up to 4096 vCPUs") Linux kernel can support upto a maximum number of 4096 vCPUS when MAXSMP is enabled in the kernel. At present, QEMU has been tested to correctly boot a linux guest with 4096 vcpus with edk2 pending various upstream EDK2 fixes
which will probably be in the 2024-05 release to be released in the coming

Quoted 4 lines

Merged meanwhile, so 2024-05 release is a sure thing and latest edk2 master branch is good too.

You might refine the commit message saying so.

Can I refer to your two pull requests
https://github.com/tianocore/edk2/pull/5410
https://github.com/tianocore/edk2/pull/5418

In the commit log? I think they are not ephemeral.

Quoted 6 lines

With or without that:

take care,
Gerd