Skip to contentSkip to conversation

Support more than 255 cpus

PATCH In review Li, Zhen-Hua 4 participants 12 messages May 13, 2014 – May 15, 2014

lore
Share & tools
lore
#0 lore raw

cover Support more than 255 cpus

From: "Li, ZhenHua" <[email protected]>

These series patches are trying to make Qemu support more than 255 CPUs. The max cpu number changed to 4096.

Support more than 255 cpus: ACPI and APIC defines Support more than 255 cpus: max_cpus to 4096 Support more than 255 cpus: max cpumask bit to 4096 Support more than 255 cpus: runtime chec

 include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
 include/hw/i386/apic_internal.h    | 2 +-
 include/hw/i386/pc.h | 2 +-
 include/sysemu/sysemu.h | 2 +-
 hw/i386/acpi-build.c | 8 ++++----
#1 lore raw

PATCH 1/4 Support more than 255 cpus: ACPI and APIC defines

From: "Li, ZhenHua" <[email protected]>

Change ACPI_CPU_HOTPLUG_ID_LIMIT from 256 to 4096; Change MAX_APICS from 256 to 4096;

---
 include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
 include/hw/i386/apic_internal.h    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/hw/acpi/cpu_hotplug_defs.h +2 -2
index 9f33663..17381e6 100644
@@ -21,10 +21,10 @@
 /* Limit for CPU arch IDs for CPU hotplug. All hotpluggable CPUs should
  * have CPUClass.get_arch_id() < ACPI_CPU_HOTPLUG_ID_LIMIT.
  */
-#define ACPI_CPU_HOTPLUG_ID_LIMIT 256
+#define ACPI_CPU_HOTPLUG_ID_LIMIT 4096
 
 /* 256 CPU IDs, 8 bits per entry: */
-#define ACPI_GPE_PROC_LEN 32
+#define ACPI_GPE_PROC_LEN ((ACPI_CPU_HOTPLUG_ID_LIMIT)/8)
 
 #define ICH9_CPU_HOTPLUG_IO_BASE 0x0CD8
 #define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00
include/hw/i386/apic_internal.h +1 -1
index 70542a6..e21f30e 100644
@@ -64,7 +64,7 @@
 #define VAPIC_ENABLE_BIT                0
 #define VAPIC_ENABLE_MASK               (1 << VAPIC_ENABLE_BIT)
 
-#define MAX_APICS 255
+#define MAX_APICS 4096
 
 typedef struct APICCommonState APICCommonState;
 
Signature · 1 line
2.0.0-rc0
#2 lore raw

PATCH 2/4 Support more than 255 cpus: max_cpus to 4096

In reply to Li, Zhen-Hua

From: "Li, ZhenHua" <[email protected]>

max_cpus from 255 to 4096. So the machine types can support up to 4096 cpus.

---
 include/hw/i386/pc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/i386/pc.h +1 -1
index 9010246..8183141 100644
@@ -411,6 +411,6 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 #define PC_DEFAULT_MACHINE_OPTIONS \
     PC_COMMON_MACHINE_OPTIONS, \
     .hot_add_cpu = pc_hot_add_cpu, \
-    .max_cpus = 255
+    .max_cpus = 4096
 
 #endif
Signature · 1 line
2.0.0-rc0
#3 lore raw

PATCH 3/4 Support more than 255 cpus: max cpumask bit to 4096

In reply to Li, Zhen-Hua

From: "Li, ZhenHua" <[email protected]>

Change MAX_CPUMASK_BITS from 255 to 4096.

---
 include/sysemu/sysemu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/sysemu/sysemu.h +1 -1
index ba5c7f8..97961a6 100644
@@ -139,7 +139,7 @@ extern QEMUClockType rtc_clock;
  *
  * Note that cpu->get_arch_id() may be larger than MAX_CPUMASK_BITS.
  */
-#define MAX_CPUMASK_BITS 255
+#define MAX_CPUMASK_BITS 4096
 
 extern int nb_numa_nodes;
 extern uint64_t node_mem[MAX_NODES];
Signature · 1 line
2.0.0-rc0
#4 lore raw

PATCH 4/4 Support more than 255 cpus: runtime check

In reply to Li, Zhen-Hua

From: "Li, ZhenHua" <[email protected]>

There is some runtime check for max cpu count. Make them support 4096 cpus.

---
 hw/i386/acpi-build.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/i386/acpi-build.c +4 -4
index c98df88..5c3bf10 100644
@@ -272,7 +272,7 @@ static void GCC_FMT_ATTR(2, 3)
 build_append_nameseg(GArray *array, const char *format, ...)
 {
     /* It would be nicer to use g_string_vprintf but it's only there in 2.22 */
-    char s[] = "XXXX";
+    char s[] = "XXXXXX";
     int len;
     va_list args;
 
@@ -280,7 +280,7 @@ build_append_nameseg(GArray *array, const char *format, ...)
     len = vsnprintf(s, sizeof s, format, args);
     va_end(args);
 
-    assert(len == 4);
+    assert(len == 4 || len == 5 || len == 6);
     g_array_append_vals(array, s, len);
 }
 
