From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCdGu-0002GN-Pc for qemu-devel@nongnu.org; Mon, 13 Jun 2016 21:36:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCdGt-0007GA-Hw for qemu-devel@nongnu.org; Mon, 13 Jun 2016 21:36:04 -0400 Date: Tue, 14 Jun 2016 11:28:52 +1000 From: David Gibson Message-ID: <20160614012852.GF4882@voom.fritz.box> References: <1465580427-13596-1-git-send-email-drjones@redhat.com> <1465580427-13596-3-git-send-email-drjones@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rWhLK7VZz0iBluhq" Content-Disposition: inline In-Reply-To: <1465580427-13596-3-git-send-email-drjones@redhat.com> Subject: Re: [Qemu-devel] [PATCH RFC 02/16] vl: smp: add checks for maxcpus based topologies List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrew Jones Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, imammedo@redhat.com, ehabkost@redhat.com, pbonzini@redhat.com, peter.maydell@linaro.org, dgibson@redhat.com, agraf@suse.de --rWhLK7VZz0iBluhq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 10, 2016 at 07:40:13PM +0200, Andrew Jones wrote: > smp_parse computes missing smp options. Unfortunately cores and > threads are computed by dividing smp_cpus, instead of max_cpus. > This is incorrect because the topology doesn't leave room for > hotplug. More unfortunately, we can't change it easily, as doing > so would impact existing command lines. This patch adds a warning > when the topology doesn't add up, and then checks that the topology > at least computes when sockets are recalculated. If not, then it > does fail. >=20 > Adding the new failure is justified by the fact that we don't > store the number of input sockets, and thus all consumers of > cpu topology information recalculate it. If they choose to > (correctly) calculate it based on maxcpus, then we need to > guard them against building topologies which provide more cpu > slots than are the maximum allowed cpus. >=20 > Signed-off-by: Andrew Jones Hmm.. this makes sense to me. Except that I've never been clear if sockets=3D was supposed to match initial cpus or maxcpus. > --- > vl.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) >=20 > diff --git a/vl.c b/vl.c > index 7b96e787922f9..8d482cb1bf020 100644 > --- a/vl.c > +++ b/vl.c > @@ -1227,6 +1227,7 @@ static void smp_parse(QemuOpts *opts) > unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); > unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); > unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); > + bool sockets_input =3D sockets > 0; > =20 > /* compute missing values, prefer sockets over cores over thread= s */ > if (cpus =3D=3D 0 || sockets =3D=3D 0) { > @@ -1269,6 +1270,24 @@ static void smp_parse(QemuOpts *opts) > exit(1); > } > =20 > + if (sockets_input && sockets * cores * threads !=3D max_cpus) { > + unsigned sockets_rounded =3D DIV_ROUND_UP(max_cpus, cores * = threads); > + > + error_report("warning: cpu topology: " > + "sockets (%u) * cores (%u) * threads (%u) !=3D " > + "maxcpus (%u). Trying sockets=3D%u.", > + sockets, cores, threads, max_cpus, sockets_roun= ded); > + sockets =3D sockets_rounded; > + > + if (sockets * cores * threads > max_cpus) { > + error_report("cpu topology: " > + "sockets (%u) * cores (%u) * threads (%u) >= " > + "maxcpus (%u)", > + sockets, cores, threads, max_cpus); > + exit(1); > + } > + } > + > smp_cpus =3D cpus; > smp_cores =3D cores; > smp_threads =3D threads; --=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 --rWhLK7VZz0iBluhq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXX13UAAoJEGw4ysog2bOSFdwQAMzJmz+pZN639n1ate/Dd7kq BVeOO5MCYUz/AHeWrwiqWyuzYB4VJRg+UdZh/hIZXpw4JDQvYzPzeWK8ZTENuKfL hhGlGQTLC9VZ+69t5FiT5awqUR7vAghsZ897RpcoC356IriLnRrOO3yQVgqrBtwm Znyyy7xBpm0BJGId/N4Fg1tkQY5EUzeBugq6PiYlbrWS27X99bK/o1UeAvQwG1MZ q26Kbz9svdvyNDq58Z/B/f7xHsxj34bGzEFcb/SFCXXhJedDz34lz0xszZLJ5jrK YxESsBMIGE90qq+A/6ROEuOcp4OgWe6uBbj5yD24ZQKCeHJzVvSK0UCPVtXwK9op GDuauiO7HsfX0WxQ8yfqERvMN1l3nofUkKZtIbyk4pomaIB6PkBYNcJcaCE3piY2 vVVtiyEaCRoSwOZ5SEUdkO97ZOmaM4p8+KR1ZwyGnILKeBmyUj7i3bhb27Cuedvr yk9eTPdZFlqWayjZERa1gcMNLjzjpT7N3p1o9CHrOmFJthG+40OZw9BP9Y4ze5BG 6H7oSvFYBHt1FRWdPHu6SZeKKVvrBW5TFxVbjy6CshsiFLNkvuijvREJUlRP8bAa G9kwgf0GWufHtxQwijLFyhDat/nU9ZawYe7Bc8ywvFJua92JOyVLtDmu9WE/WNij ehKHbvyo+4Q+9285NzCQ =5Hzb -----END PGP SIGNATURE----- --rWhLK7VZz0iBluhq--