pc-dimm: Change PCDIMMDevice->node from UINT32 to INT32, and initialize it as -1.
PATCH 1/1 pc-dimm: Change PCDIMMDevice->node from UINT32 to INT32, and initialize it as -1.
If user doesn't specify numa options, nb_numa_nodes will be 0. But PCDIMMDevice->node is also initialized to 0. As a result, the following check will fail:
pc_dimm_realize()
{
......
if (dimm->node >= nb_numa_nodes) {
error_setg(errp, "'DIMM property " PC_DIMM_NODE_PROP " has value %"
PRIu32 "' which exceeds the number of numa nodes: %d",
dimm->node, nb_numa_nodes);
return;
}
......
}But this is not an error.
PCDIMMDevice->node should be initialized to -1. This is for users who do not use NUMA.
--- hw/mem/pc-dimm.c | 2 +- include/hw/mem/pc-dimm.h | 2 +- include/sysemu/sysemu.h | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-)
hw/mem/pc-dimm.c +1 -1
@@ -197,7 +197,7 @@ out:static Property pc_dimm_properties[] = {DEFINE_PROP_UINT64 (PC_DIMM_ADDR_PROP , PCDIMMDevice, addr,0 ), -DEFINE_PROP_UINT32 (PC_DIMM_NODE_PROP , PCDIMMDevice, node,0 ), +DEFINE_PROP_INT32 (PC_DIMM_NODE_PROP , PCDIMMDevice, node,NO_NODE_ID ),DEFINE_PROP_INT32 (PC_DIMM_SLOT_PROP , PCDIMMDevice, slot,PC_DIMM_UNASSIGNED_SLOT ),DEFINE_PROP_END_OF_LIST (),
include/hw/mem/pc-dimm.h +1 -1
@@ -53,7 +53,7 @@ typedef struct PCDIMMDevice {/* public */ uint64_t addr; -uint32_t node; +int32_t node;int32_t slot;HostMemoryBackend *hostmem; } PCDIMMDevice;
include/sysemu/sysemu.h +6 -0
@@ -139,6 +139,12 @@ extern int mem_prealloc;#define MAX_NODES 128 +/* Initialize PCDIMMDevice->node to -1 so that even if user doesn't specify +* any numa option, PCDIMMDevice->node won't be 0, which indicates node0. +* In this case, SRAT won't be created, and guest kernel will fake a node. +*/ +#define NO_NODE_ID -1 +/* The following shall be true for all CPUs: * cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS *
Signature · 1 line
1.8.4.2
Quoted 58 lines · Tang Chen
If user doesn't specify numa options,
nb_numa_nodeswill be 0. ButPCDIMMDevice->nodeis also initialized to 0. As a result, the following check will fail:
pc_dimm_realize(){ ...... if (dimm->node >= nb_numa_nodes) { error_setg(errp, "'DIMM property " PC_DIMM_NODE_PROP " has value %" PRIu32 "' which exceeds the number of numa nodes: %d", dimm->node, nb_numa_nodes); return; } ...... }But this is not an error.
PCDIMMDevice->nodeshould be initialized to -1. This is for users who do not use NUMA.Signed-off-by Tang Chen <[email protected]>--- hw/mem/pc-dimm.c | 2 +- include/hw/mem/pc-dimm.h | 2 +- include/sysemu/sysemu.h | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-)hw/mem/pc-dimm.c +1
-1@@ -197,7 +197,7 @@ out:static Property pc_dimm_properties[] = {DEFINE_PROP_UINT64 (PC_DIMM_ADDR_PROP , PCDIMMDevice, addr,0 ), -DEFINE_PROP_UINT32 (PC_DIMM_NODE_PROP , PCDIMMDevice, node,0 ), +DEFINE_PROP_INT32 (PC_DIMM_NODE_PROP , PCDIMMDevice, node,NO_NODE_ID ),DEFINE_PROP_INT32 (PC_DIMM_SLOT_PROP , PCDIMMDevice, slot,PC_DIMM_UNASSIGNED_SLOT ),DEFINE_PROP_END_OF_LIST (),include/hw/mem/pc-dimm.h +1
-1@@ -53,7 +53,7 @@ typedef struct PCDIMMDevice {/* public */ uint64_t addr; -uint32_t node; +int32_t node;int32_t slot;HostMemoryBackend *hostmem; } PCDIMMDevice;include/sysemu/sysemu.h +0
-0
include/sysemu/sysemu.h extern int mem_prealloc; · line 145
Quoted 7 lines
include/sysemu/sysemu.h +4
-0@@ -139,6 +139,12 @@ extern int mem_prealloc;#define MAX_NODES 128 +/* Initialize PCDIMMDevice->node to -1 so that even if user doesn't specify +* any numa option, PCDIMMDevice->node won't be 0, which indicates node0. +* In this case, SRAT won't be created, and guest kernel will fake a node. +*/
I think you simply mean
/* default value for PCDIMMDevice->node (unless specified by user) */
include/sysemu/sysemu.h extern int mem_prealloc; · line 147
Quoted 2 lines
include/sysemu/sysemu.h +2
-0+#define NO_NODE_ID -1 +
So why do we want this macro here? Put the value near PCDIMMDevice where it's used.
Quoted 5 lines
include/sysemu/sysemu.h +0
-0/* The following shall be true for all CPUs: * cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS * Signature · 1 line
1.8.4.2
Il 18/08/2014 15:56, Michael S. Tsirkin ha scritto:
Quoted 9 lines
Quoted 4 lines
+/* Initialize
PCDIMMDevice->nodeto -1 so that even if user doesn't specify
+ * any numa option,PCDIMMDevice->nodewon't be 0, which indicates node0.
+ * In this case, SRAT won't be created, and guest kernel will fake a node.
+ */I think you simply mean
/* default value forPCDIMMDevice->node(unless specified by user) */Quoted 1 line
+#define
NO_NODE_ID-1
I think a comment about the SRAT would be useful.
Paolo
Quoted 6 lines · Paolo Bonzini
Il 18/08/2014 15:56, Michael S. Tsirkin ha scritto:
Quoted 5 lines
Quoted 4 lines
+/* Initialize
PCDIMMDevice->nodeto -1 so that even if user doesn't specify
+ * any numa option,PCDIMMDevice->nodewon't be 0, which indicates node0.
+ * In this case, SRAT won't be created, and guest kernel will fake a node.
+ */
Quoted 8 lines
Quoted 4 lines
I think you simply mean
/* default value forPCDIMMDevice->node(unless specified by user) */Quoted 1 line
+#define
NO_NODE_ID-1I think a comment about the SRAT would be useful.
Paolo
OK so add:
/* In this case, SRAT won't be created. */
Hi Michael, Paolo
Thanks for the advices. Will send a v2 patch soon.
Thanks.
Quoted 18 lines · Michael S. Tsirkin
Quoted 5 lines · Paolo Bonzini
Il 18/08/2014 15:56, Michael S. Tsirkin ha scritto:
Quoted 4 lines
Quoted 4 lines
+/* Initialize
PCDIMMDevice->nodeto -1 so that even if user doesn't specify
+ * any numa option,PCDIMMDevice->nodewon't be 0, which indicates node0.
+ * In this case, SRAT won't be created, and guest kernel will fake a node.
+ */Quoted 7 lines
Quoted 4 lines
I think you simply mean
/* default value forPCDIMMDevice->node(unless specified by user) */Quoted 1 line
+#define
NO_NODE_ID-1I think a comment about the SRAT would be useful.
Paolo
OK so add:
/* In this case, SRAT won't be created. */
.