[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 1/5] ARM: Virt: Add /distance-map node for NUMA
From: |
Shannon Zhao |
Subject: |
[Qemu-devel] [PATCH v5 1/5] ARM: Virt: Add /distance-map node for NUMA |
Date: |
Thu, 21 Apr 2016 14:23:50 +0800 |
From: Shannon Zhao <address@hidden>
This /distance-map node is used to describe the accessing distance
between NUMA nodes.
Signed-off-by: Shannon Zhao <address@hidden>
---
hw/arm/virt.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 56d35c7..814a1eb 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -40,6 +40,7 @@
#include "sysemu/device_tree.h"
#include "sysemu/sysemu.h"
#include "sysemu/kvm.h"
+#include "sysemu/numa.h"
#include "hw/boards.h"
#include "hw/loader.h"
#include "exec/address-spaces.h"
@@ -203,6 +204,9 @@ static VirtBoardInfo *find_machine_info(const char *cpu)
static void create_fdt(VirtBoardInfo *vbi)
{
+ unsigned int i, j, number, count;
+ uint64_t *matrix;
+
void *fdt = create_device_tree(&vbi->fdt_size);
if (!fdt) {
@@ -239,6 +243,32 @@ static void create_fdt(VirtBoardInfo *vbi)
"clk24mhz");
qemu_fdt_setprop_cell(fdt, "/apb-pclk", "phandle", vbi->clock_phandle);
+ if (nb_numa_nodes <= 0) {
+ return;
+ }
+
+ /* Add /distance-map node for NUMA */
+ qemu_fdt_add_subnode(fdt, "/distance-map");
+ qemu_fdt_setprop_string(fdt, "/distance-map", "compatible",
+ "numa-distance-map-v1");
+
+ number = nb_numa_nodes * nb_numa_nodes * 6;
+ matrix = g_malloc0(number * sizeof(uint64_t));
+ for (i = 0; i < nb_numa_nodes; i++) {
+ for (j = 0; j < nb_numa_nodes; j++) {
+ count = (i * nb_numa_nodes + j) * 6;
+ matrix[count++] = 1;
+ matrix[count++] = i;
+ matrix[count++] = 1;
+ matrix[count++] = j;
+ matrix[count++] = 1;
+ matrix[count++] = (i == j) ? 10 : 20;
+ }
+ }
+ qemu_fdt_setprop_sized_cells_from_array(fdt, "/distance-map",
+ "distance-matrix", number / 2,
+ matrix);
+ g_free(matrix);
}
static void fdt_add_psci_node(const VirtBoardInfo *vbi)
--
2.0.4
- [Qemu-devel] [PATCH v5 5/5] hw/arm/virt-acpi-build: Generate SRAT table, (continued)
[Qemu-devel] [PATCH v5 1/5] ARM: Virt: Add /distance-map node for NUMA,
Shannon Zhao <=