account for NVDIMM nodes during SRAT generation
v2 cover account for NVDIMM nodes during SRAT generation
Changes since v1:
- Use error_abort for getters (Igor)
- Free the device list (Igor)
- Refactor the NVDIMM related portion into hw/acpi/nvdimm.c (Igor)
- Rebase onto latest master
- Add Jingqi's Reviewed-by
On the command line, one can specify a NUMA node for NVDIMM devices. If we set up the topology to give NVDIMMs their own nodes, i.e. not containing any CPUs or regular memory, qemu doesn't populate SRAT memory affinity structures for these nodes. However the NFIT does reference those proximity domains.
As a result, Linux, while parsing the SRAT, fails to initialize node related structures for these nodes, and they never end up in the nodes_possible map. When these are onlined at a later point (via hotplug), this causes problems.
I've followed the instructions in bios-tables-test.c to update the expected SRAT binary, and the tests (make check) pass. Patches 1 and 3 are the relevant ones for the binary update.
Patch 2 is the main patch which changes SRAT generation.
Vishal Verma (3):
diffs-allowed: add the SRAT AML to diffs-allowed hw/acpi-build: account for NVDIMM numa nodes in SRAT tests/acpi: update expected SRAT files
hw/acpi/nvdimm.c | 26 ++++++++++++++++++++++++++ hw/i386/acpi-build.c | 10 ++++++++++ include/hw/mem/nvdimm.h | 1 + tests/data/acpi/pc/SRAT.dimmpxm | Bin 392 -> 392 bytes tests/data/acpi/q35/SRAT.dimmpxm | Bin 392 -> 392 bytes 5 files changed, 37 insertions(+)
Signature · 1 line
2.26.2
PATCH v2 1/3 diffs-allowed: add the SRAT AML to diffs-allowed
In anticipation of a change to the SRAT generation in qemu, add the AML file to diffs-allowed.
--- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+)
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
@@ -1 +1,2 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/SRAT.dimmpxm",
Signature · 1 line
2.26.2
PATCH v2 2/3 hw/acpi-build: account for NVDIMM numa nodes in SRAT
In reply to Vishal VermaNVDIMMs can belong to their own proximity domains, as described by the NFIT. In such cases, the SRAT needs to have Memory Affinity structures in the SRAT for these NVDIMMs, otherwise Linux doesn't populate node data structures properly during NUMA initialization. See the following for an example failure case.
https://lore.kernel.org/linux-nvdimm/[email protected]/
Fix this by adding device address range and node information from NVDIMMs to the SRAT in build_srat().
The relevant command line options to exercise this are below. Nodes 0-1 contain CPUs and regular memory, and nodes 2-3 are the NVDIMM address space.
-numa node,nodeid=0,mem=2048M,
-numa node,nodeid=1,mem=2048M,
-numa node,nodeid=2,mem=0,
-object memory-backend-file,id=nvmem0,share,mem-path=nvdimm-0,size=16384M,align=128M -device nvdimm,memdev=nvmem0,id=nv0,label-size=2M,node=2
-numa node,nodeid=3,mem=0,
-object memory-backend-file,id=nvmem1,share,mem-path=nvdimm-1,size=16384M,align=128M -device nvdimm,memdev=nvmem1,id=nv1,label-size=2M,node=3
--- hw/acpi/nvdimm.c | 26 ++++++++++++++++++++++++++ hw/i386/acpi-build.c | 10 ++++++++++ include/hw/mem/nvdimm.h | 1 + 3 files changed, 37 insertions(+)
hw/acpi/nvdimm.c +26 -0
@@ -28,6 +28,7 @@#include "qemu/osdep.h" #include "qemu/uuid.h" +#include "qapi/error.h" #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/bios-linker-loader.h"
@@ -1334,6 +1335,31 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,free_aml_allocator (); } +void *nvdimm_build_srat (GArray *table_data) +{ +AcpiSratMemoryAffinity *numamem =NULL ; +GSList *device_list =nvdimm_get_device_list (); + +for (; device_list; device_list = device_list->next) { +DeviceState *dev = device_list->data; +uint64_t addr, size; +int node; + + node =object_property_get_int (OBJECT (dev),PC_DIMM_NODE_PROP , + &error_abort); + addr =object_property_get_uint (OBJECT (dev),PC_DIMM_ADDR_PROP , + &error_abort); + size =object_property_get_uint (OBJECT (dev),PC_DIMM_SIZE_PROP , + &error_abort); + + numamem =acpi_data_push (table_data,sizeof *numamem); +build_srat_memory (numamem, addr, size, node, +MEM_AFFINITY_ENABLED |MEM_AFFINITY_NON_VOLATILE ); + } +g_slist_free (device_list); +return numamem; +} +void nvdimm_build_acpi (GArray *table_offsets,GArray *table_data,BIOSLinker *linker,NVDIMMState *state,uint32_t ram_slots)
hw/i386/acpi-build.c +10 -0
@@ -2428,6 +2428,16 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) MEM_AFFINITY_ENABLED); } } + +if (machine->nvdimms_state->is_enabled) { +void *ret; + + ret =nvdimm_build_srat (table_data); +if (ret !=NULL ) { + numamem = ret; + } + } + slots = (table_data->len - numa_start) /sizeof *numamem;for (; slots < pcms->numa_nodes +2 ; slots++) { numamem =acpi_data_push (table_data,sizeof *numamem);
include/hw/mem/nvdimm.h +1 -0
@@ -155,6 +155,7 @@ typedef struct NVDIMMState NVDIMMState;void nvdimm_init_acpi_state (NVDIMMState *state,MemoryRegion *io,struct AcpiGenericAddress dsm_io,FWCfgState *fw_cfg,Object *owner); +void *nvdimm_build_srat (GArray *table_data);void nvdimm_build_acpi (GArray *table_offsets,GArray *table_data,BIOSLinker *linker,NVDIMMState *state,uint32_t ram_slots);
Signature · 1 line
2.26.2
Re: [PATCH v2 2/3] hw/acpi-build: account for NVDIMM numa nodes in SRAT
Quoted 47 lines · On Wed, 27 May 2020 23:48:06 -0600 Vishal Verma <[email protected]>…
NVDIMMs can belong to their own proximity domains, as described by the NFIT. In such cases, the SRAT needs to have Memory Affinity structures in the SRAT for these NVDIMMs, otherwise Linux doesn't populate node data structures properly during NUMA initialization. See the following for an example failure case.
https://lore.kernel.org/linux-nvdimm/[email protected]/
Fix this by adding device address range and node information from NVDIMMs to the SRAT in
build_srat().The relevant command line options to exercise this are below. Nodes 0-1 contain CPUs and regular memory, and nodes 2-3 are the NVDIMM address space.
-numa node,nodeid=0,mem=2048M,
-numa node,nodeid=1,mem=2048M,
-numa node,nodeid=2,mem=0,
-object memory-backend-file,id=nvmem0,share,mem-path=nvdimm-0,size=16384M,align=128M -device nvdimm,memdev=nvmem0,id=nv0,label-size=2M,node=2
-numa node,nodeid=3,mem=0,
-object memory-backend-file,id=nvmem1,share,mem-path=nvdimm-1,size=16384M,align=128M -device nvdimm,memdev=nvmem1,id=nv1,label-size=2M,node=3Cc Jingqi Liu <[email protected]>Cc Michael S. Tsirkin <[email protected]>Reviewed-by Jingqi Liu <[email protected]>Signed-off-by Vishal Verma <[email protected]>--- hw/acpi/nvdimm.c | 26 ++++++++++++++++++++++++++ hw/i386/acpi-build.c | 10 ++++++++++ include/hw/mem/nvdimm.h | 1 + 3 files changed, 37 insertions(+)hw/acpi/nvdimm.c +1
-0@@ -28,6 +28,7 @@#include "qemu/osdep.h" #include "qemu/uuid.h" +#include "qapi/error.h" #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/bios-linker-loader.h"
hw/acpi/nvdimm.c static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, · line 1344
Quoted 10 lines
hw/acpi/nvdimm.c +7
-0@@ -1334,6 +1335,31 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,free_aml_allocator (); } +void *nvdimm_build_srat (GArray *table_data) +{ +AcpiSratMemoryAffinity *numamem =NULL ; +GSList *device_list =nvdimm_get_device_list (); + +for (; device_list; device_list = device_list->next) { +DeviceState *dev = device_list->data;
I'd use Object here with OBJECT() cast and drop casts beolw in property getters
Quoted 27 lines
hw/acpi/nvdimm.c +18
-0+uint64_t addr, size; +int node; + + node =object_property_get_int (OBJECT (dev),PC_DIMM_NODE_PROP , + &error_abort); + addr =object_property_get_uint (OBJECT (dev),PC_DIMM_ADDR_PROP , + &error_abort); + size =object_property_get_uint (OBJECT (dev),PC_DIMM_SIZE_PROP , + &error_abort); + + numamem =acpi_data_push (table_data,sizeof *numamem); +build_srat_memory (numamem, addr, size, node, +MEM_AFFINITY_ENABLED |MEM_AFFINITY_NON_VOLATILE ); + } +g_slist_free (device_list); +return numamem; +} +void nvdimm_build_acpi (GArray *table_offsets,GArray *table_data,BIOSLinker *linker,NVDIMMState *state,uint32_t ram_slots)hw/i386/acpi-build.c +0
-0@@ -2428,6 +2428,16 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) MEM_AFFINITY_ENABLED);
hw/i386/acpi-build.c build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) · line 2438
Quoted 10 lines
hw/i386/acpi-build.c +8
-0} } + +if (machine->nvdimms_state->is_enabled) { +void *ret; + + ret =nvdimm_build_srat (table_data); +if (ret !=NULL ) { + numamem = ret; + }
why do we need return value here and a test condition and assign 'ret' to numamem?
Quoted 17 lines
hw/i386/acpi-build.c +2
-0+ } + slots = (table_data->len - numa_start) /sizeof *numamem;for (; slots < pcms->numa_nodes +2 ; slots++) { numamem =acpi_data_push (table_data,sizeof *numamem);include/hw/mem/nvdimm.h +1
-0@@ -155,6 +155,7 @@ typedef struct NVDIMMState NVDIMMState;void nvdimm_init_acpi_state (NVDIMMState *state,MemoryRegion *io,struct AcpiGenericAddress dsm_io,FWCfgState *fw_cfg,Object *owner); +void *nvdimm_build_srat (GArray *table_data);void nvdimm_build_acpi (GArray *table_offsets,GArray *table_data,BIOSLinker *linker,NVDIMMState *state,uint32_t ram_slots);
Re: [PATCH v2 2/3] hw/acpi-build: account for NVDIMM numa nodes in SRAT
On Thu, 2020-05-28 at 13:19 +0200, Igor Mammedov wrote:
[..]
Quoted 4 lines
Quoted 4 lines
hw/acpi/nvdimm.c +0
-0@@ -1334,6 +1335,31 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,free_aml_allocator (); }
Quoted 9 lines
hw/acpi/nvdimm.c static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, · line 1344
Quoted 7 lines
hw/acpi/nvdimm.c +7
-0+void *nvdimm_build_srat (GArray *table_data) +{ +AcpiSratMemoryAffinity *numamem =NULL ; +GSList *device_list =nvdimm_get_device_list (); + +for (; device_list; device_list = device_list->next) { +DeviceState *dev = device_list->data;I'd use Object here with
OBJECT()cast and drop casts beolw in property getters
Done, that makes it much cleaner.
Quoted 10 lines
Quoted 10 lines
hw/i386/acpi-build.c +2
-0@@ -2428,6 +2428,16 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) MEM_AFFINITY_ENABLED); } } + +if (machine->nvdimms_state->is_enabled) {
Quoted 8 lines
hw/i386/acpi-build.c build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) · line 2438
Quoted 6 lines
hw/i386/acpi-build.c +6
-0+void *ret; + + ret =nvdimm_build_srat (table_data); +if (ret !=NULL ) { + numamem = ret; + }why do we need return value here and a test condition and assign 'ret' to numamem?
Ah I thought numamem was propagated through the different parts of the build_srat flow, but I misread. You're right it is not needed, removing.
PATCH v2 3/3 tests/acpi: update expected SRAT files
In reply to Vishal VermaUpdate the expected SRAT files for the change to account for NVDIMM numa nodes in the SRAT.
AML Diff:
--- /tmp/asl-V49YJ0.dsl 2020-04-27 18:50:52.680043327 -0600
+++ /tmp/asl-48AZJ0.dsl 2020-04-27 18:50:52.679043344 -0600
@@ -3,7 +3,7 @@
* AML/ASL+ Disassembler version 20190509 (64-bit version)
* Copyright (c) 2000 - 2019 Intel Corporation
*
- * Disassembly of tests/data/acpi/pc/SRAT.dimmpxm, Mon Apr 27 18:50:52 2020
+ * Disassembly of /tmp/aml-U3BZJ0, Mon Apr 27 18:50:52 2020
*
* ACPI Data Table [SRAT]
*
@@ -13,7 +13,7 @@
[000h 0000 4] Signature : "SRAT" [System Resource Affinity Table]
[004h 0004 4] Table Length : 00000188
[008h 0008 1] Revision : 01
-[009h 0009 1] Checksum : 80
+[009h 0009 1] Checksum : 68
[00Ah 0010 6] Oem ID : "BOCHS "
[010h 0016 8] Oem Table ID : "BXPCSRAT"
[018h 0024 4] Oem Revision : 00000001 @@ -140,15 +140,15 @@
[138h 0312 1] Subtable Type : 01 [Memory Affinity]
[139h 0313 1] Length : 28
-[13Ah 0314 4] Proximity Domain : 00000000 +[13Ah 0314 4] Proximity Domain : 00000002 [13Eh 0318 2] Reserved1 : 0000 -[140h 0320 8] Base Address : 0000000000000000 -[148h 0328 8] Address Length : 0000000000000000 +[140h 0320 8] Base Address : 0000000108000000 +[148h 0328 8] Address Length : 0000000008000000 [150h 0336 4] Reserved2 : 00000000 -[154h 0340 4] Flags (decoded below) : 00000000
- Enabled : 0
+[154h 0340 4] Flags (decoded below) : 00000005
+ Enabled : 1
Hot Pluggable : 0
- Non-Volatile : 0
+ Non-Volatile : 1
[158h 0344 8] Reserved3 : 0000000000000000
[160h 0352 1] Subtable Type : 01 [Memory Affinity]
@@ -167,7 +167,7 @@
Raw Table Data: Length 392 (0x188)
- 0000: 53 52 41 54 88 01 00 00 01 80 42 4F 43 48 53 20 // SRAT......BOCHS
+ 0000: 53 52 41 54 88 01 00 00 01 68 42 4F 43 48 53 20 // SRAT.....hBOCHS
0010: 42 58 50 43 53 52 41 54 01 00 00 00 42 58 50 43 // BXPCSRAT....BXPC
0020: 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 // ................
0030: 00 10 00 00 01 00 00 00 00 00 00 00 00 00 00 00 // ................
@@ -186,9 +186,9 @@
0100: 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 // ................
0110: 01 28 03 00 00 00 00 00 00 00 00 06 00 00 00 00 // .(..............
0120: 00 00 00 02 00 00 00 00 00 00 00 00 01 00 00 00 // ................
- 0130: 00 00 00 00 00 00 00 00 01 28 00 00 00 00 00 00 // .........(......
- 0140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
- 0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
+ 0130: 00 00 00 00 00 00 00 00 01 28 02 00 00 00 00 00 // .........(......
+ 0140: 00 00 00 08 01 00 00 00 00 00 00 08 00 00 00 00 // ................
+ 0150: 00 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 // ................
0160: 01 28 03 00 00 00 00 00 00 00 00 00 01 00 00 00 // .(..............
0170: 00 00 00 F8 00 00 00 00 00 00 00 00 03 00 00 00 // ................
0180: 00 00 00 00 00 00 00 00 // ........--- tests/data/acpi/pc/SRAT.dimmpxm | Bin 392 -> 392 bytes tests/data/acpi/q35/SRAT.dimmpxm | Bin 392 -> 392 bytes tests/qtest/bios-tables-test-allowed-diff.h | 1 - 3 files changed, 1 deletion(-)
tests/data/acpi/pc/SRAT.dimmpxm binary +0 -0
tests/data/acpi/q35/SRAT.dimmpxm binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
@@ -1,2 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/SRAT.dimmpxm",
Signature · 1 line
2.26.2
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Subject: [PATCH v2 0/3] account for NVDIMM nodes during SRAT generation
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Switched to a new branch 'test'
92f6e3c tests/acpi: update expected SRAT files 325a20a hw/acpi-build: account for NVDIMM numa nodes in SRAT ff8f589 diffs-allowed: add the SRAT AML to diffs-allowed
=== OUTPUT BEGIN ===
1/3 Checking commit ff8f5897d948 (diffs-allowed: add the SRAT AML to diffs-allowed)
2/3 Checking commit 325a20aae003 (hw/acpi-build: account for NVDIMM numa nodes in SRAT)
3/3 Checking commit 92f6e3cdac4c (tests/acpi: update expected SRAT files)
ERROR: Do not add expected files together with tests, follow instructions in tests/qtest/bios-tables-test.c: both tests/data/acpi/q35/SRAT.dimmpxm and tests/qtest/bios-tables-test-allowed-diff.h found
ERROR: Do not add expected files together with tests, follow instructions in tests/qtest/bios-tables-test.c: both tests/data/acpi/q35/SRAT.dimmpxm and tests/qtest/bios-tables-test-allowed-diff.h found
total: 2 errors, 0 warnings, 1 lines checked
Patch 3/3 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]