@@ -680,7 +680,7 @@ build_append_notify_method(GArray *device, const char *name,
     for (i = 0; i < count; i++) {
         GArray *target = build_alloc_array();
         build_append_nameseg(target, format, i);
-        assert(i < 256); /* Fits in 1 byte */
+        assert(i < 4096); /* Fits in 1 byte */
         build_append_notify_target_ifequal(method, target, i, 1);
         build_free_array(target);
     }
@@ -1006,7 +1006,7 @@ build_ssdt(GArray *table_data, GArray *linker,
 
     /* The current AML generator can cover the APIC ID range [0..255],
      * inclusive, for VCPU hotplug. */
-    QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 256);
+    QEMU_BUILD_BUG_ON(ACPI_CPU_HOTPLUG_ID_LIMIT > 4096);
     g_assert(acpi_cpus <= ACPI_CPU_HOTPLUG_ID_LIMIT);
 
     /* Copy header and patch values in the S3_ / S4_ / S5_ packages */
Signature · 1 line
2.0.0-rc0
#5 lore raw

Re: [Qemu-devel] [PATCH 4/4] Support more than 255 cpus: runtime check

Quoted 13 lines · Zhen-Hua

From: "Li, ZhenHua" <[email protected]>

There is some runtime check for max cpu count. Make them support 4096 cpus.

---
 hw/i386/acpi-build.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/i386/acpi-build.c +0 -0
index c98df88..5c3bf10 100644

[...]

hw/i386/acpi-build.c build_append_notify_method(GArray *device, const char *name, · line 683

Quoted 6 lines
hw/i386/acpi-build.c +1 -1
@@ -680,7 +680,7 @@ build_append_notify_method(GArray *device, const char *name,
     for (i = 0; i < count; i++) {
         GArray *target = build_alloc_array();
         build_append_nameseg(target, format, i);
-        assert(i < 256); /* Fits in 1 byte */
+        assert(i < 4096); /* Fits in 1 byte */

The comment is no longer true.
Also the function build_append_notify_method is called with format argument set to "CP%0.02X", looks like this should be changed to "CP%0.03X".

Signature · 2 lines
Thanks.
-- Max
#6 lore raw

Re: [Qemu-devel] [PATCH 4/4] Support more than 255 cpus: runtime check

Maybe it should be 4 bytes for 4096 (0x1000).

Quoted 26 lines · Max Filippov
Quoted 13 lines · Zhen-Hua

From: "Li, ZhenHua" <[email protected]>

There is some runtime check for max cpu count. Make them support 4096 cpus.

---
  hw/i386/acpi-build.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
hw/i386/acpi-build.c +0 -0
index c98df88..5c3bf10 100644

[...]

hw/i386/acpi-build.c build_append_notify_method(GArray *device, const char *name, · line 683

Quoted 6 lines
hw/i386/acpi-build.c +1 -1
@@ -680,7 +680,7 @@ build_append_notify_method(GArray *device, const char *name,
      for (i = 0; i < count; i++) {
          GArray *target = build_alloc_array();
          build_append_nameseg(target, format, i);
-        assert(i < 256); /* Fits in 1 byte */
+        assert(i < 4096); /* Fits in 1 byte */

The comment is no longer true.
Also the function build_append_notify_method is called with format argument set to "CP%0.02X", looks like this should be changed to "CP%0.03X".

#7 lore raw

Re: [Qemu-devel] [PATCH 4/4] Support more than 255 cpus: runtime check

Quoted 1 line · ZhenHua

Maybe it should be 4 bytes for 4096 (0x1000).

I'd say that 2 bytes should be enough, but actually I don't see why anybody would care in that function how many bytes it is.

Quoted 21 lines · Max Filippov
Quoted 20 lines · Zhen-Hua
Quoted 15 lines

From: "Li, ZhenHua" <[email protected]>

There is some runtime check for max cpu count. Make them support 4096 cpus.

---
  hw/i386/acpi-build.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
hw/i386/acpi-build.c +0 -0
index c98df88..5c3bf10 100644

[...]

Quoted 5 lines
Quoted 5 lines

hw/i386/acpi-build.c build_append_notify_method(GArray *device, const char · line 683

Quoted 5 lines
hw/i386/acpi-build.c +0 -0
@@ -680,7 +680,7 @@ build_append_notify_method(GArray *device, const char
 *name,
      for (i = 0; i < count; i++) {
          GArray *target = build_alloc_array();
          build_append_nameseg(target, format, i);

BTW, build_append_nameseg also expects format string that makes a string of 4 characters, otherwise it asserts.

Quoted 7 lines
Quoted 7 lines

hw/i386/acpi-build.c build_append_notify_method(GArray *device, const char *name, · line 683

Quoted 2 lines
hw/i386/acpi-build.c +1 -1
-        assert(i < 256); /* Fits in 1 byte */
+        assert(i < 4096); /* Fits in 1 byte */

The comment is no longer true.
Also the function build_append_notify_method is called with format argument
set to "CP%0.02X", looks like this should be changed to "CP%0.03X".

Signature · 2 lines
Thanks.
-- Max
#8 lore raw
In reply to Li, Zhen-Hua

Am 13.05.2014 09:09, schrieb Li, Zhen-Hua:

Quoted 4 lines

From: "Li, ZhenHua" <[email protected]>

These series patches are trying to make Qemu support more than 255 CPUs. The max cpu number changed to 4096.

This series is not trivial.
And it's not a bug fix either, so not stable material.

CC'ing Igor and Eduardo for review.

Regards,
Andreas

Quoted 10 lines

Support more than 255 cpus: ACPI and APIC defines Support more than 255 cpus: max_cpus to 4096 Support more than 255 cpus: max cpumask bit to 4096 Support more than 255 cpus: runtime chec

 include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
 include/hw/i386/apic_internal.h    | 2 +-
 include/hw/i386/pc.h | 2 +-
 include/sysemu/sysemu.h | 2 +-
 hw/i386/acpi-build.c | 8 ++++----
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#9 lore raw
In reply to Li, Zhen-Hua
Quoted 10 lines · Zhen-Hua

From: "Li, ZhenHua" <[email protected]>

These series patches are trying to make Qemu support more than 255 CPUs. The max cpu number changed to 4096.

Support more than 255 cpus: ACPI and APIC defines Support more than 255 cpus: max_cpus to 4096 Support more than 255 cpus: max cpumask bit to 4096 Support more than 255 cpus: runtime chec

Quoted 5 lines
 include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
 include/hw/i386/apic_internal.h    | 2 +-
 include/hw/i386/pc.h | 2 +-
 include/sysemu/sysemu.h | 2 +-
 hw/i386/acpi-build.c | 8 ++++----

Don't we need x2APIC support to provide >255 CPUs? Where so you enforce this, i.e. keep the restriction to 255 CPUs when we are not in KVM mode with in-kernel APIC (the emulate APIC lacks x2APIC mode, unfortunately)? But, wait, KVM only supports up to 255 VCPUs. So what are you targeting at?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
#10 lore raw

Kernel's kvm support is not here.
x2APIC is needed, I will try to do that later.

Quoted 23 lines · Jan Kiszka
Quoted 10 lines · Zhen-Hua

From: "Li, ZhenHua" <[email protected]>

These series patches are trying to make Qemu support more than 255 CPUs. The max cpu number changed to 4096.

Support more than 255 cpus: ACPI and APIC defines Support more than 255 cpus: max_cpus to 4096 Support more than 255 cpus: max cpumask bit to 4096 Support more than 255 cpus: runtime chec

Quoted 5 lines
  include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
  include/hw/i386/apic_internal.h    | 2 +-
  include/hw/i386/pc.h | 2 +-
  include/sysemu/sysemu.h | 2 +-
  hw/i386/acpi-build.c | 8 ++++----

Don't we need x2APIC support to provide >255 CPUs? Where so you enforce this, i.e. keep the restriction to 255 CPUs when we are not in KVM mode with in-kernel APIC (the emulate APIC lacks x2APIC mode, unfortunately)? But, wait, KVM only supports up to 255 VCPUs. So what are you targeting at?

Jan

#11 lore raw
Quoted 2 lines · ZhenHua

Kernel's kvm support is not here.
x2APIC is needed, I will try to do that later.

x2APIC emulation can wait if KVM support is there. But we need at least one of them before starting to think about raising the limit.

Jan

PS: Please don't top-post.

Quoted 27 lines · Jan Kiszka
Quoted 24 lines · Zhen-Hua
Quoted 10 lines

From: "Li, ZhenHua" <[email protected]>

These series patches are trying to make Qemu support more than 255 CPUs. The max cpu number changed to 4096.

Support more than 255 cpus: ACPI and APIC defines Support more than 255 cpus: max_cpus to 4096 Support more than 255 cpus: max cpumask bit to 4096 Support more than 255 cpus: runtime chec

Quoted 5 lines
  include/hw/acpi/cpu_hotplug_defs.h | 4 ++--
  include/hw/i386/apic_internal.h    | 2 +-
  include/hw/i386/pc.h | 2 +-
  include/sysemu/sysemu.h | 2 +-
  hw/i386/acpi-build.c | 8 ++++----

Don't we need x2APIC support to provide >255 CPUs? Where so you enforce this, i.e. keep the restriction to 255 CPUs when we are not in KVM mode with in-kernel APIC (the emulate APIC lacks x2APIC mode, unfortunately)? But, wait, KVM only supports up to 255 VCPUs. So what are you targeting at?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux