hw/acpi-build: build SRAT memory affinity structures for DIMM devices
v2 cover hw/acpi-build: build SRAT memory affinity structures for DIMM devices
ACPI 6.2A Table 5-129 "SPA Range Structure" requires the proximity domain of a NVDIMM SPA range must match with corresponding entry in SRAT table.
The address ranges of vNVDIMM in QEMU are allocated from the hot-pluggable address space, which is entirely covered by one SRAT memory affinity structure. However, users can set the vNVDIMM proximity domain in NFIT SPA range structure by the 'node' property of '-device nvdimm' to a value different than the one in the above SRAT memory affinity structure.
In order to solve such proximity domain mismatch, this patch builds one SRAT memory affinity structure for each static-plugged DIMM device, including both PC-DIMM and NVDIMM, with the proximity domain specified in '-device pc-dimm' or '-device nvdimm'.
The remaining hot-pluggable address space is covered by one or multiple SRAT memory affinity structures with the proximity domain of the last node as before.
Changes in v2:
* Build SRAT memory affinity structures of PC-DIMM devices as well.
* Add test cases.
Haozhong Zhang (3):
hw/acpi-build: build SRAT memory affinity structures for DIMM devices tests/bios-tables-test: allow setting extra machine options tests/bios-tables-test: add test cases for DIMM proximity
hw/i386/acpi-build.c | 50 ++++++++++++++++++++-- hw/mem/pc-dimm.c | 8 ++++ include/hw/mem/pc-dimm.h | 10 +++++ tests/acpi-test-data/pc/APIC.dimmpxm | Bin 0 -> 136 bytes tests/acpi-test-data/pc/DSDT.dimmpxm | Bin 0 -> 6710 bytes tests/acpi-test-data/pc/NFIT.dimmpxm | Bin 0 -> 224 bytes tests/acpi-test-data/pc/SRAT.dimmpxm | Bin 0 -> 416 bytes tests/acpi-test-data/pc/SSDT.dimmpxm | Bin 0 -> 685 bytes tests/acpi-test-data/q35/APIC.dimmpxm | Bin 0 -> 136 bytes tests/acpi-test-data/q35/DSDT.dimmpxm | Bin 0 -> 9394 bytes tests/acpi-test-data/q35/NFIT.dimmpxm | Bin 0 -> 224 bytes tests/acpi-test-data/q35/SRAT.dimmpxm | Bin 0 -> 416 bytes tests/acpi-test-data/q35/SSDT.dimmpxm | Bin 0 -> 685 bytes tests/bios-tables-test.c | 78 +++++++++++++++++++++++++++------- 14 files changed, 126 insertions(+), 20 deletions(-) create mode 100644 tests/acpi-test-data/pc/APIC.dimmpxm create mode 100644 tests/acpi-test-data/pc/DSDT.dimmpxm create mode 100644 tests/acpi-test-data/pc/NFIT.dimmpxm create mode 100644 tests/acpi-test-data/pc/SRAT.dimmpxm create mode 100644 tests/acpi-test-data/pc/SSDT.dimmpxm create mode 100644 tests/acpi-test-data/q35/APIC.dimmpxm create mode 100644 tests/acpi-test-data/q35/DSDT.dimmpxm create mode 100644 tests/acpi-test-data/q35/NFIT.dimmpxm create mode 100644 tests/acpi-test-data/q35/SRAT.dimmpxm create mode 100644 tests/acpi-test-data/q35/SSDT.dimmpxm
Signature · 1 line
2.14.1
PATCH v2 1/3 hw/acpi-build: build SRAT memory affinity structures for DIMM devices
ACPI 6.2A Table 5-129 "SPA Range Structure" requires the proximity domain of a NVDIMM SPA range must match with corresponding entry in SRAT table.
The address ranges of vNVDIMM in QEMU are allocated from the hot-pluggable address space, which is entirely covered by one SRAT memory affinity structure. However, users can set the vNVDIMM proximity domain in NFIT SPA range structure by the 'node' property of '-device nvdimm' to a value different than the one in the above SRAT memory affinity structure.
In order to solve such proximity domain mismatch, this patch builds one SRAT memory affinity structure for each static-plugged DIMM device, including both PC-DIMM and NVDIMM, with the proximity domain specified in '-device pc-dimm' or '-device nvdimm'.
The remaining hot-pluggable address space is covered by one or multiple SRAT memory affinity structures with the proximity domain of the last node as before.
--- hw/i386/acpi-build.c | 50 ++++++++++++++++++++++++++++++++++++++++++++---- hw/mem/pc-dimm.c | 8 ++++++++ include/hw/mem/pc-dimm.h | 10 ++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-)
hw/i386/acpi-build.c +46 -4
@@ -2323,6 +2323,49 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)#define HOLE_640K_START (640 * 1024)#define HOLE_640K_END (1024 * 1024) +static void build_srat_hotpluggable_memory (GArray *table_data,uint64_t base, +uint64_t len,int default_node) +{ +GSList *dimms =pc_dimm_get_device_list (); +GSList *ent = dimms; +PCDIMMDevice *dev; +Object *obj; +uint64_t end = base + len, addr, size; +int node; +AcpiSratMemoryAffinity *numamem; + +while (base < end) { + numamem =acpi_data_push (table_data,sizeof *numamem); + +if (!ent) { +build_srat_memory (numamem, base, end - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); +break ; + } + + dev =PC_DIMM (ent->data); + obj =OBJECT (dev); + addr =object_property_get_uint (obj,PC_DIMM_ADDR_PROP ,NULL ); + size =object_property_get_uint (obj,PC_DIMM_SIZE_PROP ,NULL ); + node =object_property_get_uint (obj,PC_DIMM_NODE_PROP ,NULL ); + +if (base < addr) { +build_srat_memory (numamem, base, addr - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); + numamem =acpi_data_push (table_data,sizeof *numamem); + } +build_srat_memory (numamem, addr, size, node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED | + (object_dynamic_cast (obj,TYPE_NVDIMM ) ? +MEM_AFFINITY_NON_VOLATILE :0 )); + + base = addr + size; + ent =g_slist_next (ent); + } + +g_slist_free (dimms); +} +static void build_srat (GArray *table_data,BIOSLinker *linker,MachineState *machine) {
@@ -2434,10 +2477,9 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)* providing _PXM method if necessary. */ if (hotplugabble_address_space_size) { - numamem =acpi_data_push (table_data,sizeof *numamem); -build_srat_memory (numamem, pcms->hotplug_memory.base, - hotplugabble_address_space_size, pcms->numa_nodes -1 , -MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); +build_srat_hotpluggable_memory (table_data, pcms->hotplug_memory.base, + hotplugabble_address_space_size, + pcms->numa_nodes -1 ); } build_header(linker, table_data,
hw/mem/pc-dimm.c +8 -0
@@ -276,6 +276,14 @@ static int pc_dimm_built_list(Object *obj, void *opaque)return 0 ; } +GSList *pc_dimm_get_device_list (void ) +{ +GSList *list =NULL ; + +object_child_foreach (qdev_get_machine (), pc_dimm_built_list, &list); +return list; +} + uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t align, uint64_t size,
include/hw/mem/pc-dimm.h +10 -0
@@ -100,4 +100,14 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, Error **errp);void pc_dimm_memory_unplug (DeviceState *dev,MemoryHotplugState *hpms,MemoryRegion *mr); + +/* +* Return a list of DeviceState of pc-dimm and nvdimm devices. The +* list is sorted in the ascendant order of the base address of +* devices. +* +* Note: callers are responsible to free the list. +*/ +GSList *pc_dimm_get_device_list (void ); +#endif
Signature · 1 line
2.14.1
Quoted 11 lines · On Wed, 28 Feb 2018 12:02:58 +0800 Haozhong Zhang <[email protected]>…
ACPI 6.2A Table 5-129 "SPA Range Structure" requires the proximity domain of a NVDIMM SPA range must match with corresponding entry in SRAT table.
The address ranges of vNVDIMM in QEMU are allocated from the hot-pluggable address space, which is entirely covered by one SRAT memory affinity structure. However, users can set the vNVDIMM proximity domain in NFIT SPA range structure by the 'node' property of '-device nvdimm' to a value different than the one in the above SRAT memory affinity structure.
Quoted 2 lines
In order to solve such proximity domain mismatch, this patch builds one SRAT memory affinity structure for each static-plugged DIMM device,
s/static-plugged/present at boot/
since after hotplug and following reset SRAT will be recreated and include hotplugged DIMMs as well.
Quoted 24 lines
including both PC-DIMM and NVDIMM, with the proximity domain specified in '-device pc-dimm' or '-device nvdimm'.
The remaining hot-pluggable address space is covered by one or multiple SRAT memory affinity structures with the proximity domain of the last node as before.
Signed-off-by Haozhong Zhang <[email protected]>--- hw/i386/acpi-build.c | 50 ++++++++++++++++++++++++++++++++++++++++++++---- hw/mem/pc-dimm.c | 8 ++++++++ include/hw/mem/pc-dimm.h | 10 ++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-)hw/i386/acpi-build.c +2
-0@@ -2323,6 +2323,49 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)#define HOLE_640K_START (640 * 1024)#define HOLE_640K_END (1024 * 1024) +static void build_srat_hotpluggable_memory (GArray *table_data,uint64_t base, +uint64_t len,int default_node)
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2337
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+{ +GSList *dimms =pc_dimm_get_device_list (); +GSList *ent = dimms; +PCDIMMDevice *dev; +Object *obj; +uint64_t end = base + len, addr, size; +int node; +AcpiSratMemoryAffinity *numamem; + +while (base < end) {
It's just matter of taste but wouldn't 'for' loop be better here? One can see start, end and next step from the begging.
Quoted 11 lines
hw/i386/acpi-build.c +11
-0+ numamem =acpi_data_push (table_data,sizeof *numamem); + +if (!ent) { +build_srat_memory (numamem, base, end - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); +break ; + } + + dev =PC_DIMM (ent->data); + obj =OBJECT (dev); + addr =object_property_get_uint (obj,PC_DIMM_ADDR_PROP ,NULL );
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2358
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+ size =object_property_get_uint (obj,PC_DIMM_SIZE_PROP ,NULL ); + node =object_property_get_uint (obj,PC_DIMM_NODE_PROP ,NULL ); + +if (base < addr) { +build_srat_memory (numamem, base, addr - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); + numamem =acpi_data_push (table_data,sizeof *numamem); + } + build_srat_memory(numamem, addr, size, node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED |
Is NVDIMM hotplug supported in QEMU?
If not we might need make MEM_AFFINITY_HOTPLUGGABLE conditional too.
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2360
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+ (object_dynamic_cast (obj,TYPE_NVDIMM ) ? + MEM_AFFINITY_NON_VOLATILE : 0));
it might be cleaner without inline flags duplication
flags = MEM_AFFINITY_ENABLED;
...
if (!ent) {
flags |= MEM_AFFINITY_HOTPLUGGABLE
}
...
if (PCDIMMDeviceInfo::hotpluggable) { // see ***
flags |= MEM_AFFINITY_HOTPLUGGABLE
}
...
if (object_dynamic_cast(obj, TYPE_NVDIMM))
flags |= MEM_AFFINITY_NON_VOLATILE
}Quoted 30 lines
hw/i386/acpi-build.c +11
-4+ + base = addr + size; + ent =g_slist_next (ent); + } + +g_slist_free (dimms); +} +static void build_srat (GArray *table_data,BIOSLinker *linker,MachineState *machine) {@@ -2434,10 +2477,9 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)* providing _PXM method if necessary. */ if (hotplugabble_address_space_size) { - numamem =acpi_data_push (table_data,sizeof *numamem); -build_srat_memory (numamem, pcms->hotplug_memory.base, - hotplugabble_address_space_size, pcms->numa_nodes -1 , -MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); +build_srat_hotpluggable_memory (table_data, pcms->hotplug_memory.base, + hotplugabble_address_space_size, + pcms->numa_nodes -1 ); } build_header(linker, table_data,hw/mem/pc-dimm.c +0
-0
hw/mem/pc-dimm.c static int pc_dimm_built_list(Object *obj, void *opaque) · line 285
Quoted 10 lines
hw/mem/pc-dimm.c +7
-0@@ -276,6 +276,14 @@ static int pc_dimm_built_list(Object *obj, void *opaque)return 0 ; } +GSList *pc_dimm_get_device_list (void ) +{ +GSList *list =NULL ; + +object_child_foreach (qdev_get_machine (), pc_dimm_built_list, &list); +return list; +}
(***)
see http://lists.gnu.org/archive/html/qemu-ppc/2018-02/msg00271.html
You could do that in separate patch, so that it won't matter whose patch got merged first and it won't affect the rest of patches.
Quoted 22 lines
hw/mem/pc-dimm.c +0
-0uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t align, uint64_t size,include/hw/mem/pc-dimm.h +10
-0@@ -100,4 +100,14 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, Error **errp);void pc_dimm_memory_unplug (DeviceState *dev,MemoryHotplugState *hpms,MemoryRegion *mr); + +/* +* Return a list of DeviceState of pc-dimm and nvdimm devices. The +* list is sorted in the ascendant order of the base address of +* devices. +* +* Note: callers are responsible to free the list. +*/ +GSList *pc_dimm_get_device_list (void ); +#endif
Quoted 14 lines · Igor Mammedov
Quoted 11 lines · On Wed, 28 Feb 2018 12:02:58 +0800 Haozhong Zhang <[email protected]>…
ACPI 6.2A Table 5-129 "SPA Range Structure" requires the proximity domain of a NVDIMM SPA range must match with corresponding entry in SRAT table.
The address ranges of vNVDIMM in QEMU are allocated from the hot-pluggable address space, which is entirely covered by one SRAT memory affinity structure. However, users can set the vNVDIMM proximity domain in NFIT SPA range structure by the 'node' property of '-device nvdimm' to a value different than the one in the above SRAT memory affinity structure.
Quoted 5 lines
Quoted 2 lines
In order to solve such proximity domain mismatch, this patch builds one SRAT memory affinity structure for each static-plugged DIMM device,
s/static-plugged/present at boot/
since after hotplug and following reset SRAT will be recreated and include hotplugged DIMMs as well.
Ah yes, I'll fix the message in the next version.
Quoted 23 lines
Quoted 23 lines
including both PC-DIMM and NVDIMM, with the proximity domain specified in '-device pc-dimm' or '-device nvdimm'.
The remaining hot-pluggable address space is covered by one or multiple SRAT memory affinity structures with the proximity domain of the last node as before.
Signed-off-by Haozhong Zhang <[email protected]>--- hw/i386/acpi-build.c | 50 ++++++++++++++++++++++++++++++++++++++++++++---- hw/mem/pc-dimm.c | 8 ++++++++ include/hw/mem/pc-dimm.h | 10 ++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-)hw/i386/acpi-build.c +0
-0@@ -2323,6 +2323,49 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)#define HOLE_640K_START (640 * 1024)#define HOLE_640K_END (1024 * 1024)
Quoted 14 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2337
Quoted 12 lines
hw/i386/acpi-build.c +12
-0+static void build_srat_hotpluggable_memory (GArray *table_data,uint64_t base, +uint64_t len,int default_node) +{ +GSList *dimms =pc_dimm_get_device_list (); +GSList *ent = dimms; +PCDIMMDevice *dev; +Object *obj; +uint64_t end = base + len, addr, size; +int node; +AcpiSratMemoryAffinity *numamem; + +while (base < end) {It's just matter of taste but wouldn't 'for' loop be better here? One can see start, end and next step from the begging.
will switch to a for loop
Quoted 16 lines
Quoted 16 lines
hw/i386/acpi-build.c +15
-0+ numamem =acpi_data_push (table_data,sizeof *numamem); + +if (!ent) { +build_srat_memory (numamem, base, end - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); +break ; + } + + dev =PC_DIMM (ent->data); + obj =OBJECT (dev); + addr =object_property_get_uint (obj,PC_DIMM_ADDR_PROP ,NULL ); + size =object_property_get_uint (obj,PC_DIMM_SIZE_PROP ,NULL ); + node =object_property_get_uint (obj,PC_DIMM_NODE_PROP ,NULL ); + +if (base < addr) {
Quoted 8 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2358
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+build_srat_memory (numamem, base, addr - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); + numamem =acpi_data_push (table_data,sizeof *numamem); + } + build_srat_memory(numamem, addr, size, node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED |Is NVDIMM hotplug supported in QEMU?
If not we might need makeMEM_AFFINITY_HOTPLUGGABLEconditional too.
Yes, it's supported.
Quoted 5 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2360
Quoted 3 lines
hw/i386/acpi-build.c +2
-0+ (object_dynamic_cast (obj,TYPE_NVDIMM ) ? + MEM_AFFINITY_NON_VOLATILE : 0));it might be cleaner without inline flags duplication
Quoted 13 lines
flags = MEM_AFFINITY_ENABLED;
...
if (!ent) {
flags |= MEM_AFFINITY_HOTPLUGGABLE
}
...
if (PCDIMMDeviceInfo::hotpluggable) { // see ***
flags |= MEM_AFFINITY_HOTPLUGGABLE
}
...
if (object_dynamic_cast(obj, TYPE_NVDIMM))
flags |= MEM_AFFINITY_NON_VOLATILE
}I'm fine for such changes, except ***
[..]
Quoted 8 lines
Quoted 8 lines
hw/mem/pc-dimm.c +0
-0@@ -276,6 +276,14 @@ static int pc_dimm_built_list(Object *obj, void *opaque)return 0 ; }
Quoted 11 lines
hw/mem/pc-dimm.c static int pc_dimm_built_list(Object *obj, void *opaque) · line 285
Quoted 7 lines
hw/mem/pc-dimm.c +7
-0+GSList *pc_dimm_get_device_list (void ) +{ +GSList *list =NULL ; + +object_child_foreach (qdev_get_machine (), pc_dimm_built_list, &list); +return list; +}(***)
see http://lists.gnu.org/archive/html/qemu-ppc/2018-02/msg00271.html
You could do that in separate patch, so that it won't matter whose patch got merged first and it won't affect the rest of patches.
Sure, I can separate this part, but I would still like to use a list of PCDIMMDevice rather than a list of MemoryDeviceInfo. The latter would need to be extended to include NVDIMM information (e.g., adding a NVDIMMDeviceInfo to the union).
Haozhong
Quoted 25 lines
Quoted 24 lines
hw/mem/pc-dimm.c +0
-0uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t align, uint64_t size,include/hw/mem/pc-dimm.h +10
-0@@ -100,4 +100,14 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, Error **errp);void pc_dimm_memory_unplug (DeviceState *dev,MemoryHotplugState *hpms,MemoryRegion *mr); + +/* +* Return a list of DeviceState of pc-dimm and nvdimm devices. The +* list is sorted in the ascendant order of the base address of +* devices. +* +* Note: callers are responsible to free the list. +*/ +GSList *pc_dimm_get_device_list (void ); +#endif
Quoted 132 lines · On Thu, 1 Mar 2018 19:56:51 +0800 Haozhong Zhang <[email protected]>…
Quoted 14 lines · Igor Mammedov
Quoted 11 lines · On Wed, 28 Feb 2018 12:02:58 +0800 Haozhong Zhang <[email protected]>…
ACPI 6.2A Table 5-129 "SPA Range Structure" requires the proximity domain of a NVDIMM SPA range must match with corresponding entry in SRAT table.
The address ranges of vNVDIMM in QEMU are allocated from the hot-pluggable address space, which is entirely covered by one SRAT memory affinity structure. However, users can set the vNVDIMM proximity domain in NFIT SPA range structure by the 'node' property of '-device nvdimm' to a value different than the one in the above SRAT memory affinity structure.
Quoted 5 lines
Quoted 2 lines
In order to solve such proximity domain mismatch, this patch builds one SRAT memory affinity structure for each static-plugged DIMM device,
s/static-plugged/present at boot/
since after hotplug and following reset SRAT will be recreated and include hotplugged DIMMs as well.Ah yes, I'll fix the message in the next version.
Quoted 23 lines
Quoted 23 lines
including both PC-DIMM and NVDIMM, with the proximity domain specified in '-device pc-dimm' or '-device nvdimm'.
The remaining hot-pluggable address space is covered by one or multiple SRAT memory affinity structures with the proximity domain of the last node as before.
Signed-off-by Haozhong Zhang <[email protected]>--- hw/i386/acpi-build.c | 50 ++++++++++++++++++++++++++++++++++++++++++++---- hw/mem/pc-dimm.c | 8 ++++++++ include/hw/mem/pc-dimm.h | 10 ++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-)hw/i386/acpi-build.c +0
-0@@ -2323,6 +2323,49 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)#define HOLE_640K_START (640 * 1024)#define HOLE_640K_END (1024 * 1024)Quoted 14 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2337
Quoted 12 lines
hw/i386/acpi-build.c +12
-0+static void build_srat_hotpluggable_memory (GArray *table_data,uint64_t base, +uint64_t len,int default_node) +{ +GSList *dimms =pc_dimm_get_device_list (); +GSList *ent = dimms; +PCDIMMDevice *dev; +Object *obj; +uint64_t end = base + len, addr, size; +int node; +AcpiSratMemoryAffinity *numamem; + +while (base < end) {It's just matter of taste but wouldn't 'for' loop be better here? One can see start, end and next step from the begging.
will switch to a for loop
Quoted 16 lines
Quoted 16 lines
hw/i386/acpi-build.c +15
-0+ numamem =acpi_data_push (table_data,sizeof *numamem); + +if (!ent) { +build_srat_memory (numamem, base, end - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); +break ; + } + + dev =PC_DIMM (ent->data); + obj =OBJECT (dev); + addr =object_property_get_uint (obj,PC_DIMM_ADDR_PROP ,NULL ); + size =object_property_get_uint (obj,PC_DIMM_SIZE_PROP ,NULL ); + node =object_property_get_uint (obj,PC_DIMM_NODE_PROP ,NULL ); + +if (base < addr) {Quoted 8 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2358
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+build_srat_memory (numamem, base, addr - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); + numamem =acpi_data_push (table_data,sizeof *numamem); + } + build_srat_memory(numamem, addr, size, node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED |Is NVDIMM hotplug supported in QEMU?
If not we might need makeMEM_AFFINITY_HOTPLUGGABLEconditional too.Yes, it's supported.
Quoted 5 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2360
Quoted 3 lines
hw/i386/acpi-build.c +2
-0+ (object_dynamic_cast (obj,TYPE_NVDIMM ) ? + MEM_AFFINITY_NON_VOLATILE : 0));it might be cleaner without inline flags duplication
Quoted 13 lines
flags = MEM_AFFINITY_ENABLED; ... if (!ent) { flags |= MEM_AFFINITY_HOTPLUGGABLE } ... if (PCDIMMDeviceInfo::hotpluggable) { // see *** flags |= MEM_AFFINITY_HOTPLUGGABLE } ... if (object_dynamic_cast(obj, TYPE_NVDIMM)) flags |= MEM_AFFINITY_NON_VOLATILE }I'm fine for such changes, except ***
[..]
Quoted 8 lines
Quoted 8 lines
hw/mem/pc-dimm.c +0
-0@@ -276,6 +276,14 @@ static int pc_dimm_built_list(Object *obj, void *opaque)return 0 ; }Quoted 11 lines
hw/mem/pc-dimm.c static int pc_dimm_built_list(Object *obj, void *opaque) · line 285
Quoted 7 lines
hw/mem/pc-dimm.c +7
-0+GSList *pc_dimm_get_device_list (void ) +{ +GSList *list =NULL ; + +object_child_foreach (qdev_get_machine (), pc_dimm_built_list, &list); +return list; +}(***)
see http://lists.gnu.org/archive/html/qemu-ppc/2018-02/msg00271.html
You could do that in separate patch, so that it won't matter whose patch got merged first and it won't affect the rest of patches.
Quoted 4 lines
Sure, I can separate this part, but I would still like to use a list of PCDIMMDevice rather than a list of MemoryDeviceInfo. The latter would need to be extended to include NVDIMM information (e.g., adding a NVDIMMDeviceInfo to the union).
You don't have to add NVDIMMDeviceInfo until there would be need to expose NVDIMM specific information.
qmp_pc_dimm_device_list() API is sufficient in this case (modulo missing sorting).
Suggestion has been made to keep number of public APIs that do almost the same at minimum.
Quoted 27 lines
Haozhong
Quoted 25 lines
Quoted 24 lines
hw/mem/pc-dimm.c +0
-0uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t align, uint64_t size,include/hw/mem/pc-dimm.h +10
-0@@ -100,4 +100,14 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, Error **errp);void pc_dimm_memory_unplug (DeviceState *dev,MemoryHotplugState *hpms,MemoryRegion *mr); + +/* +* Return a list of DeviceState of pc-dimm and nvdimm devices. The +* list is sorted in the ascendant order of the base address of +* devices. +* +* Note: callers are responsible to free the list. +*/ +GSList *pc_dimm_get_device_list (void ); +#endif
Quoted 135 lines · Igor Mammedov
Quoted 132 lines · On Thu, 1 Mar 2018 19:56:51 +0800 Haozhong Zhang <[email protected]>…
Quoted 14 lines · Igor Mammedov
Quoted 11 lines · On Wed, 28 Feb 2018 12:02:58 +0800 Haozhong Zhang <[email protected]>…
ACPI 6.2A Table 5-129 "SPA Range Structure" requires the proximity domain of a NVDIMM SPA range must match with corresponding entry in SRAT table.
The address ranges of vNVDIMM in QEMU are allocated from the hot-pluggable address space, which is entirely covered by one SRAT memory affinity structure. However, users can set the vNVDIMM proximity domain in NFIT SPA range structure by the 'node' property of '-device nvdimm' to a value different than the one in the above SRAT memory affinity structure.
Quoted 5 lines
Quoted 2 lines
In order to solve such proximity domain mismatch, this patch builds one SRAT memory affinity structure for each static-plugged DIMM device,
s/static-plugged/present at boot/
since after hotplug and following reset SRAT will be recreated and include hotplugged DIMMs as well.Ah yes, I'll fix the message in the next version.
Quoted 23 lines
Quoted 23 lines
including both PC-DIMM and NVDIMM, with the proximity domain specified in '-device pc-dimm' or '-device nvdimm'.
The remaining hot-pluggable address space is covered by one or multiple SRAT memory affinity structures with the proximity domain of the last node as before.
Signed-off-by Haozhong Zhang <[email protected]>--- hw/i386/acpi-build.c | 50 ++++++++++++++++++++++++++++++++++++++++++++---- hw/mem/pc-dimm.c | 8 ++++++++ include/hw/mem/pc-dimm.h | 10 ++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-)hw/i386/acpi-build.c +0
-0@@ -2323,6 +2323,49 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)#define HOLE_640K_START (640 * 1024)#define HOLE_640K_END (1024 * 1024)Quoted 14 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2337
Quoted 12 lines
hw/i386/acpi-build.c +12
-0+static void build_srat_hotpluggable_memory (GArray *table_data,uint64_t base, +uint64_t len,int default_node) +{ +GSList *dimms =pc_dimm_get_device_list (); +GSList *ent = dimms; +PCDIMMDevice *dev; +Object *obj; +uint64_t end = base + len, addr, size; +int node; +AcpiSratMemoryAffinity *numamem; + +while (base < end) {It's just matter of taste but wouldn't 'for' loop be better here? One can see start, end and next step from the begging.
will switch to a for loop
Quoted 16 lines
Quoted 16 lines
hw/i386/acpi-build.c +15
-0+ numamem =acpi_data_push (table_data,sizeof *numamem); + +if (!ent) { +build_srat_memory (numamem, base, end - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); +break ; + } + + dev =PC_DIMM (ent->data); + obj =OBJECT (dev); + addr =object_property_get_uint (obj,PC_DIMM_ADDR_PROP ,NULL ); + size =object_property_get_uint (obj,PC_DIMM_SIZE_PROP ,NULL ); + node =object_property_get_uint (obj,PC_DIMM_NODE_PROP ,NULL ); + +if (base < addr) {Quoted 8 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2358
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+build_srat_memory (numamem, base, addr - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); + numamem =acpi_data_push (table_data,sizeof *numamem); + } + build_srat_memory(numamem, addr, size, node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED |Is NVDIMM hotplug supported in QEMU?
If not we might need makeMEM_AFFINITY_HOTPLUGGABLEconditional too.Yes, it's supported.
Quoted 5 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2360
Quoted 3 lines
hw/i386/acpi-build.c +2
-0+ (object_dynamic_cast (obj,TYPE_NVDIMM ) ? + MEM_AFFINITY_NON_VOLATILE : 0));it might be cleaner without inline flags duplication
Quoted 13 lines
flags = MEM_AFFINITY_ENABLED; ... if (!ent) { flags |= MEM_AFFINITY_HOTPLUGGABLE } ... if (PCDIMMDeviceInfo::hotpluggable) { // see *** flags |= MEM_AFFINITY_HOTPLUGGABLE } ... if (object_dynamic_cast(obj, TYPE_NVDIMM)) flags |= MEM_AFFINITY_NON_VOLATILE }I'm fine for such changes, except ***
[..]
Quoted 19 lines
Quoted 5 lines
hw/mem/pc-dimm.c +0
-0hw/mem/pc-dimm.c static int pc_dimm_built_list(Object *obj, void *opaque) · line 285
Quoted 10 lines
hw/mem/pc-dimm.c +7
-0@@ -276,6 +276,14 @@ static int pc_dimm_built_list(Object *obj, void *opaque)return 0 ; } +GSList *pc_dimm_get_device_list (void ) +{ +GSList *list =NULL ; + +object_child_foreach (qdev_get_machine (), pc_dimm_built_list, &list); +return list; +}(***)
see http://lists.gnu.org/archive/html/qemu-ppc/2018-02/msg00271.html
You could do that in separate patch, so that it won't matter whose patch got merged first and it won't affect the rest of patches.
Quoted 6 lines
Quoted 4 lines
Sure, I can separate this part, but I would still like to use a list of PCDIMMDevice rather than a list of MemoryDeviceInfo. The latter would need to be extended to include NVDIMM information (e.g., adding a NVDIMMDeviceInfo to the union).
You don't have to add NVDIMMDeviceInfo until there would be need to expose NVDIMM specific information.
Well, I need to know whether a memory device is NVDIMM in order to decide whether the non-volatile flag is need in SRAT.
Quoted 3 lines
qmp_pc_dimm_device_list()API is sufficient in this case (modulo missing sorting).
sorting is not a big issue and can be easily added by using pc_dimm_built_list in qmp_pc_dimm_device_list().
Haozhong
Quoted 3 lines
Suggestion has been made to keep number of public APIs that do almost the same at minimum.
Quoted 140 lines · On Thu, 1 Mar 2018 21:12:37 +0800 Haozhong Zhang <[email protected]>…
Quoted 139 lines · Igor Mammedov
Quoted 136 lines · On Thu, 1 Mar 2018 19:56:51 +0800 Haozhong Zhang <[email protected]>…
Quoted 14 lines · Igor Mammedov
Quoted 11 lines · On Wed, 28 Feb 2018 12:02:58 +0800 Haozhong Zhang <[email protected]>…
ACPI 6.2A Table 5-129 "SPA Range Structure" requires the proximity domain of a NVDIMM SPA range must match with corresponding entry in SRAT table.
The address ranges of vNVDIMM in QEMU are allocated from the hot-pluggable address space, which is entirely covered by one SRAT memory affinity structure. However, users can set the vNVDIMM proximity domain in NFIT SPA range structure by the 'node' property of '-device nvdimm' to a value different than the one in the above SRAT memory affinity structure.
Quoted 5 lines
Quoted 2 lines
In order to solve such proximity domain mismatch, this patch builds one SRAT memory affinity structure for each static-plugged DIMM device,
s/static-plugged/present at boot/
since after hotplug and following reset SRAT will be recreated and include hotplugged DIMMs as well.Ah yes, I'll fix the message in the next version.
Quoted 23 lines
Quoted 23 lines
including both PC-DIMM and NVDIMM, with the proximity domain specified in '-device pc-dimm' or '-device nvdimm'.
The remaining hot-pluggable address space is covered by one or multiple SRAT memory affinity structures with the proximity domain of the last node as before.
Signed-off-by Haozhong Zhang <[email protected]>--- hw/i386/acpi-build.c | 50 ++++++++++++++++++++++++++++++++++++++++++++---- hw/mem/pc-dimm.c | 8 ++++++++ include/hw/mem/pc-dimm.h | 10 ++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-)hw/i386/acpi-build.c +0
-0@@ -2323,6 +2323,49 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)#define HOLE_640K_START (640 * 1024)#define HOLE_640K_END (1024 * 1024)Quoted 14 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2337
Quoted 12 lines
hw/i386/acpi-build.c +12
-0+static void build_srat_hotpluggable_memory (GArray *table_data,uint64_t base, +uint64_t len,int default_node) +{ +GSList *dimms =pc_dimm_get_device_list (); +GSList *ent = dimms; +PCDIMMDevice *dev; +Object *obj; +uint64_t end = base + len, addr, size; +int node; +AcpiSratMemoryAffinity *numamem; + +while (base < end) {It's just matter of taste but wouldn't 'for' loop be better here? One can see start, end and next step from the begging.
will switch to a for loop
Quoted 16 lines
Quoted 16 lines
hw/i386/acpi-build.c +15
-0+ numamem =acpi_data_push (table_data,sizeof *numamem); + +if (!ent) { +build_srat_memory (numamem, base, end - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); +break ; + } + + dev =PC_DIMM (ent->data); + obj =OBJECT (dev); + addr =object_property_get_uint (obj,PC_DIMM_ADDR_PROP ,NULL ); + size =object_property_get_uint (obj,PC_DIMM_SIZE_PROP ,NULL ); + node =object_property_get_uint (obj,PC_DIMM_NODE_PROP ,NULL ); + +if (base < addr) {Quoted 8 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2358
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+build_srat_memory (numamem, base, addr - base, default_node, +MEM_AFFINITY_HOTPLUGGABLE |MEM_AFFINITY_ENABLED ); + numamem =acpi_data_push (table_data,sizeof *numamem); + } + build_srat_memory(numamem, addr, size, node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED |Is NVDIMM hotplug supported in QEMU?
If not we might need makeMEM_AFFINITY_HOTPLUGGABLEconditional too.Yes, it's supported.
Quoted 5 lines
hw/i386/acpi-build.c build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) · line 2360
Quoted 3 lines
hw/i386/acpi-build.c +2
-0+ (object_dynamic_cast (obj,TYPE_NVDIMM ) ? + MEM_AFFINITY_NON_VOLATILE : 0));it might be cleaner without inline flags duplication
Quoted 13 lines
flags = MEM_AFFINITY_ENABLED; ... if (!ent) { flags |= MEM_AFFINITY_HOTPLUGGABLE } ... if (PCDIMMDeviceInfo::hotpluggable) { // see *** flags |= MEM_AFFINITY_HOTPLUGGABLE } ... if (object_dynamic_cast(obj, TYPE_NVDIMM)) flags |= MEM_AFFINITY_NON_VOLATILE }I'm fine for such changes, except ***
[..]
Quoted 8 lines
Quoted 8 lines
hw/mem/pc-dimm.c +0
-0@@ -276,6 +276,14 @@ static int pc_dimm_built_list(Object *obj, void *opaque)return 0 ; }Quoted 11 lines
hw/mem/pc-dimm.c static int pc_dimm_built_list(Object *obj, void *opaque) · line 285
Quoted 7 lines
hw/mem/pc-dimm.c +7
-0+GSList *pc_dimm_get_device_list (void ) +{ +GSList *list =NULL ; + +object_child_foreach (qdev_get_machine (), pc_dimm_built_list, &list); +return list; +}(***)
see http://lists.gnu.org/archive/html/qemu-ppc/2018-02/msg00271.html
You could do that in separate patch, so that it won't matter whose patch got merged first and it won't affect the rest of patches.Sure, I can separate this part, but I would still like to use a list of PCDIMMDevice rather than a list of MemoryDeviceInfo. The latter would need to be extended to include NVDIMM information (e.g., adding a NVDIMMDeviceInfo to the union).
Quoted 5 lines
Quoted 2 lines
You don't have to add NVDIMMDeviceInfo until there would be need to expose NVDIMM specific information.
Well, I need to know whether a memory device is NVDIMM in order to decide whether the non-volatile flag is need in SRAT.
Maybe we should add NVDIMMDeviceInfo after all,
extra benefit of it would be that HMP 'info memory-devices' and QMP query-memory-devices would show correct device type.
We can do something like this for starters
+##
+# @NVDIMMDeviceInfo:
+#
+# 'nvdimm' device state information
+#
+# Since: 2.12
+##
+{ 'struct': 'NVDIMMDeviceInfo',
+ 'base': 'PCDIMMDeviceInfo',
+ 'data': {}
+}
and later extend 'data' section with nvdimm specific data when necessary
Quoted 12 lines
Quoted 2 lines
qmp_pc_dimm_device_list()API is sufficient in this case (modulo missing sorting).sorting is not a big issue and can be easily added by using
pc_dimm_built_listinqmp_pc_dimm_device_list().Haozhong
Quoted 3 lines
Suggestion has been made to keep number of public APIs that do almost the same at minimum.
PATCH v2 2/3 tests/bios-tables-test: allow setting extra machine options
In reply to Haozhong ZhangSome test cases may require extra machine options than the those used in the current test_acpi_ones(), e.g., nvdimm test cases require the machine option 'nvdimm=on'.
--- tests/bios-tables-test.c | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-)
tests/bios-tables-test.c +29 -16
@@ -654,17 +654,22 @@ static void test_smbios_structs(test_data *data) } } -static void test_acpi_one (const char *params,test_data *data) +static void test_acpi_one (const char *extra_machine_opts, +const char *params,test_data *data) {char *args;/* Disable kernel irqchip to be able to override apic irq0. */ - args =g_strdup_printf ("-machine %s,accel=%s,kernel-irqchip=off " + args =g_strdup_printf ("-machine %s,accel=%s,kernel-irqchip=off" , + data->machine,"kvm:tcg" ); +if (extra_machine_opts) { + args =g_strdup_printf ("%s,%s" , args, extra_machine_opts); + } + args =g_strdup_printf ("%s " "-net none -display none %s " "-drive id=hd0,if=none,file=%s,format=raw " "-device ide-hd,drive=hd0 " , - data->machine,"kvm:tcg" , - params ? params :"" , disk); + args, params ? params :"" , disk);qtest_start (args);
@@ -711,7 +716,7 @@ static void test_acpi_piix4_tcg(void) data.machine =MACHINE_PC ; data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); -test_acpi_one (NULL , &data); +test_acpi_one (NULL ,NULL , &data);free_test_data (&data); }
@@ -724,7 +729,7 @@ static void test_acpi_piix4_tcg_bridge(void) data.variant =".bridge" ; data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); -test_acpi_one ("-device pci-bridge,chassis_nr=1" , &data); +test_acpi_one (NULL ,"-device pci-bridge,chassis_nr=1" , &data);free_test_data (&data); }
@@ -736,7 +741,7 @@ static void test_acpi_q35_tcg(void) data.machine =MACHINE_Q35 ; data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); -test_acpi_one (NULL , &data); +test_acpi_one (NULL ,NULL , &data);free_test_data (&data); }
@@ -749,7 +754,7 @@ static void test_acpi_q35_tcg_bridge(void) data.variant =".bridge" ; data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); -test_acpi_one ("-device pci-bridge,chassis_nr=1" , +test_acpi_one (NULL ,"-device pci-bridge,chassis_nr=1" , &data);free_test_data (&data); }
@@ -761,7 +766,8 @@ static void test_acpi_piix4_tcg_cphp(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_PC ; data.variant =".cphp" ; -test_acpi_one ("-smp 2,cores=3,sockets=2,maxcpus=6" +test_acpi_one (NULL , +"-smp 2,cores=3,sockets=2,maxcpus=6" " -numa node -numa node" " -numa dist,src=0,dst=1,val=21" , &data);
@@ -775,7 +781,8 @@ static void test_acpi_q35_tcg_cphp(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_Q35 ; data.variant =".cphp" ; -test_acpi_one (" -smp 2,cores=3,sockets=2,maxcpus=6" +test_acpi_one (NULL , +" -smp 2,cores=3,sockets=2,maxcpus=6" " -numa node -numa node" " -numa dist,src=0,dst=1,val=21" , &data);
@@ -795,7 +802,8 @@ static void test_acpi_q35_tcg_ipmi(void) data.variant =".ipmibt" ; data.required_struct_types = ipmi_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (ipmi_required_struct_types); -test_acpi_one ("-device ipmi-bmc-sim,id=bmc0" +test_acpi_one (NULL , +"-device ipmi-bmc-sim,id=bmc0" " -device isa-ipmi-bt,bmc=bmc0" , &data);free_test_data (&data);
@@ -813,7 +821,8 @@ static void test_acpi_piix4_tcg_ipmi(void) data.variant =".ipmikcs" ; data.required_struct_types = ipmi_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (ipmi_required_struct_types); -test_acpi_one ("-device ipmi-bmc-sim,id=bmc0" +test_acpi_one (NULL , +"-device ipmi-bmc-sim,id=bmc0" " -device isa-ipmi-kcs,irq=0,bmc=bmc0" , &data);free_test_data (&data);
@@ -826,7 +835,8 @@ static void test_acpi_q35_tcg_memhp(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_Q35 ; data.variant =".memhp" ; -test_acpi_one (" -m 128,slots=3,maxmem=1G" +test_acpi_one (NULL , +" -m 128,slots=3,maxmem=1G" " -numa node -numa node" " -numa dist,src=0,dst=1,val=21" , &data);
@@ -840,7 +850,8 @@ static void test_acpi_piix4_tcg_memhp(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_PC ; data.variant =".memhp" ; -test_acpi_one (" -m 128,slots=3,maxmem=1G" +test_acpi_one (NULL , +" -m 128,slots=3,maxmem=1G" " -numa node -numa node" " -numa dist,src=0,dst=1,val=21" , &data);
@@ -854,7 +865,8 @@ static void test_acpi_q35_tcg_numamem(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_Q35 ; data.variant =".numamem" ; -test_acpi_one (" -numa node -numa node,mem=128" , &data); +test_acpi_one (NULL , +" -numa node -numa node,mem=128" , &data);free_test_data (&data); }
@@ -865,7 +877,8 @@ static void test_acpi_piix4_tcg_numamem(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_PC ; data.variant =".numamem" ; -test_acpi_one (" -numa node -numa node,mem=128" , &data); +test_acpi_one (NULL , +" -numa node -numa node,mem=128" , &data);free_test_data (&data); }
Signature · 1 line
2.14.1
PATCH v2 3/3 tests/bios-tables-test: add test cases for DIMM proximity
In reply to Haozhong ZhangQEMU now builds one SRAT memory affinity structure for each static-plugged PC-DIMM and NVDIMM device with the proximity domain specified in the device option 'node', rather than only one SRAT memory affinity structure covering the entire hotpluggable address space with the proximity domain of the last node.
Add test cases on PC and Q35 machines with 3 proximity domains, and one PC-DIMM and one NVDIMM attached to the second proximity domain. Check whether the QEMU-built SRAT tables match with the expected ones.
--- tests/acpi-test-data/pc/APIC.dimmpxm | Bin 0 -> 136 bytes tests/acpi-test-data/pc/DSDT.dimmpxm | Bin 0 -> 6710 bytes tests/acpi-test-data/pc/NFIT.dimmpxm | Bin 0 -> 224 bytes tests/acpi-test-data/pc/SRAT.dimmpxm | Bin 0 -> 416 bytes tests/acpi-test-data/pc/SSDT.dimmpxm | Bin 0 -> 685 bytes tests/acpi-test-data/q35/APIC.dimmpxm | Bin 0 -> 136 bytes tests/acpi-test-data/q35/DSDT.dimmpxm | Bin 0 -> 9394 bytes tests/acpi-test-data/q35/NFIT.dimmpxm | Bin 0 -> 224 bytes tests/acpi-test-data/q35/SRAT.dimmpxm | Bin 0 -> 416 bytes tests/acpi-test-data/q35/SSDT.dimmpxm | Bin 0 -> 685 bytes tests/bios-tables-test.c | 33 +++++++++++++++++++++++++++++++++ 11 files changed, 33 insertions(+) create mode 100644 tests/acpi-test-data/pc/APIC.dimmpxm create mode 100644 tests/acpi-test-data/pc/DSDT.dimmpxm create mode 100644 tests/acpi-test-data/pc/NFIT.dimmpxm create mode 100644 tests/acpi-test-data/pc/SRAT.dimmpxm create mode 100644 tests/acpi-test-data/pc/SSDT.dimmpxm create mode 100644 tests/acpi-test-data/q35/APIC.dimmpxm create mode 100644 tests/acpi-test-data/q35/DSDT.dimmpxm create mode 100644 tests/acpi-test-data/q35/NFIT.dimmpxm create mode 100644 tests/acpi-test-data/q35/SRAT.dimmpxm create mode 100644 tests/acpi-test-data/q35/SSDT.dimmpxm
tests/acpi-test-data/pc/APIC.dimmpxm new file binary +0 -0
tests/acpi-test-data/pc/DSDT.dimmpxm new file binary +0 -0
tests/acpi-test-data/pc/NFIT.dimmpxm new file binary +0 -0
tests/acpi-test-data/pc/SRAT.dimmpxm new file binary +0 -0
tests/acpi-test-data/pc/SSDT.dimmpxm new file binary +0 -0
tests/acpi-test-data/q35/APIC.dimmpxm new file binary +0 -0
tests/acpi-test-data/q35/DSDT.dimmpxm new file binary +0 -0
tests/acpi-test-data/q35/NFIT.dimmpxm new file binary +0 -0
tests/acpi-test-data/q35/SRAT.dimmpxm new file binary +0 -0
tests/acpi-test-data/q35/SSDT.dimmpxm new file binary +0 -0
tests/bios-tables-test.c +33 -0
@@ -882,6 +882,37 @@ static void test_acpi_piix4_tcg_numamem(void)free_test_data (&data); } +static void test_acpi_tcg_dimm_pxm (const char *machine) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine = machine; + data.variant =".dimmpxm" ; +test_acpi_one ("nvdimm=on" , +" -smp 3" +" -m 128M,slots=3,maxmem=1G" +" -numa node,mem=32M,cpus=0,nodeid=0" +" -numa node,mem=32M,cpus=1,nodeid=1" +" -numa node,mem=64M,cpus=2,nodeid=2" +" -object memory-backend-ram,id=ram0,size=128M" +" -object memory-backend-ram,id=nvm0,size=128M" +" -device pc-dimm,id=dimm0,memdev=ram0,node=1" +" -device nvdimm,id=dimm1,memdev=nvm0,node=1" , + &data); +free_test_data (&data); +} + +static void test_acpi_q35_tcg_dimm_pxm (void ) +{ +test_acpi_tcg_dimm_pxm (MACHINE_Q35 ); +} + +static void test_acpi_piix4_tcg_dimm_pxm (void ) +{ +test_acpi_tcg_dimm_pxm (MACHINE_PC ); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();
@@ -906,6 +937,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp);qtest_add_func ("acpi/piix4/numamem" , test_acpi_piix4_tcg_numamem);qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_tcg_numamem); +qtest_add_func ("acpi/piix4/dimmpxm" , test_acpi_piix4_tcg_dimm_pxm); +qtest_add_func ("acpi/q35/dimmpxm" , test_acpi_q35_tcg_dimm_pxm); } ret =g_test_run ();boot_sector_cleanup (disk);
Signature · 1 line
2.14.1