From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXj4j-0005kM-64 for qemu-devel@nongnu.org; Fri, 04 Sep 2015 00:58:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXj4h-0003VD-UZ for qemu-devel@nongnu.org; Fri, 04 Sep 2015 00:58:09 -0400 Date: Fri, 4 Sep 2015 14:56:41 +1000 From: David Gibson Message-ID: <20150904045641.GS6537@voom.redhat.com> References: <1441342300-28318-1-git-send-email-david@gibson.dropbear.id.au> <1441342300-28318-2-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BuGwuXnZwGGQ9GEc" Content-Disposition: inline In-Reply-To: <1441342300-28318-2-git-send-email-david@gibson.dropbear.id.au> Subject: Re: [Qemu-devel] [RFCv2 1/2] pseries: Fix incorrect calculation of threads per socket for chip-id List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aik@ozlabs.ru, mdroth@linux.vnet.ibm.com Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de --BuGwuXnZwGGQ9GEc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 04, 2015 at 02:51:39PM +1000, David Gibson wrote: > The device tree presented to pseries machine type guests includes an > ibm,chip-id property which gives essentially the socket number of each > vcpu core (individual vcpu threads don't get a node in the device > tree). >=20 > To calculate this, it uses a vcpus_per_socket variable computed as > (smp_cpus / #sockets). This is correct for the usual case where > smp_cpus =3D=3D smp_threads * smp_cores * #sockets. >=20 > However, you can start QEMU with the number of cores and threads > mismatching the total number of vcpus (whether that _should_ be > permitted is a topic for another day). It's a bit hard to say what > the "real" number of vcpus per socket here is, but for most purposes > (smp_threads * smp_cores) will more meaningfully match how QEMU > behaves with respect to socket boundaries. >=20 > Signed-off-by: David Gibson Gah, sorry, there's a compile error in this. I got sidetracked between writing and posting and forgot I hadn't fixed it yet. > --- > hw/ppc/spapr.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 783763f..dbc295b 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -595,8 +595,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void = *fdt, int offset, > uint32_t page_sizes_prop[64]; > size_t page_sizes_prop_size; > QemuOpts *opts =3D qemu_opts_find(qemu_find_opts("smp-opts"), NULL); > - unsigned sockets =3D opts ? qemu_opt_get_number(opts, "sockets", 0) = : 0; > - uint32_t cpus_per_socket =3D sockets ? (smp_cpus / sockets) : 1; > + uint32_t vcpus_per_socket =3D smp_threads * smp_cores; > uint32_t pft_size_prop[] =3D {0, cpu_to_be32(spapr->htab_shift)}; > =20 > _FDT((fdt_setprop_cell(fdt, offset, "reg", index))); > @@ -665,7 +664,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void = *fdt, int offset, > } > =20 > _FDT((fdt_setprop_cell(fdt, offset, "ibm,chip-id", > - cs->cpu_index / cpus_per_socket))); > + cs->cpu_index / vcpus_per_socket))); > =20 > _FDT((fdt_setprop(fdt, offset, "ibm,pft-size", > pft_size_prop, sizeof(pft_size_prop)))); --=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 --BuGwuXnZwGGQ9GEc Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV6SSIAAoJEGw4ysog2bOSQKYQAJLHkI7zS0hXoPG5IiBbN6r7 jUxan2Y89jm+BtN0zq6k6qEyirmCmRkTG0V1/V3Y9qMFKuOJwGESsOV9rfUthWbM cNw0kCEjtGlcXJFVYq0fl/cU1rYHZg7nMsZZL9TwbC7ud2N7EIEpSjiTiTGvWnBn vzuQbeCr7pb1ccR7zjKgL6+aRRk2lybQ3eNBDVHe+ogzzbl57Gb4Hj6vUjPcWAPL 0oz9oH+NnKUulnbL0C1WTShbxGMnkbuybZqMTWtqHc9uMkIpSDQywg83bfBgWFq3 vHDtzDQPkrT/Pme82wD+djSSKFuE6t2PHoxTpdUPQV2+Yp4PoFn1Q77e5SoqQypE exwCQV36ZkLpKYC6G5qYLz1oa+GfexxglbdNJUdz7g8uEQUcQg/69t8HyD1VVLZz KTVXY1I7nLT5flztoLj3Qe5nRmN4W01lPAFghIXqWRH8JgmvaHVfpVcwtDyEOBx9 F+k7loknZGVvcHY9+5vTYIN/FXlqJeo8p+8uqWyWp/xBbToavELZKM231/EoGDm0 B83olYoIeN9jtQ4570oN/ELyNkxXTfQKgh1hM2X4dgkRKkdviS+WVjuaJcgqWhdo rrE4laoz8vgpMMk5PbaiwClglNt9MowgOtuekWG5Zi1oWW/B8/5w6qkxNGxIjF2U mNGiejHC9IbJy3my4oDx =pKSF -----END PGP SIGNATURE----- --BuGwuXnZwGGQ9GEc--