From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQR3P-0006sV-VI for qemu-devel@nongnu.org; Thu, 21 Jul 2016 23:23:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQR3L-0003t0-0E for qemu-devel@nongnu.org; Thu, 21 Jul 2016 23:23:10 -0400 Date: Fri, 22 Jul 2016 13:23:01 +1000 From: David Gibson Message-ID: <20160722032301.GG15941@voom.fritz.box> References: <1469116479-233280-1-git-send-email-imammedo@redhat.com> <1469116479-233280-7-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yQbNiKLmgenwUfTN" Content-Disposition: inline In-Reply-To: <1469116479-233280-7-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH 6/8] spapr: init CPUState->cpu_index with index relative to core-id List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Alexander Graf , Riku Voipio , Bharata B Rao , qemu-ppc@nongnu.org --yQbNiKLmgenwUfTN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 21, 2016 at 05:54:37PM +0200, Igor Mammedov wrote: > It will enshure that cpu_index for a given cpu stays the same > regardless of the order cpus has been created/deleted and so > it would be possible to migrate QEMU instance with out of order > created CPU. >=20 > Signed-off-by: Igor Mammedov So, this isn't quite right (it wasn't right in my version either). The problem occurs when smp_threads < kvmppc_smt_threads(). That is, when the requested threads-per-core is less than the hardware's maximum number of threads-per-core. The core-id values are assigned essentially as i * kvmppc_smt_threads(), meaning the patch below will leave gaps in the cpu_index values and the last ones will exceed max_cpus, causing other problems. What I'm not sure about is whether the right way to fix this is to change the core-id values, or to calculate the cpu_index from the existing core-id values. > --- > hw/ppc/spapr_cpu_core.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > index 4bfc96b..f68e88d 100644 > --- a/hw/ppc/spapr_cpu_core.c > +++ b/hw/ppc/spapr_cpu_core.c > @@ -309,9 +309,13 @@ static void spapr_cpu_core_realize(DeviceState *dev,= Error **errp) > sc->threads =3D g_malloc0(size * cc->nr_threads); > for (i =3D 0; i < cc->nr_threads; i++) { > char id[32]; > + CPUState *cs; > + > obj =3D sc->threads + i * size; > =20 > object_initialize(obj, size, typename); > + cs =3D CPU(obj); > + cs->cpu_index =3D cc->core_id + i; > snprintf(id, sizeof(id), "thread[%d]", i); > object_property_add_child(OBJECT(sc), id, obj, &local_err); > if (local_err) { --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --yQbNiKLmgenwUfTN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXkZGVAAoJEGw4ysog2bOSpCkP/iopx04aQhP0/Z9i6CD/Xdlp bT8s2v7zZnJSkcyqcqxKiiW0bYMtTQSNYZr11Tk8UDEhBmBnwu2Wg3olQY4sYSIF wU3MO4fzTJ4+IIFUD4bbR8r4ypDEH/9/rW1/r8UV+zjELFJqhXOjoP0MXYIRNMM1 OfB5pNx3n6gm9VTYPgnef4Xpp+qfQvynuBbZFNe4JFqEFMm8p5vOfOjEgj1VxKgp 6dvfkRg7Ff55USHu2Cdgrwl/3xDvIf/Q+COp4O1NkBo6cp7giQ1t06C+MnhL4teL H4IVyOFipxYYby0cWGETS6RiqNOwLQWFJlEBblyD+c7NWjYWRu/7fJJejWRk6Vrf p/FLghP6TnXB4jC6pYrw6z0vn/9EpQhVuM2JnCT5YssbHUV1UxhQnYb5sg2QOf5X bhPXyGyQ3o6C/Yo0x2ki923ADX3JadigoOCTnG3N1Tdx15Sg/AmDaeUTnK1wrlji oTVFXJK7tP2yJTHqKmMJtebXD3ff+0L9jFfVBGkW2EWTtM0hpaus92qzRSmrRLeR B0DmvvYS+Bs/+ou5U91eu2jI2osdBcpY22eu3eYRE8DHJ0cPjAMi8fQ4XdOwClvn euQj7roKYWk/rNOPkLLcBUGL9lRqHt+1omgKVONKoXWoN1U/YeNMJQMe/kVs0P1O 60Q4WN18hTx3nKniX3O1 =3o2e -----END PGP SIGNATURE----- --yQbNiKLmgenwUfTN--