From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WL3FF-00059R-8o for qemu-devel@nongnu.org; Tue, 04 Mar 2014 23:15:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WL3F9-0002j4-P5 for qemu-devel@nongnu.org; Tue, 04 Mar 2014 23:15:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WL3F9-0002im-7n for qemu-devel@nongnu.org; Tue, 04 Mar 2014 23:15:43 -0500 Message-ID: <5316A472.6030402@redhat.com> Date: Tue, 04 Mar 2014 21:13:38 -0700 From: Eric Blake MIME-Version: 1.0 References: <1393990609-12361-1-git-send-email-bharata@linux.vnet.ibm.com> In-Reply-To: <1393990609-12361-1-git-send-email-bharata@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ib0XAkEeCMMUXxtn7aFTsfaIqvmeKUPNM" Subject: Re: [Qemu-devel] [PATCH v1] ppc: Force CPU threads count to be a power of 2. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao , qemu-devel@nongnu.org Cc: aik@ozlabs.ru, stewart@linux.vnet.ibm.com, agraf@suse.de This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ib0XAkEeCMMUXxtn7aFTsfaIqvmeKUPNM Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/04/2014 08:36 PM, Bharata B Rao wrote: > PowerPC kernel expects the number of SMT threads in a core to be a powe= r > of 2. Since QEMU doesn't enforce this, it leads to an early guest kerne= l > crash if invalid threads count is specified. >=20 > Prevent this crash and make it a graceful exit from QEMU itself by > validating the user supplied threads count. >=20 > =20 > +#include > } > + threads_shift =3D log2(smp_threads); Overkill. qemu-common.h gives you is_power_of_2() that uses just integer math rather than dragging in floating-point overhead of libm. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ib0XAkEeCMMUXxtn7aFTsfaIqvmeKUPNM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTFqRyAAoJEKeha0olJ0NqEacH/in0IfLejTujhNylVE+U+7vo fAVhR72SO5skal9BbdSDe89rf/sI9cRqxmfjokw9JPBy+7daH9gu1HaB/REi4A9g phQKObtMcja7aCiGxwp/mjwAZFil2DCeYB7SXpu4HqsYUSf11fZ9ZjWo2PoQPsl+ ZXUISCD3mZfVt0kx1LQ7cnqwY4MyeBrZKBVdeMS73XmDaoN5m+B03FZ5/pscUzTK x+Ub1eh0K0P6ZGSewaibSs2YAZ2+3AQtyopt4LzNknjKv9+v20x8lys3oW32BKbS EKNULMCyisDRO4vCdA0iWwaMrRM27v8eXC+KfpOWtmT689MdQ2LaY4S24ASllWI= =Dnm7 -----END PGP SIGNATURE----- --ib0XAkEeCMMUXxtn7aFTsfaIqvmeKUPNM--