From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsZOl-0000cA-J0 for qemu-devel@nongnu.org; Mon, 16 Dec 2013 09:44:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VsZOg-00045q-Fr for qemu-devel@nongnu.org; Mon, 16 Dec 2013 09:43:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsZOg-00045k-6J for qemu-devel@nongnu.org; Mon, 16 Dec 2013 09:43:50 -0500 Message-ID: <52AF11A3.6060402@redhat.com> Date: Mon, 16 Dec 2013 07:43:47 -0700 From: Eric Blake MIME-Version: 1.0 References: <52A9FC0C.3040509@gmail.com> <52AC939E.9060706@gmail.com> In-Reply-To: <52AC939E.9060706@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jj6Db5rCrUQ5mniaXObrrSTHnEHcICJIs" Subject: Re: [Qemu-devel] [PATCH] qemu will core dump with "-smp 254, sockets=2, cores=3, threads=2" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: lijun , qemu-devel@nongnu.org Cc: aliguori@amazon.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jj6Db5rCrUQ5mniaXObrrSTHnEHcICJIs Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12/14/2013 10:21 AM, lijun wrote: > Hi all, > As qemu core dump cause by "sockets=3D2,cores=3D3,threads=3D2", so = add > this patch to check whether cores and threads is a power of 2. > +/** > + * This function will return whether @num is power of 2. > + * > + * Returns: 1 indicate @num is power of 2, 0 indicate @num is not. > + */ > +static int is_2_power(int num) > +{ > + if (num < 0 || num > 256) > + return 1; > + > + return !(num & (num - 1)); > +} Please don't reinvent qemu-common.h's is_power_of_2. Furthermore, your function is more than just a power-of-2 check, it is also a range check. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jj6Db5rCrUQ5mniaXObrrSTHnEHcICJIs 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.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSrxGjAAoJEKeha0olJ0Nq+tIIAK41MBk5rGtd0R/0LDHCsL/U 5zmm0JriJUMn2jI67YYPWWBgyD5hA0MXdNwgcaogVYLupnIrv3bKnwUAfJdU89Ik Xwig32OvnHXrKhEOG2ZNIdyaysKnW1vLZDTHR1OBqFspvRhqmzsMWeHCHXpXzWXt d9rA8PXBTuV2FRx6zFmGrWzvHFByPi5FqGW3x3oh5KlwlF7ew0XUuVhIyFm3qCBC iZcHS4J9AbnPk0UA6rIIp/C+vHkY/QAtCczA0g2uPZG4F2hxg4JxYprcuehjRZJR YlYZskSIK/t5W4VD0VkwfOzAtZdK0iVqQSRT+tmJgrg0dhzk4VW0k+NaMKRtjIc= =Wkel -----END PGP SIGNATURE----- --jj6Db5rCrUQ5mniaXObrrSTHnEHcICJIs--