numa: add auto_enable_numa to fix broken check in spapr
RFC PATCH 1/1 numa: add auto_enable_numa to fix broken check in spapr
Introduce MachineClass::auto_enable_numa for one implicit NUMA node, and enable it to fix broken check in spapr_validate_node_memory(), when spapr_populate_memory() creates a implicit node and info then use nb_numa_nodes which is 0.
---
This patch has a dependency on
https://patchwork.kernel.org/cover/11063235/
--- hw/core/numa.c | 9 +++++++-- hw/ppc/spapr.c | 9 +-------- include/hw/boards.h | 1 + 3 files changed, 9 insertions(+), 10 deletions(-)
hw/core/numa.c +7 -2
@@ -580,9 +580,14 @@ void numa_complete_configuration(MachineState *ms)* guest tries to use it with that drivers. * * Enable NUMA implicitly by adding a new NUMA node automatically. +* +* Or if MachineClass::auto_enable_numa is true and no NUMA nodes, +* assume there is just one node with whole RAM. */ -if (ms->ram_slots >0 && ms->numa_state->num_nodes ==0 && - mc->auto_enable_numa_with_memhp) { +if (ms->numa_state->num_nodes ==0 && + ((ms->ram_slots >0 && + mc->auto_enable_numa_with_memhp) || + mc->auto_enable_numa)) {NumaNodeOptions node = { };parse_numa_node (ms, &node, &error_abort); }
hw/ppc/spapr.c +1 -8
@@ -400,14 +400,6 @@ static int spapr_populate_memory(SpaprMachineState *spapr, void *fdt)hwaddr mem_start, node_size;int i, nb_nodes = machine->numa_state->num_nodes;NodeInfo *nodes = machine->numa_state->nodes; -NodeInfo ramnode; - -/* No NUMA nodes, assume there is just one node with whole RAM */ -if (!nb_nodes) { - nb_nodes =1 ; - ramnode.node_mem = machine->ram_size; - nodes = &ramnode; - }for (i =0 , mem_start =0 ; i < nb_nodes; ++i) {if (!nodes[i].node_mem) {
@@ -4369,6 +4361,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)*/ mc->numa_mem_align_shift =28 ; mc->numa_mem_supported = true; + mc->auto_enable_numa = true; smc->default_caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; smc->default_caps.caps[SPAPR_CAP_VSX ] =SPAPR_CAP_ON ;
include/hw/boards.h +1 -0
@@ -220,6 +220,7 @@ struct MachineClass {bool smbus_no_migration_support;bool nvdimm_supported;bool numa_mem_supported; +bool auto_enable_numa; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);
Signature · 1 line
2.20.1
Quoted 8 lines · Tao Xu
Introduce
MachineClass::auto_enable_numafor one implicit NUMA node, and enable it to fix broken check inspapr_validate_node_memory(), whenspapr_populate_memory()creates a implicit node and info then usenb_numa_nodeswhich is 0.Suggested-by Igor Mammedov <[email protected]>Suggested-by Eduardo Habkost <[email protected]>Signed-off-by Tao Xu <[email protected]>
The change here looks fine so,
However, I'm not following what check in spapr is broken and why.
Quoted 70 lines
---
This patch has a dependency on
https://patchwork.kernel.org/cover/11063235/--- hw/core/numa.c | 9 +++++++-- hw/ppc/spapr.c | 9 +-------- include/hw/boards.h | 1 + 3 files changed, 9 insertions(+), 10 deletions(-)hw/core/numa.c +7
-2@@ -580,9 +580,14 @@ void numa_complete_configuration(MachineState *ms)* guest tries to use it with that drivers. * * Enable NUMA implicitly by adding a new NUMA node automatically. +* +* Or if MachineClass::auto_enable_numa is true and no NUMA nodes, +* assume there is just one node with whole RAM. */ -if (ms->ram_slots >0 && ms->numa_state->num_nodes ==0 && - mc->auto_enable_numa_with_memhp) { +if (ms->numa_state->num_nodes ==0 && + ((ms->ram_slots >0 && + mc->auto_enable_numa_with_memhp) || + mc->auto_enable_numa)) {NumaNodeOptions node = { };parse_numa_node (ms, &node, &error_abort); }hw/ppc/spapr.c +1
-8@@ -400,14 +400,6 @@ static int spapr_populate_memory(SpaprMachineState *spapr, void *fdt)hwaddr mem_start, node_size;int i, nb_nodes = machine->numa_state->num_nodes;NodeInfo *nodes = machine->numa_state->nodes; -NodeInfo ramnode; - -/* No NUMA nodes, assume there is just one node with whole RAM */ -if (!nb_nodes) { - nb_nodes =1 ; - ramnode.node_mem = machine->ram_size; - nodes = &ramnode; - }for (i =0 , mem_start =0 ; i < nb_nodes; ++i) {if (!nodes[i].node_mem) {@@ -4369,6 +4361,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)*/ mc->numa_mem_align_shift =28 ; mc->numa_mem_supported = true; + mc->auto_enable_numa = true; smc->default_caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; smc->default_caps.caps[SPAPR_CAP_VSX ] =SPAPR_CAP_ON ;include/hw/boards.h +1
-0@@ -220,6 +220,7 @@ struct MachineClass {bool smbus_no_migration_support;bool nvdimm_supported;bool numa_mem_supported; +bool auto_enable_numa; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);
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
Quoted 10 lines · David Gibson
Quoted 8 lines · Tao Xu
Introduce
MachineClass::auto_enable_numafor one implicit NUMA node, and enable it to fix broken check inspapr_validate_node_memory(), whenspapr_populate_memory()creates a implicit node and info then usenb_numa_nodeswhich is 0.Suggested-by Igor Mammedov <[email protected]>Suggested-by Eduardo Habkost <[email protected]>Signed-off-by Tao Xu <[email protected]>
Quoted 6 lines
The change here looks fine so,
Acked-by David Gibson <[email protected]>However, I'm not following what check in spapr is broken and why.
Sorry, may be I should update the commit message.
Because in spapr_populate_memory(), if numa node is 0
if (!nb_nodes) {
nb_nodes = 1;
ramnode.node_mem = machine->ram_size;
nodes = &ramnode;
}it use a local 'nb_nodes' as 1 and update global nodes info, but inpapr_validate_node_memory(), use the global nb_numa_nodes
for (i = 0; i < nb_numa_nodes; i++) {
if (numa_info[i].node_mem % SPAPR_MEMORY_BLOCK_SIZE) {so the global is 0 and skip the node_mem check.
Quoted 71 lines
Quoted 70 lines
---
This patch has a dependency on
https://patchwork.kernel.org/cover/11063235/--- hw/core/numa.c | 9 +++++++-- hw/ppc/spapr.c | 9 +-------- include/hw/boards.h | 1 + 3 files changed, 9 insertions(+), 10 deletions(-)hw/core/numa.c +7
-2@@ -580,9 +580,14 @@ void numa_complete_configuration(MachineState *ms)* guest tries to use it with that drivers. * * Enable NUMA implicitly by adding a new NUMA node automatically. +* +* Or if MachineClass::auto_enable_numa is true and no NUMA nodes, +* assume there is just one node with whole RAM. */ -if (ms->ram_slots >0 && ms->numa_state->num_nodes ==0 && - mc->auto_enable_numa_with_memhp) { +if (ms->numa_state->num_nodes ==0 && + ((ms->ram_slots >0 && + mc->auto_enable_numa_with_memhp) || + mc->auto_enable_numa)) {NumaNodeOptions node = { };parse_numa_node (ms, &node, &error_abort); }hw/ppc/spapr.c +1
-8@@ -400,14 +400,6 @@ static int spapr_populate_memory(SpaprMachineState *spapr, void *fdt)hwaddr mem_start, node_size;int i, nb_nodes = machine->numa_state->num_nodes;NodeInfo *nodes = machine->numa_state->nodes; -NodeInfo ramnode; - -/* No NUMA nodes, assume there is just one node with whole RAM */ -if (!nb_nodes) { - nb_nodes =1 ; - ramnode.node_mem = machine->ram_size; - nodes = &ramnode; - }for (i =0 , mem_start =0 ; i < nb_nodes; ++i) {if (!nodes[i].node_mem) {@@ -4369,6 +4361,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)*/ mc->numa_mem_align_shift =28 ; mc->numa_mem_supported = true; + mc->auto_enable_numa = true; smc->default_caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; smc->default_caps.caps[SPAPR_CAP_VSX ] =SPAPR_CAP_ON ;include/hw/boards.h +1
-0@@ -220,6 +220,7 @@ struct MachineClass {bool smbus_no_migration_support;bool nvdimm_supported;bool numa_mem_supported; +bool auto_enable_numa; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);
Quoted 27 lines · Tao Xu
Quoted 10 lines · David Gibson
Quoted 8 lines · Tao Xu
Introduce
MachineClass::auto_enable_numafor one implicit NUMA node, and enable it to fix broken check inspapr_validate_node_memory(), whenspapr_populate_memory()creates a implicit node and info then usenb_numa_nodeswhich is 0.Suggested-by Igor Mammedov <[email protected]>Suggested-by Eduardo Habkost <[email protected]>Signed-off-by Tao Xu <[email protected]>Quoted 6 lines
The change here looks fine so,
Acked-by David Gibson <[email protected]>However, I'm not following what check in spapr is broken and why.
Sorry, may be I should update the commit message.
Because in
spapr_populate_memory(), if numa node is 0if (!nb_nodes) { nb_nodes = 1; ramnode.node_mem = machine->ram_size; nodes = &ramnode; }
Quoted 7 lines
it use a local '
nb_nodes' as 1 and update global nodes info, butinpapr_validate_node_memory(), use the globalnb_numa_nodesfor (i = 0; i < nb_numa_nodes; i++) { if (numa_info[i].node_mem % SPAPR_MEMORY_BLOCK_SIZE) {so the global is 0 and skip the
node_memcheck.
Well, not really. That loop is that each node has memory size a multiple of 256MiB. But we've already checked that the whole memory size is a multiple of 256MiB, so in the case of one NUMA node, the per-node check doesn't actually do anything extra.
And in the "non-NUMA" case, nb_numa_nodes == 0, then I don't believe numa_info[] is populated anyway, so we couldn't do the check like this.
Quoted 69 lines
Quoted 68 lines
Quoted 67 lines
---
This patch has a dependency on
https://patchwork.kernel.org/cover/11063235/--- hw/core/numa.c | 9 +++++++-- hw/ppc/spapr.c | 9 +-------- include/hw/boards.h | 1 + 3 files changed, 9 insertions(+), 10 deletions(-)hw/core/numa.c +7
-2@@ -580,9 +580,14 @@ void numa_complete_configuration(MachineState *ms)* guest tries to use it with that drivers. * * Enable NUMA implicitly by adding a new NUMA node automatically. +* +* Or if MachineClass::auto_enable_numa is true and no NUMA nodes, +* assume there is just one node with whole RAM. */ -if (ms->ram_slots >0 && ms->numa_state->num_nodes ==0 && - mc->auto_enable_numa_with_memhp) { +if (ms->numa_state->num_nodes ==0 && + ((ms->ram_slots >0 && + mc->auto_enable_numa_with_memhp) || + mc->auto_enable_numa)) {NumaNodeOptions node = { };parse_numa_node (ms, &node, &error_abort); }hw/ppc/spapr.c +1
-8@@ -400,14 +400,6 @@ static int spapr_populate_memory(SpaprMachineState *spapr, void *fdt)hwaddr mem_start, node_size;int i, nb_nodes = machine->numa_state->num_nodes;NodeInfo *nodes = machine->numa_state->nodes; -NodeInfo ramnode; - -/* No NUMA nodes, assume there is just one node with whole RAM */ -if (!nb_nodes) { - nb_nodes =1 ; - ramnode.node_mem = machine->ram_size; - nodes = &ramnode; - }for (i =0 , mem_start =0 ; i < nb_nodes; ++i) {if (!nodes[i].node_mem) {@@ -4369,6 +4361,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)*/ mc->numa_mem_align_shift =28 ; mc->numa_mem_supported = true; + mc->auto_enable_numa = true; smc->default_caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; smc->default_caps.caps[SPAPR_CAP_VSX ] =SPAPR_CAP_ON ;include/hw/boards.h +1
-0@@ -220,6 +220,7 @@ struct MachineClass {bool smbus_no_migration_support;bool nvdimm_supported;bool numa_mem_supported; +bool auto_enable_numa; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev);
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
Quoted 36 lines · David Gibson
Quoted 27 lines · Tao Xu
Quoted 10 lines · David Gibson
Quoted 8 lines · Tao Xu
Introduce
MachineClass::auto_enable_numafor one implicit NUMA node, and enable it to fix broken check inspapr_validate_node_memory(), whenspapr_populate_memory()creates a implicit node and info then usenb_numa_nodeswhich is 0.Suggested-by Igor Mammedov <[email protected]>Suggested-by Eduardo Habkost <[email protected]>Signed-off-by Tao Xu <[email protected]>Quoted 6 lines
The change here looks fine so,
Acked-by David Gibson <[email protected]>However, I'm not following what check in spapr is broken and why.
Sorry, may be I should update the commit message.
Because in
spapr_populate_memory(), if numa node is 0if (!nb_nodes) { nb_nodes = 1; ramnode.node_mem = machine->ram_size; nodes = &ramnode; }Quoted 7 lines
it use a local '
nb_nodes' as 1 and update global nodes info, butinpapr_validate_node_memory(), use the globalnb_numa_nodesfor (i = 0; i < nb_numa_nodes; i++) { if (numa_info[i].node_mem % SPAPR_MEMORY_BLOCK_SIZE) {so the global is 0 and skip the
node_memcheck.
Quoted 9 lines
Well, not really. That loop is that each node has memory size a multiple of 256MiB. But we've already checked that the whole memory size is a multiple of 256MiB, so in the case of one NUMA node, the per-node check doesn't actually do anything extra.
And in the "non-NUMA" case,
nb_numa_nodes== 0, then I don't believe numa_info[] is populated anyway, so we couldn't do the check like this.
Thank you David. I understand. I will modify the commit message. So can I modify and keep this patch as a feature? Because it can reuse the generic numa code.
Quoted 42 lines · Tao Xu
Quoted 41 lines · David Gibson
Quoted 27 lines · Tao Xu
Quoted 10 lines · David Gibson
Quoted 8 lines · Tao Xu
Introduce
MachineClass::auto_enable_numafor one implicit NUMA node, and enable it to fix broken check inspapr_validate_node_memory(), whenspapr_populate_memory()creates a implicit node and info then usenb_numa_nodeswhich is 0.Suggested-by Igor Mammedov <[email protected]>Suggested-by Eduardo Habkost <[email protected]>Signed-off-by Tao Xu <[email protected]>Quoted 6 lines
The change here looks fine so,
Acked-by David Gibson <[email protected]>However, I'm not following what check in spapr is broken and why.
Sorry, may be I should update the commit message.
Because in
spapr_populate_memory(), if numa node is 0if (!nb_nodes) { nb_nodes = 1; ramnode.node_mem = machine->ram_size; nodes = &ramnode; }Quoted 7 lines
it use a local '
nb_nodes' as 1 and update global nodes info, butinpapr_validate_node_memory(), use the globalnb_numa_nodesfor (i = 0; i < nb_numa_nodes; i++) { if (numa_info[i].node_mem % SPAPR_MEMORY_BLOCK_SIZE) {so the global is 0 and skip the
node_memcheck.Well, not really. That loop is that each node has memory size a multiple of 256MiB. But we've already checked that the whole memory size is a multiple of 256MiB, so in the case of one NUMA node, the per-node check doesn't actually do anything extra.
Quoted 7 lines
Quoted 4 lines
And in the "non-NUMA" case,
nb_numa_nodes== 0, then I don't believe numa_info[] is populated anyway, so we couldn't do the check like this.Thank you David. I understand. I will modify the commit message. So can I modify and keep this patch as a feature? Because it can reuse the generic numa code.
Yes, the patch itself looks fine, just the comment is misleading.
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