From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuRiF-000251-Rn for qemu-devel@nongnu.org; Thu, 26 Jul 2012 13:19:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SuRiE-0007C5-E6 for qemu-devel@nongnu.org; Thu, 26 Jul 2012 13:18:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuRiE-0007C1-5n for qemu-devel@nongnu.org; Thu, 26 Jul 2012 13:18:58 -0400 Date: Thu, 26 Jul 2012 13:18:54 -0400 From: Eduardo Habkost Message-ID: <20120726171853.GE7834@shell.eng.rdu.redhat.com> References: <1342803890-1795-1-git-send-email-ehabkost@redhat.com> <1342803890-1795-3-git-send-email-ehabkost@redhat.com> <20120723122014.GB26120@redhat.com> <20120725184220.GI13029@otherpad.lan.raisama.net> <20120726060840.GQ26120@redhat.com> <20120726141653.GD27859@shell.eng.rdu.redhat.com> <50115A4D.2050303@redhat.com> <20120726150701.GD7834@shell.eng.rdu.redhat.com> <50116B73.2070401@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50116B73.2070401@redhat.com> Subject: Re: [Qemu-devel] [SeaBIOS PATCH 2/2] allow CPUs to have non-contiguous Local APIC IDs (v2) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Igor Mammedov , Kevin O'Connor , seabios@seabios.org, qemu-devel@nongnu.org, Gleb Natapov On Thu, Jul 26, 2012 at 07:08:19PM +0300, Avi Kivity wrote: > On 07/26/2012 06:07 PM, Eduardo Habkost wrote: > > On Thu, Jul 26, 2012 at 05:55:09PM +0300, Avi Kivity wrote: > >> On 07/26/2012 05:16 PM, Eduardo Habkost wrote: > >> >> > > >> >> > It's possible to replace the atomic read of CountCPUs with the bitmap weight > >> >> > calculation on the loop, but: is it really worth it? > >> >> > > >> >> Why not? This eliminates one more global state. > >> > > >> > Maybe we can simply make it stop being global and be used only by the > >> > smp.c initialization code? > >> > > >> > Even if the variable didn't exist yet, I think I would add it myself: > >> > it's simpler and more efficient to calculate the bitmap weight once, > >> > while filling the bitmap, than recalculating it every time on the > >> > while(cmos_smp_count) loop. > >> > >> So you're spinning more efficiently? > > > > No, coding more efficiently. I'm lazy. :-) > > > > I don't want to risk breaking that part of the code to save 2 bytes of > > memory. It's possible to impement it reliably, yes, but it's also very > > easy to introduce a subtle bug, so why touch something that works > > perfectly just to save 2 bytes? > > Like gleb, I prefer avoiding derived state which can get out-of-sync. It is calculated only once on boot, and only used inside smp_probe() and nowhere else (after applying this series, I mean). Personally I am more afraid of subtle races between the bit-setting and the (non-atomic) bitmap weight calculation + loop, than getting CountCPUs out of sync while smp_probe() runs. Note that I am all for making it not a global variable anymore, and use it only inside smp_probe() and nowhere else (this series does that, the only thing missing is to remove it from util.h). If anybody wants to eliminate it from smp_probe() too, be my guest. :) (I am hoping this is just a suggestion of an additional improvement, not an issue that would block this patch from inclusion) -- Eduardo