From: Peter Krempa <pkrempa@redhat.com>
To: qemu-devel@nongnu.org
Cc: dgibson@redhat.com, imammedo@redhat.com,
Peter Krempa <pkrempa@redhat.com>
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 [thread overview]
Message-ID: <417b83d0e074e2004aa35bef337d32ac2c89f559.1467904342.git.pkrempa@redhat.com> (raw)
In-Reply-To: <cover.1467904342.git.pkrempa@redhat.com>
In-Reply-To: <cover.1467904342.git.pkrempa@redhat.com>
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 <pkrempa@redhat.com>
---
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
next prev parent reply other threads:[~2016-07-07 15:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-07 15:17 [Qemu-devel] [RFC PATCH 0/2] cpu hotplug: Extend data provided by query-hotpluggable-cpus Peter Krempa
2016-07-07 15:17 ` [Qemu-devel] [RFC PATCH 1/2] qapi: Add vcpu id to query-hotpluggable-cpus output Peter Krempa
2016-07-08 2:18 ` David Gibson
2016-07-08 11:40 ` Igor Mammedov
2016-07-11 3:30 ` David Gibson
2016-07-11 8:23 ` Igor Mammedov
2016-07-07 15:17 ` Peter Krempa [this message]
2016-07-07 16:10 ` [Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggable-cpus Andrew Jones
2016-07-08 2:23 ` David Gibson
2016-07-08 7:46 ` Peter Krempa
2016-07-08 12:06 ` Igor Mammedov
2016-07-08 12:26 ` Peter Krempa
2016-07-12 3:27 ` David Gibson
2016-07-08 11:54 ` Igor Mammedov
2016-07-08 12:04 ` Peter Krempa
2016-07-08 12:10 ` Igor Mammedov
2016-07-08 12:53 ` Peter Krempa
2016-07-07 15:24 ` [Qemu-devel] [RFC PATCH 0/2] cpu hotplug: Extend data provided by query-hotpluggable-cpus Peter Krempa
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=417b83d0e074e2004aa35bef337d32ac2c89f559.1467904342.git.pkrempa@redhat.com \
--to=pkrempa@redhat.com \
--cc=dgibson@redhat.com \
--cc=imammedo@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).