From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLXdw-0003fO-Pv for qemu-devel@nongnu.org; Fri, 08 Jul 2016 11:24:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLXdr-0007Bm-DY for qemu-devel@nongnu.org; Fri, 08 Jul 2016 11:24:40 -0400 Received: from 10.mo69.mail-out.ovh.net ([46.105.73.241]:60501) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLXdr-0007BN-4j for qemu-devel@nongnu.org; Fri, 08 Jul 2016 11:24:35 -0400 Received: from player779.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 21F40100C4A2 for ; Fri, 8 Jul 2016 17:24:34 +0200 (CEST) Date: Fri, 8 Jul 2016 17:24:24 +0200 From: Greg Kurz Message-ID: <20160708172424.0f37f508@bahia.lan> In-Reply-To: <20160708075907.GS14675@voom.fritz.box> References: <1467903025-13383-1-git-send-email-bharata@linux.vnet.ibm.com> <1467903025-13383-4-git-send-email-bharata@linux.vnet.ibm.com> <20160707181131.3d9926fc@bahia.lan> <20160708052533.GN14675@voom.fritz.box> <20160708094647.6267415c@bahia.lan> <20160708075907.GS14675@voom.fritz.box> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/byPDQ/4rqEVhD/muO6HQDKf"; protocol="application/pgp-signature" Subject: Re: [Qemu-devel] [RFC PATCH v2 3/5] spapr: Set stable_cpu_id for threads of CPU cores List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: Bharata B Rao , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, imammedo@redhat.com, nikunj@linux.vnet.ibm.com, pbonzini@redhat.com --Sig_/byPDQ/4rqEVhD/muO6HQDKf Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 8 Jul 2016 17:59:07 +1000 David Gibson wrote: > On Fri, Jul 08, 2016 at 09:46:47AM +0200, Greg Kurz wrote: > > On Fri, 8 Jul 2016 15:25:33 +1000 > > David Gibson wrote: > > =20 > > > On Thu, Jul 07, 2016 at 06:11:31PM +0200, Greg Kurz wrote: =20 > > > > On Thu, 7 Jul 2016 20:20:23 +0530 > > > > Bharata B Rao wrote: > > > > =20 > > > > > Conditonally set stable_cpu_id for CPU threads that are created a= s part > > > > > of spapr CPU cores. The use of stable_cpu_id is enabled for pseri= es-2.7 > > > > > onwards. > > > > > =20 > > > >=20 > > > > The last sentence is a bit confusing since the enablement actually = happens > > > > in patch 5/5. > > > > =20 > > > > > Signed-off-by: Bharata B Rao > > > > > --- > > > > > hw/ppc/spapr_cpu_core.c | 7 +++++++ > > > > > 1 file changed, 7 insertions(+) > > > > >=20 > > > > > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > > > > > index b104778..0ec3513 100644 > > > > > --- a/hw/ppc/spapr_cpu_core.c > > > > > +++ b/hw/ppc/spapr_cpu_core.c > > > > > @@ -293,8 +293,15 @@ static void spapr_cpu_core_realize(DeviceSta= te *dev, Error **errp) > > > > > for (i =3D 0; i < cc->nr_threads; i++) { > > > > > char id[32]; > > > > > obj =3D sc->threads + i * size; > > > > > + CPUState *cs; > > > > > =20 > > > > > object_initialize(obj, size, typename); > > > > > + cs =3D CPU(obj); > > > > > + > > > > > + /* Use core_id (which is actually cpu_dt_id) as stable C= PU id */ =20 > > > >=20 > > > > It isn't what I had in mind. More something like below: > > > >=20 > > > > In ppc_spapr_init(): > > > >=20 > > > > for (i =3D 0; i < spapr_max_cores; i++) { > > > > spapr->cores[i]->stable_id =3D i * smp_threads; > > > > } > > > >=20 > > > >=20 > > > > In spapr_cpu_core_realize(): > > > >=20 > > > > for (j =3D 0; j < cc->nr_threads; j++) { > > > > stable_cpu_id =3D cc->stable_id + j; > > > > } > > > >=20 > > > > So we need to introduce cc->stable_id. =20 > > >=20 > > > No, we don't. Cores have had a stable ID since they were introduced. > > > =20 > >=20 > > I agree core_dt_id is stable but it is a DT concept. =20 >=20 > There is no core_dt_id. There's just core-id, which is machine > assigned (via the query hotpluggable cpus interface) and stable. >=20 > > static void ppc_spapr_init(MachineState *machine) > > { > > [...] > > for (i =3D 0; i < spapr_max_cores; i++) { > > int core_dt_id =3D i * smt; =20 >=20 > ..uh, ok, except for that poorly named variable. But that's because > this is in the machine type, and it knows it's going to use the same > ids to give to the core object and to put in the device tree. >=20 It is core_id everywhere else. $ git grep core_id hw/ppc/ hw/ppc/spapr.c: cpu_props->has_core_id =3D true; hw/ppc/spapr.c: cpu_props->core_id =3D i * smt; hw/ppc/spapr_cpu_core.c: spapr->cores[cc->core_id / smt] =3D NULL; hw/ppc/spapr_cpu_core.c: drc =3D spapr_dr_connector_by_id(SPAPR_DR_CONNE= CTOR_TYPE_CPU, cc->core_id); hw/ppc/spapr_cpu_core.c: index =3D cc->core_id / smt; hw/ppc/spapr_cpu_core.c: if (cc->core_id % smt) { hw/ppc/spapr_cpu_core.c: error_setg(&local_err, "invalid core id %d\= n", cc->core_id); hw/ppc/spapr_cpu_core.c: index =3D cc->core_id / smt; hw/ppc/spapr_cpu_core.c: error_setg(&local_err, "core id %d out of r= ange", cc->core_id); hw/ppc/spapr_cpu_core.c: error_setg(&local_err, "core %d already pop= ulated", cc->core_id); $ git grep core_dt_id hw/ppc/ hw/ppc/spapr.c: int core_dt_id =3D i * smt; hw/ppc/spapr.c: SPAPR_DR_CONNECTOR_TY= PE_CPU, core_dt_id); hw/ppc/spapr.c: object_property_set_int(core, core_dt_id, CP= U_CORE_PROP_CORE_ID, I got confused because the current code still puts cpu_dt_id of thread0 in = the device tree. And since cpu_dt_id is still being computed on cpu_index, it is a different beast (which needs to be killed since it even crashes simple hotplug/unplug scenarios). > > [...] > > object_property_set_int(core, core_dt_id, CPU_CORE_PROP= _CORE_ID, > > &error_fatal); > >=20 > > This patch produces stable_cpu_id in the [0...smt * smp_cores) range. I= find it > > awkward it depends on the host setup. =20 >=20 > True. Possibly we should set these as i * (maximum plausible number > of threads). >=20 > The gotcha is that currently we're using the same "dt_id" to control > KVM's cpu id and that in turn controls the SMT level. That's a poor > interface on the kernel side (my bad), but we have to live with it > now. However we could de-couple that KVM id from the core-id. It'd > no doubt cause some complications with kvm-xics, but we can probably > handle it. >=20 > > I'm suggesting we introduce cc->stable_id to be able to compute a simple > > stable_cpu_id in the range [0...max_cpus), like x86 and ARM. =20 >=20 > I really don't see what properties this is supposed to have that are > different from the existing core-id. >=20 Simplicity of always having CPU0, 1, 2, 3... max_cpus in QEMU, and try to hide the "poor interface on the kernel side" from the code that does not need it... but maybe that is not that important. > > =20 > > > Instead we should be setting the thread stable ids based on the core > > > stable id. > > > =20 > > > > I think stable_cpu_id is the prerequisite to compute both cpu_dt_id= and instance_id. > > > >=20 > > > > Makes sense ? > > > > =20 > > > > > + if (cs->has_stable_cpu_id) { > > > > > + cs->stable_cpu_id =3D cc->core_id + i; > > > > > + } > > > > > snprintf(id, sizeof(id), "thread[%d]", i); > > > > > object_property_add_child(OBJECT(sc), id, obj, &local_er= r); > > > > > if (local_err) { =20 > > > > =20 > > > =20 > > =20 >=20 >=20 >=20 --Sig_/byPDQ/4rqEVhD/muO6HQDKf Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAld/xagACgkQAvw66wEB28LClgCdG/7J0eoNEcXRJyxf+uvbLwF3 DiEAnRluhm6y6UxYhGJFQA1D6obGABWD =nPCk -----END PGP SIGNATURE----- --Sig_/byPDQ/4rqEVhD/muO6HQDKf--