[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggabl
From: |
Peter Krempa |
Subject: |
[Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggable-cpus |
Date: |
Thu, 7 Jul 2016 17:17:14 +0200 |
Add a helper that looks up the NUMA node for a given CPU and use it to
fill the node_id in the PPC and X86 impls of query-hotpluggable-cpus.
Signed-off-by: Peter Krempa <address@hidden>
---
hw/i386/pc.c | 7 +++++++
hw/ppc/spapr.c | 8 ++++++--
include/sysemu/numa.h | 1 +
numa.c | 13 +++++++++++++
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4ba02c4..a0b9507 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -2115,6 +2115,7 @@ static HotpluggableCPUList
*pc_query_hotpluggable_cpus(MachineState *machine)
HotpluggableCPUList *head = NULL;
PCMachineState *pcms = PC_MACHINE(machine);
const char *cpu_type;
+ int node_id;
cpu = pcms->possible_cpus->cpus[0].cpu;
assert(cpu); /* BSP is always present */
@@ -2138,6 +2139,12 @@ static HotpluggableCPUList
*pc_query_hotpluggable_cpus(MachineState *machine)
cpu_props->core_id = topo.core_id;
cpu_props->has_thread_id = true;
cpu_props->thread_id = topo.smt_id;
+
+ if ((node_id = numa_node_get_by_cpu_index(i)) >= 0) {
+ cpu_props->has_node_id = true;
+ cpu_props->node_id = node_id;
+ }
+
cpu_item->props = cpu_props;
cpu = pcms->possible_cpus->cpus[i].cpu;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index d1f5195..06ba7fc 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2370,6 +2370,7 @@ static HotpluggableCPUList
*spapr_query_hotpluggable_cpus(MachineState *machine)
sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
int spapr_max_cores = max_cpus / smp_threads;
int smt = kvmppc_smt_threads();
+ int node_id;
for (i = 0; i < spapr_max_cores; i++) {
HotpluggableCPUList *list_item = g_new0(typeof(*list_item), 1);
@@ -2381,8 +2382,11 @@ static HotpluggableCPUList
*spapr_query_hotpluggable_cpus(MachineState *machine)
cpu_item->vcpu_id = i;
cpu_props->has_core_id = true;
cpu_props->core_id = i * smt;
- /* TODO: add 'has_node/node' here to describe
- to which node core belongs */
+
+ if ((node_id = numa_node_get_by_cpu_index(i)) >= 0) {
+ cpu_props->has_node_id = true;
+ cpu_props->node_id = node_id;
+ }
cpu_item->props = cpu_props;
if (spapr->cores[i]) {
diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index bb184c9..04d7097 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -31,5 +31,6 @@ extern QemuOptsList qemu_numa_opts;
void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
void numa_unset_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
uint32_t numa_get_node(ram_addr_t addr, Error **errp);
+int numa_node_get_by_cpu_index(int cpu_index);
#endif
diff --git a/numa.c b/numa.c
index cbae430..365738a 100644
--- a/numa.c
+++ b/numa.c
@@ -506,6 +506,19 @@ void query_numa_node_mem(uint64_t node_mem[])
}
}
+int numa_node_get_by_cpu_index(int cpu_index)
+{
+ int i;
+
+ for (i = 0; i < nb_numa_nodes; i++) {
+ if (test_bit(cpu_index, numa_info[i].node_cpu)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
static int query_memdev(Object *obj, void *opaque)
{
MemdevList **list = opaque;
--
2.9.0
[Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggable-cpus,
Peter Krempa <=
Re: [Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggable-cpus, Igor Mammedov, 2016/07/08