From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WL5SB-0005p3-Sm for qemu-devel@nongnu.org; Wed, 05 Mar 2014 01:37:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WL5S2-0001sR-W8 for qemu-devel@nongnu.org; Wed, 05 Mar 2014 01:37:19 -0500 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:36454) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WL5S2-0001sE-Cp for qemu-devel@nongnu.org; Wed, 05 Mar 2014 01:37:10 -0500 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Mar 2014 12:07:06 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 1805F1258048 for ; Wed, 5 Mar 2014 12:09:13 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s256awQE61931592 for ; Wed, 5 Mar 2014 12:06:58 +0530 Received: from d28av04.in.ibm.com (localhost [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s256b29x016568 for ; Wed, 5 Mar 2014 12:07:02 +0530 Date: Wed, 5 Mar 2014 12:09:19 +0530 From: Bharata B Rao Message-ID: <20140305063919.GE20295@in.ibm.com> References: <1393990609-12361-1-git-send-email-bharata@linux.vnet.ibm.com> <5316A472.6030402@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5316A472.6030402@redhat.com> Subject: Re: [Qemu-devel] [PATCH v1] ppc: Force CPU threads count to be a power of 2. Reply-To: bharata@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: aik@ozlabs.ru, stewart@linux.vnet.ibm.com, qemu-devel@nongnu.org, agraf@suse.de On Tue, Mar 04, 2014 at 09:13:38PM -0700, Eric Blake wrote: > 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 power > > of 2. Since QEMU doesn't enforce this, it leads to an early guest kernel > > crash if invalid threads count is specified. > > > > Prevent this crash and make it a graceful exit from QEMU itself by > > validating the user supplied threads count. > > > > > > > +#include > > > } > > + threads_shift = 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. Nice. Using is_power_of_2() in v2. Regards, Bharata.