[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 18/50] hw/acpi-build: build SRAT memory affinity s
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 18/50] hw/acpi-build: build SRAT memory affinity structures for DIMM devices |
Date: |
Tue, 20 Mar 2018 05:17:23 +0200 |
From: Haozhong Zhang <address@hidden>
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 DIMM device present at
boot time, 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 <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/i386/acpi-build.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 52 insertions(+), 4 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index ebde2cd..1df9ed2 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2250,6 +2250,55 @@ 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)
+{
+ MemoryDeviceInfoList *info_list = qmp_pc_dimm_device_list();
+ MemoryDeviceInfoList *info;
+ MemoryDeviceInfo *mi;
+ PCDIMMDeviceInfo *di;
+ uint64_t end = base + len, cur, size;
+ bool is_nvdimm;
+ AcpiSratMemoryAffinity *numamem;
+ MemoryAffinityFlags flags;
+
+ for (cur = base, info = info_list;
+ cur < end;
+ cur += size, info = info->next) {
+ numamem = acpi_data_push(table_data, sizeof *numamem);
+
+ if (!info) {
+ build_srat_memory(numamem, cur, end - cur, default_node,
+ MEM_AFFINITY_HOTPLUGGABLE |
MEM_AFFINITY_ENABLED);
+ break;
+ }
+
+ mi = info->value;
+ is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM);
+ di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data;
+
+ if (cur < di->addr) {
+ build_srat_memory(numamem, cur, di->addr - cur, default_node,
+ MEM_AFFINITY_HOTPLUGGABLE |
MEM_AFFINITY_ENABLED);
+ numamem = acpi_data_push(table_data, sizeof *numamem);
+ }
+
+ size = di->size;
+
+ flags = MEM_AFFINITY_ENABLED;
+ if (di->hotpluggable) {
+ flags |= MEM_AFFINITY_HOTPLUGGABLE;
+ }
+ if (is_nvdimm) {
+ flags |= MEM_AFFINITY_NON_VOLATILE;
+ }
+
+ build_srat_memory(numamem, di->addr, size, di->node, flags);
+ }
+
+ qapi_free_MemoryDeviceInfoList(info_list);
+}
+
static void
build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
{
@@ -2361,10 +2410,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,
--
MST
- [Qemu-devel] [PULL v2 05/50] pc: replace pm object initialization with one-liner in acpi_get_pm_info(), (continued)
- [Qemu-devel] [PULL v2 05/50] pc: replace pm object initialization with one-liner in acpi_get_pm_info(), Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 08/50] acpi: move ACPI_PORT_SMI_CMD define to header it belongs to, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 01/50] scripts/update-linux-headers: add ethtool.h and update to 4.16.0-rc4, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 09/50] pc: acpi: isolate FADT specific data into AcpiFadtData structure, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 10/50] pc: acpi: use build_append_foo() API to construct FADT, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 15/50] hw/pci: remove obsolete PCIDevice->init(), Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 13/50] tests: acpi: don't read all fields in test_acpi_fadt_table(), Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 14/50] standard-headers: update virtio_net.h, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 16/50] pc-dimm: make qmp_pc_dimm_device_list() sort devices by address, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 19/50] tests/bios-tables-test: add test cases for DIMM proximity, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 18/50] hw/acpi-build: build SRAT memory affinity structures for DIMM devices,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 17/50] qmp: distinguish PC-DIMM and NVDIMM in MemoryDeviceInfoList, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 12/50] virt_arm: acpi: reuse common build_fadt(), Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 11/50] acpi: move build_fadt() from i386 specific to generic ACPI source, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 20/50] test/acpi-test-data: add ACPI tables for dimmpxm test, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 21/50] Makefile: add target to print generated files, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 22/50] migrate: Update ram_block_discard_range for shared, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 23/50] qemu_ram_block_host_offset, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 26/50] postcopy: Add vhost-user flag for postcopy and check it, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 24/50] postcopy: use UFFDIO_ZEROPAGE only when available, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 25/50] postcopy: Add notifier chain, Michael S. Tsirkin, 2018/03/19