From: <ankita@nvidia.com>
To: <ankita@nvidia.com>, <jgg@nvidia.com>,
<alex.williamson@redhat.com>, <clg@redhat.com>,
<shannon.zhaosl@gmail.com>, <peter.maydell@linaro.org>,
<ani@anisinha.ca>
Cc: <aniketa@nvidia.com>, <cjia@nvidia.com>, <kwankhede@nvidia.com>,
<targupta@nvidia.com>, <vsethi@nvidia.com>, <acurrid@nvidia.com>,
<qemu-arm@nongnu.org>, <qemu-devel@nongnu.org>
Subject: [PATCH v1 3/4] hw/arm/virt-acpi-build: patch guest SRAT for NUMA nodes
Date: Thu, 14 Sep 2023 19:45:58 -0700 [thread overview]
Message-ID: <20230915024559.6565-4-ankita@nvidia.com> (raw)
In-Reply-To: <20230915024559.6565-1-ankita@nvidia.com>
From: Ankit Agrawal <ankita@nvidia.com>
During bootup, Linux kernel parse the ACPI SRAT to determine the PXM ids.
This allows for the creation of NUMA nodes for each unique id.
Insert a series of the unique PXM ids in the VM SRAT ACPI table. The
range of nodes can be determined from the "dev_mem_pxm_start" and
"dev_mem_pxm_count" object properties associated with the device. These
nodes as made MEM_AFFINITY_HOTPLUGGABLE. This allows the kernel to create
memory-less NUMA nodes on bootup to which a subrange (or entire range) of
device memory can be added/removed.
Signed-off-by: Ankit Agrawal <ankita@nvidia.com>
---
hw/arm/virt-acpi-build.c | 54 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 6b674231c2..6d1e3b6b8a 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -46,6 +46,7 @@
#include "hw/acpi/hmat.h"
#include "hw/pci/pcie_host.h"
#include "hw/pci/pci.h"
+#include "hw/vfio/pci.h"
#include "hw/pci/pci_bus.h"
#include "hw/pci-host/gpex.h"
#include "hw/arm/virt.h"
@@ -515,6 +516,57 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
acpi_table_end(linker, &table);
}
+static int devmem_device_list(Object *obj, void *opaque)
+{
+ GSList **list = opaque;
+
+ if (object_dynamic_cast(obj, TYPE_VFIO_PCI)) {
+ *list = g_slist_append(*list, DEVICE(obj));
+ }
+
+ object_child_foreach(obj, devmem_device_list, opaque);
+ return 0;
+}
+
+static GSList *devmem_get_device_list(void)
+{
+ GSList *list = NULL;
+
+ object_child_foreach(qdev_get_machine(), devmem_device_list, &list);
+ return list;
+}
+
+static void build_srat_devmem(GArray *table_data)
+{
+ GSList *device_list, *list = devmem_get_device_list();
+
+ for (device_list = list; device_list; device_list = device_list->next) {
+ DeviceState *dev = device_list->data;
+ Object *obj = OBJECT(dev);
+ VFIOPCIDevice *pcidev
+ = ((VFIOPCIDevice *)object_dynamic_cast(OBJECT(obj),
+ TYPE_VFIO_PCI));
+
+ if (pcidev->pdev.has_coherent_memory) {
+ uint64_t start_node = object_property_get_uint(obj,
+ "dev_mem_pxm_start", &error_abort);
+ uint64_t node_count = object_property_get_uint(obj,
+ "dev_mem_pxm_count", &error_abort);
+ uint64_t node_index;
+
+ /*
+ * Add the node_count PXM domains starting from start_node as
+ * hot pluggable. The VM kernel parse the PXM domains and
+ * creates NUMA nodes.
+ */
+ for (node_index = 0; node_index < node_count; node_index++)
+ build_srat_memory(table_data, 0, 0, start_node + node_index,
+ MEM_AFFINITY_ENABLED | MEM_AFFINITY_HOTPLUGGABLE);
+ }
+ }
+ g_slist_free(list);
+}
+
/*
* ACPI spec, Revision 5.1
* 5.2.16 System Resource Affinity Table (SRAT)
@@ -569,6 +621,8 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
}
+ build_srat_devmem(table_data);
+
acpi_table_end(linker, &table);
}
--
2.17.1
next prev parent reply other threads:[~2023-09-15 2:46 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 2:45 [PATCH v1 0/4] vfio: report NUMA nodes for device memory ankita
2023-09-15 2:45 ` [PATCH v1 1/4] vfio: new command line params for device memory NUMA nodes ankita
2023-09-15 14:25 ` Jonathan Cameron via
2023-09-15 14:48 ` Igor Mammedov
2023-09-22 5:44 ` Ankit Agrawal
2023-09-25 14:08 ` Jonathan Cameron via
2023-09-15 2:45 ` [PATCH v1 2/4] vfio: assign default values to node params ankita
2023-09-15 2:45 ` ankita [this message]
2023-09-15 14:37 ` [PATCH v1 3/4] hw/arm/virt-acpi-build: patch guest SRAT for NUMA nodes Jonathan Cameron via
2023-09-22 5:49 ` Ankit Agrawal
2023-09-25 13:54 ` Jonathan Cameron via
2023-09-25 14:03 ` Jason Gunthorpe
2023-09-25 14:53 ` Jonathan Cameron via
2023-09-25 16:00 ` Jason Gunthorpe
2023-09-25 17:00 ` Jonathan Cameron via
2023-09-26 14:54 ` Ankit Agrawal
2023-09-27 7:06 ` Ankit Agrawal
2023-09-27 11:01 ` Jonathan Cameron via
2023-09-15 14:52 ` Igor Mammedov
2023-09-15 15:49 ` David Hildenbrand
2023-09-15 2:45 ` [PATCH v1 4/4] acpi/gpex: patch guest DSDT for dev mem information ankita
2023-09-15 15:13 ` Igor Mammedov
2023-09-27 11:42 ` Jonathan Cameron via
2023-09-15 14:19 ` [PATCH v1 0/4] vfio: report NUMA nodes for device memory Cédric Le Goater
2023-09-15 14:47 ` Alex Williamson
2023-09-15 18:34 ` David Hildenbrand
2023-09-22 8:11 ` Ankit Agrawal
2023-09-22 8:15 ` David Hildenbrand
2023-09-26 14:52 ` Ankit Agrawal
2023-09-26 16:54 ` David Hildenbrand
2023-09-26 19:14 ` Alex Williamson
2023-09-27 7:14 ` Ankit Agrawal
2023-09-27 11:33 ` Jonathan Cameron via
2023-09-27 13:53 ` Jason Gunthorpe
2023-09-27 14:24 ` Alex Williamson
2023-09-27 15:03 ` Vikram Sethi
2023-09-27 15:42 ` Jason Gunthorpe
2023-09-28 16:15 ` Jonathan Cameron via
2023-09-27 16:37 ` Alex Williamson
2023-09-28 16:29 ` Jonathan Cameron via
2023-09-28 16:04 ` Jonathan Cameron via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230915024559.6565-4-ankita@nvidia.com \
--to=ankita@nvidia.com \
--cc=acurrid@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=ani@anisinha.ca \
--cc=aniketa@nvidia.com \
--cc=cjia@nvidia.com \
--cc=clg@redhat.com \
--cc=jgg@nvidia.com \
--cc=kwankhede@nvidia.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhaosl@gmail.com \
--cc=targupta@nvidia.com \
--cc=vsethi@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).