From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLLQ0-0001jN-0q for qemu-devel@nongnu.org; Thu, 07 Jul 2016 22:21:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLLPu-0000Ca-U2 for qemu-devel@nongnu.org; Thu, 07 Jul 2016 22:21:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46649) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLLPu-0000CW-LV for qemu-devel@nongnu.org; Thu, 07 Jul 2016 22:21:22 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 433C663326 for ; Fri, 8 Jul 2016 02:21:22 +0000 (UTC) Date: Fri, 8 Jul 2016 12:23:08 +1000 From: David Gibson Message-ID: <20160708122308.1f43b56a@voom.fritz.box> In-Reply-To: <417b83d0e074e2004aa35bef337d32ac2c89f559.1467904342.git.pkrempa@redhat.com> References: <417b83d0e074e2004aa35bef337d32ac2c89f559.1467904342.git.pkrempa@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/QYU0KI2xaLBpVyZv/1H7F8U"; protocol="application/pgp-signature" Subject: Re: [Qemu-devel] [RFC PATCH 2/2] numa: Add node_id data in query-hotpluggable-cpus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Krempa Cc: qemu-devel@nongnu.org, imammedo@redhat.com --Sig_/QYU0KI2xaLBpVyZv/1H7F8U Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 7 Jul 2016 17:17:14 +0200 Peter Krempa 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. IIUC how the query thing works this means that the node id issued by query-hotpluggable-cpus will be echoed back to device add by libvirt. I'm not sure we actually process that information in the core at present, so I don't know that that's right. We need to be clear on which direction information is flowing here. Does query-hotpluggable-cpus *define* the NUMA node allocation which is then passed to the core device which implements it. Or is the NUMA allocation defined elsewhere, and query-hotpluggable-cpus just reports it. > Signed-off-by: Peter Krempa > --- > 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(-) >=20 > 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_c= pus(MachineState *machine) > HotpluggableCPUList *head =3D NULL; > PCMachineState *pcms =3D PC_MACHINE(machine); > const char *cpu_type; > + int node_id; >=20 > cpu =3D 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 =3D topo.core_id; > cpu_props->has_thread_id =3D true; > cpu_props->thread_id =3D topo.smt_id; > + > + if ((node_id =3D numa_node_get_by_cpu_index(i)) >=3D 0) { > + cpu_props->has_node_id =3D true; > + cpu_props->node_id =3D node_id; > + } > + > cpu_item->props =3D cpu_props; >=20 > cpu =3D 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_hotpluggabl= e_cpus(MachineState *machine) > sPAPRMachineState *spapr =3D SPAPR_MACHINE(machine); > int spapr_max_cores =3D max_cpus / smp_threads; > int smt =3D kvmppc_smt_threads(); > + int node_id; >=20 > for (i =3D 0; i < spapr_max_cores; i++) { > HotpluggableCPUList *list_item =3D g_new0(typeof(*list_item), 1); > @@ -2381,8 +2382,11 @@ static HotpluggableCPUList *spapr_query_hotpluggab= le_cpus(MachineState *machine) > cpu_item->vcpu_id =3D i; > cpu_props->has_core_id =3D true; > cpu_props->core_id =3D i * smt; > - /* TODO: add 'has_node/node' here to describe > - to which node core belongs */ > + > + if ((node_id =3D numa_node_get_by_cpu_index(i)) >=3D 0) { As with the previous patch this is incorrect, becauyse numa_node_get_by_cpu_index() is working from a vcpu (i.e. thread) index, but you're passing a core index. > + cpu_props->has_node_id =3D true; > + cpu_props->node_id =3D node_id; > + } >=20 > cpu_item->props =3D 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 nod= e); > uint32_t numa_get_node(ram_addr_t addr, Error **errp); > +int numa_node_get_by_cpu_index(int cpu_index); >=20 > #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[]) > } > } >=20 > +int numa_node_get_by_cpu_index(int cpu_index) > +{ > + int i; > + > + for (i =3D 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 =3D opaque; > --=20 > 2.9.0 >=20 --=20 David Gibson Senior Software Engineer, Virtualization, Red Hat --Sig_/QYU0KI2xaLBpVyZv/1H7F8U Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXfw6MAAoJEGw4ysog2bOSnIsP/0iqNAerjZeD+RLLv6ODdyoy /a6p0g74I6YoJnf4lbonYWdlOtShkHxGkUM6jkEOtBw1BkUlBmDaLTYtpVr/k65r kFQp/1nr9tytQUQTqPqTVYN+oCMVulOrM1CBO1V0gVbcph9PTl0YWj/o8jj7ampV pVK1WdszYUYuMjPAt5JDwibur5ZRCFOLiXd7lbAa/jmXNomUVggalscSvlzrJj7R d1ktyh18G+T6tzkFJEWbybBHJWAgLgx9wjigGdx2EPtxY3clfxTNz+hKhF0BMUjp /gwIbWo+iH/oRrcuO2/ZoNkIfe9JTVHK8hU3gDKV1SOkYvz0Ph9Lv40ZtNOU2D+Q Mbko28ncbADpOV5RuEqlR2a1YCnJ6EVTsIJAXASiTIvuixlRa2PZLQn7cA91/2C5 PLhK9UeXiu68FszmZ6MW1sKqf2i3mfQP0Tg+RjrtxWuJIYIiQK8fjkrwSjFt3sZg NyvWx0C0OsQ8yWxKT+IV4Imoi3WGfMXGsuMKp5edd8UVkpCdoL/7DRmMJ40lMekz koZDUbdJrH8zEX79wsez+5SS6iMsrwb3p36T+GPOdnHq7VmBJY0Spt4eqLAQSxS6 rmCZSLDk9djsOOxUwZczhBW9/UY04q89RECjuKoWlr/htm3tKTzrK9x6Imeu/lD4 jHlvDz7toXMhAH7tnmZN =9URB -----END PGP SIGNATURE----- --Sig_/QYU0KI2xaLBpVyZv/1H7F8U--