[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotplug
From: |
Igor Mammedov |
Subject: |
Re: [Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggable-cpus |
Date: |
Fri, 8 Jul 2016 13:54:58 +0200 |
On Thu, 7 Jul 2016 17:17:14 +0200
Peter Krempa <address@hidden> wrote:
> 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;
> + }
I've not included node_id for a reason,
"-numa cpus=1,2,3..." looks to me hopelessly broken now but
I've not came up with an idea how to redo it in nice and clean way yet.
Alternative could be CLI-less numa configuration, where QEMU is started
without "-numa cpus" but with "-S" then mgmt could call
query_hotpluggable_cpus() to get possible CPUs and then
map them to numa nodes with a new QMP command using attributes
it got from query_hotpluggable_cpus().
it's along the way start QEMU -smp 1,maxcpus=X and then add
remaining CPUs with device_add after getting properties from
query_hotpluggable_cpus().
then at machine_done time we can adjust DT/ACPI data to reflect
configured mapping.
> 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;
- Re: [Qemu-devel] [RFC PATCH 1/2] qapi: Add vcpu id to query-hotpluggable-cpus output, (continued)
[Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggable-cpus, Peter Krempa, 2016/07/07
Re: [Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggable-cpus,
Igor Mammedov <=
Re: [Qemu-devel] [RFC PATCH 0/2] cpu hotplug: Extend data provided by query-hotpluggable-cpus, Peter Krempa, 2016/07/07