Skip to contentSkip to conversation

Increase max memslots to 512 for PowerPC

RFC PATCH Applied Thomas Huth 3 participants 7 messages Jun 1, 2016 – Jun 3, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 5 lines · Bharata B Rao

Recently the number of memory slots supported by KVM for PowerPC was changed from 32 to 512. QEMU was restricting the user specifiable hot-pluggable memory slots to 32. This patchset changes that to 512.

This allows more number of slots to be available for memory hotplugging.

It's certainly a good idea to increase the number of slots for hot-pluggable memory. But should we really increase it to the full maximum of 512 slots? The in-kernel slots are shared with other memory regions, too, e.g. the memory slots for PCI cards. So if you allow the users to plug all slots with DIMMs, they certainly will run into problems there again later.

I think x86 is also using 256 DIMM slots only on purpose (see
https://lkml.org/lkml/2014/11/14/328 for example), so we should maybe also limit the max. number of DIMM slots on spapr to kvm_get_max_memslots() divided by two ?

Thomas

#2 lore raw
Quoted 14 lines · Thomas Huth
Quoted 5 lines · Bharata B Rao

Recently the number of memory slots supported by KVM for PowerPC was changed from 32 to 512. QEMU was restricting the user specifiable hot-pluggable memory slots to 32. This patchset changes that to 512.

This allows more number of slots to be available for memory hotplugging.

It's certainly a good idea to increase the number of slots for hot-pluggable memory. But should we really increase it to the full maximum of 512 slots? The in-kernel slots are shared with other memory regions, too, e.g. the memory slots for PCI cards. So if you allow the users to plug all slots with DIMMs, they certainly will run into problems there again later.

Quoted 4 lines

I think x86 is also using 256 DIMM slots only on purpose (see
https://lkml.org/lkml/2014/11/14/328 for example), so we should maybe also limit the max. number of DIMM slots on spapr to kvm_get_max_memslots() divided by two ?

I tend to agree. I've held off on merging 2/2 pending outcome of this discussion.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
Quoted 15 lines · David Gibson
Quoted 14 lines · Thomas Huth
Quoted 5 lines · Bharata B Rao

Recently the number of memory slots supported by KVM for PowerPC was changed from 32 to 512. QEMU was restricting the user specifiable hot-pluggable memory slots to 32. This patchset changes that to 512.

This allows more number of slots to be available for memory hotplugging.

It's certainly a good idea to increase the number of slots for hot-pluggable memory. But should we really increase it to the full maximum of 512 slots? The in-kernel slots are shared with other memory regions, too, e.g. the memory slots for PCI cards. So if you allow the users to plug all slots with DIMMs, they certainly will run into problems there again later.

Quoted 7 lines
Quoted 4 lines

I think x86 is also using 256 DIMM slots only on purpose (see
https://lkml.org/lkml/2014/11/14/328 for example), so we should maybe also limit the max. number of DIMM slots on spapr to kvm_get_max_memslots() divided by two ?

I tend to agree. I've held off on merging 2/2 pending outcome of this discussion.

Agreed. Here is the updated patch:

spapr: Increase hotpluggable memory slots to 256

From: Bharata B Rao <[email protected]>

KVM now supports 512 memslots on PowerPC (earlier it was 32). Allow half of it (256) to be used as hotpluggable memory slots.

Instead of hard coding the max value, use the KVM supplied value if KVM is enabled. Otherwise resort to the default value of 32.

---
 hw/ppc/spapr.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +13 -2
index 44e401a..c82adef 100644
@@ -1816,11 +1816,22 @@ static void ppc_spapr_init(MachineState *machine)
     /* initialize hotplug memory address space */
     if (machine->ram_size < machine->maxram_size) {
         ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
+        /*
+         * Number of memslots supported by KVM on PowerPC was increased
+         * from 32 to 512. Let us limit the number of hotpluggable slots
+         * to half of that (256). However ensure that number of slots
+         * doesn't drop below 32 on older hosts.
+         */
+        int max_memslots = kvm_enabled() ? kvm_get_max_memslots() / 2 :
+                           SPAPR_MAX_RAM_SLOTS;
 
-        if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) {
+        if (max_memslots < SPAPR_MAX_RAM_SLOTS) {
+            max_memslots = SPAPR_MAX_RAM_SLOTS;
+        }
+        if (machine->ram_slots > max_memslots) {
             error_report("Specified number of memory slots %"
                          PRIu64" exceeds max supported %d",
-                         machine->ram_slots, SPAPR_MAX_RAM_SLOTS);
+                         machine->ram_slots, max_memslots);
             exit(1);
         }
 
#4 lore raw

On 02.06.2016 06:39, Bharata B Rao wrote:
...

Quoted 22 lines

Agreed. Here is the updated patch:

spapr: Increase hotpluggable memory slots to 256

From: Bharata B Rao <[email protected]>

KVM now supports 512 memslots on PowerPC (earlier it was 32). Allow half of it (256) to be used as hotpluggable memory slots.

Instead of hard coding the max value, use the KVM supplied value if KVM is enabled. Otherwise resort to the default value of 32.

---
 hw/ppc/spapr.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +0 -0
index 44e401a..c82adef 100644

hw/ppc/spapr.c static void ppc_spapr_init(MachineState *machine) · line 1824

Quoted 9 lines
hw/ppc/spapr.c +6 -0
@@ -1816,11 +1816,22 @@ static void ppc_spapr_init(MachineState *machine)
     /* initialize hotplug memory address space */
     if (machine->ram_size < machine->maxram_size) {
         ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
+        /*
+         * Number of memslots supported by KVM on PowerPC was increased
+         * from 32 to 512. Let us limit the number of hotpluggable slots
+         * to half of that (256). However ensure that number of slots
+         * doesn't drop below 32 on older hosts.
+         */

Using "hard-coded" information like "increased to 512" in comments is true for the current state, but this has a risk of being out of date soon. Once we change the memslots in the kernel, this comment is not true anymore and might cause confusion. Better talk about leaving half of the kernel memslots for PCI and other devices, or so.

Quoted 4 lines
hw/ppc/spapr.c +2 -1
+        int max_memslots = kvm_enabled() ? kvm_get_max_memslots() / 2 :
+                           SPAPR_MAX_RAM_SLOTS;
 
-        if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) {

hw/ppc/spapr.c static void ppc_spapr_init(MachineState *machine) · line 1836

Quoted 10 lines
hw/ppc/spapr.c +5 -1
+        if (max_memslots < SPAPR_MAX_RAM_SLOTS) {
+            max_memslots = SPAPR_MAX_RAM_SLOTS;
+        }
+        if (machine->ram_slots > max_memslots) {
             error_report("Specified number of memory slots %"
                          PRIu64" exceeds max supported %d",
-                         machine->ram_slots, SPAPR_MAX_RAM_SLOTS);
+                         machine->ram_slots, max_memslots);
             exit(1);
         }

The changes to the code look fine to me. So once you've updated the comment, feel free to add my "Reviewed-by".

Thomas

Reviewed-by Thomas Huth
#5 lore raw
Quoted 31 lines · Thomas Huth

On 02.06.2016 06:39, Bharata B Rao wrote:
...

Quoted 29 lines

Agreed. Here is the updated patch:

spapr: Increase hotpluggable memory slots to 256

From: Bharata B Rao <[email protected]>

KVM now supports 512 memslots on PowerPC (earlier it was 32). Allow half of it (256) to be used as hotpluggable memory slots.

Instead of hard coding the max value, use the KVM supplied value if KVM is enabled. Otherwise resort to the default value of 32.

---
 hw/ppc/spapr.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +4 -0
index 44e401a..c82adef 100644
@@ -1816,11 +1816,22 @@ static void ppc_spapr_init(MachineState *machine)
     /* initialize hotplug memory address space */
     if (machine->ram_size < machine->maxram_size) {
         ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
+        /*
+         * Number of memslots supported by KVM on PowerPC was increased
+         * from 32 to 512. Let us limit the number of hotpluggable slots
+         * to half of that (256). However ensure that number of slots
Quoted 8 lines

hw/ppc/spapr.c static void ppc_spapr_init(MachineState *machine) · line 1824

Quoted 2 lines
hw/ppc/spapr.c +2 -0
+         * doesn't drop below 32 on older hosts.
+         */

Using "hard-coded" information like "increased to 512" in comments is true for the current state, but this has a risk of being out of date soon. Once we change the memslots in the kernel, this comment is not true anymore and might cause confusion. Better talk about leaving half of the kernel memslots for PCI and other devices, or so.

Just want to note that even though we are limiting hotpluggable memory slots to half of max, it is always possible for other devices to eat into the memory hotplug slots, right ?

David - here is the patch updated with comments as suggested by Thomas. If you need a separate post, let me know.

spapr: Increase hotpluggable memory slots to 256

From: Bharata B Rao <[email protected]>

KVM now supports 512 memslots on PowerPC (earlier it was 32). Allow half of it (256) to be used as hotpluggable memory slots.

Instead of hard coding the max value, use the KVM supplied value if KVM is enabled. Otherwise resort to the default value of 32.

---
 hw/ppc/spapr.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +12 -2
index 44e401a..14cc6ae 100644
@@ -1816,11 +1816,21 @@ static void ppc_spapr_init(MachineState *machine)
     /* initialize hotplug memory address space */
     if (machine->ram_size < machine->maxram_size) {
         ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
+        /*
+         * Limit the number of hotpluggable memory slots to half the number
+         * slots that KVM supports, leaving the other half for PCI and other
+         * devices. However ensure that number of slots doesn't drop below 32.
+         */
+        int max_memslots = kvm_enabled() ? kvm_get_max_memslots() / 2 :
+                           SPAPR_MAX_RAM_SLOTS;
 
-        if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) {
+        if (max_memslots < SPAPR_MAX_RAM_SLOTS) {
+            max_memslots = SPAPR_MAX_RAM_SLOTS;
+        }
+        if (machine->ram_slots > max_memslots) {
             error_report("Specified number of memory slots %"
                          PRIu64" exceeds max supported %d",
-                         machine->ram_slots, SPAPR_MAX_RAM_SLOTS);
+                         machine->ram_slots, max_memslots);
             exit(1);
         }
 
#6 lore raw
Quoted 41 lines · Bharata B Rao
Quoted 31 lines · Thomas Huth

On 02.06.2016 06:39, Bharata B Rao wrote:
...

Quoted 29 lines

Agreed. Here is the updated patch:

spapr: Increase hotpluggable memory slots to 256

From: Bharata B Rao <[email protected]>

KVM now supports 512 memslots on PowerPC (earlier it was 32). Allow half of it (256) to be used as hotpluggable memory slots.

Instead of hard coding the max value, use the KVM supplied value if KVM is enabled. Otherwise resort to the default value of 32.

---
 hw/ppc/spapr.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +4 -0
index 44e401a..c82adef 100644
@@ -1816,11 +1816,22 @@ static void ppc_spapr_init(MachineState *machine)
     /* initialize hotplug memory address space */
     if (machine->ram_size < machine->maxram_size) {
         ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
+        /*
+         * Number of memslots supported by KVM on PowerPC was increased
+         * from 32 to 512. Let us limit the number of hotpluggable slots
+         * to half of that (256). However ensure that number of slots
Quoted 8 lines

hw/ppc/spapr.c static void ppc_spapr_init(MachineState *machine) · line 1824

Quoted 2 lines
hw/ppc/spapr.c +2 -0
+         * doesn't drop below 32 on older hosts.
+         */

Using "hard-coded" information like "increased to 512" in comments is true for the current state, but this has a risk of being out of date soon. Once we change the memslots in the kernel, this comment is not true anymore and might cause confusion. Better talk about leaving half of the kernel memslots for PCI and other devices, or so.

Quoted 3 lines

Just want to note that even though we are limiting hotpluggable memory slots to half of max, it is always possible for other devices to eat into the memory hotplug slots, right ?

Right. But 256 slots for those other devices is already plenty, I think. Let's hope that it is enough for a while - if it's not enough, we've got to rework the kernel code again (and maybe switch to dynamic memslots allocation instead).

Thomas

Applied
#7 lore raw
In reply to Bharata B Rao
Quoted 41 lines · Bharata B Rao
Quoted 31 lines · Thomas Huth

On 02.06.2016 06:39, Bharata B Rao wrote:
...

Quoted 29 lines

Agreed. Here is the updated patch:

spapr: Increase hotpluggable memory slots to 256

From: Bharata B Rao <[email protected]>

KVM now supports 512 memslots on PowerPC (earlier it was 32). Allow half of it (256) to be used as hotpluggable memory slots.

Instead of hard coding the max value, use the KVM supplied value if KVM is enabled. Otherwise resort to the default value of 32.

---
 hw/ppc/spapr.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +4 -0
index 44e401a..c82adef 100644
@@ -1816,11 +1816,22 @@ static void ppc_spapr_init(MachineState *machine)
     /* initialize hotplug memory address space */
     if (machine->ram_size < machine->maxram_size) {
         ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
+        /*
+         * Number of memslots supported by KVM on PowerPC was increased
+         * from 32 to 512. Let us limit the number of hotpluggable slots
+         * to half of that (256). However ensure that number of slots
Quoted 8 lines

hw/ppc/spapr.c static void ppc_spapr_init(MachineState *machine) · line 1824

Quoted 2 lines
hw/ppc/spapr.c +2 -0
+         * doesn't drop below 32 on older hosts.
+         */

Using "hard-coded" information like "increased to 512" in comments is true for the current state, but this has a risk of being out of date soon. Once we change the memslots in the kernel, this comment is not true anymore and might cause confusion. Better talk about leaving half of the kernel memslots for PCI and other devices, or so.

Quoted 6 lines

Just want to note that even though we are limiting hotpluggable memory slots to half of max, it is always possible for other devices to eat into the memory hotplug slots, right ?

David - here is the patch updated with comments as suggested by Thomas. If you need a separate post, let me know.

Applied to ppc-for-2.7, thanks.

Quoted 46 lines

spapr: Increase hotpluggable memory slots to 256

From: Bharata B Rao <[email protected]>

KVM now supports 512 memslots on PowerPC (earlier it was 32). Allow half of it (256) to be used as hotpluggable memory slots.

Instead of hard coding the max value, use the KVM supplied value if KVM is enabled. Otherwise resort to the default value of 32.

---
 hw/ppc/spapr.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +12 -2
index 44e401a..14cc6ae 100644
@@ -1816,11 +1816,21 @@ static void ppc_spapr_init(MachineState *machine)
     /* initialize hotplug memory address space */
     if (machine->ram_size < machine->maxram_size) {
         ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
+        /*
+         * Limit the number of hotpluggable memory slots to half the number
+         * slots that KVM supports, leaving the other half for PCI and other
+         * devices. However ensure that number of slots doesn't drop below 32.
+         */
+        int max_memslots = kvm_enabled() ? kvm_get_max_memslots() / 2 :
+                           SPAPR_MAX_RAM_SLOTS;
 
-        if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) {
+        if (max_memslots < SPAPR_MAX_RAM_SLOTS) {
+            max_memslots = SPAPR_MAX_RAM_SLOTS;
+        }
+        if (machine->ram_slots > max_memslots) {
             error_report("Specified number of memory slots %"
                          PRIu64" exceeds max supported %d",
-                         machine->ram_slots, SPAPR_MAX_RAM_SLOTS);
+                         machine->ram_slots, max_memslots);
             exit(1);
         }
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson