From owner-svn-src-head@FreeBSD.ORG Sun Apr 15 13:01:17 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F20BA1065676; Sun, 15 Apr 2012 13:01:16 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 547778FC25; Sun, 15 Apr 2012 13:01:16 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q3FD1F3R071247; Sun, 15 Apr 2012 15:01:15 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q3FD1E8i071246; Sun, 15 Apr 2012 15:01:14 +0200 (CEST) (envelope-from marius) Date: Sun, 15 Apr 2012 15:01:14 +0200 From: Marius Strobl To: "Justin T. Gibbs" Message-ID: <20120415130114.GB68446@alchemy.franken.de> References: <201204092241.q39MfJZn081610@svn.freebsd.org> <20120409230949.GB68111@alchemy.franken.de> <20120410114118.GB93449@alchemy.franken.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: Attilio Rao , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, John Baldwin Subject: Re: svn commit: r234074 - in head/sys: amd64/amd64 i386/i386 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Apr 2012 13:01:17 -0000 On Sat, Apr 14, 2012 at 05:05:35PM -0600, Justin T. Gibbs wrote: > > On Apr 10, 2012, at 5:41 AM, Marius Strobl wrote: > > > On Tue, Apr 10, 2012 at 01:03:56AM +0100, Attilio Rao wrote: > >> Il 10 aprile 2012 00:09, Marius Strobl ha scritto: > >>> On Mon, Apr 09, 2012 at 10:41:19PM +0000, Attilio Rao wrote: > >>>> Author: attilio > >>>> Date: Mon Apr ??9 22:41:19 2012 > >>>> New Revision: 234074 > >>>> URL: http://svn.freebsd.org/changeset/base/234074 > >>>> > >>>> Log: > >>>> ?? BSP is not added to the mask of valid target CPUs for interrupts > >>>> ?? in set_apic_interrupt_ids(). Besides, set_apic_interrupts_ids() is not > >>>> ?? called in the !SMP case too. > >>>> ?? Fix this by: > >>>> ?? - Adding the BSP as an interrupt target directly in cpu_startup(). > >>>> ?? - Remove an obsolete optimization where the BSP are skipped in > >>>> ?? ?? set_apic_interrupt_ids(). > >>>> > >>>> ?? Reported by: ?? ?? ?? ??jh > >>>> ?? Reviewed by: ?? ?? ?? ??jhb > >>>> ?? MFC after: ??3 days > >>>> ?? X-MFC: ?? ?? ?? ?? ?? ?? ??r233961 > >>>> ?? Pointy hat to: ?? ?? ??me > >>>> > >>>> Modified: > >>>> ?? head/sys/amd64/amd64/machdep.c > >>>> ?? head/sys/amd64/amd64/mp_machdep.c > >>>> ?? head/sys/i386/i386/machdep.c > >>>> ?? head/sys/i386/i386/mp_machdep.c > >>>> > >>>> Modified: head/sys/amd64/amd64/machdep.c > >>>> ============================================================================== > >>>> --- head/sys/amd64/amd64/machdep.c ?? ??Mon Apr ??9 22:01:43 2012 ?? ?? ?? ??(r234073) > >>>> +++ head/sys/amd64/amd64/machdep.c ?? ??Mon Apr ??9 22:41:19 2012 ?? ?? ?? ??(r234074) > >>>> @@ -295,6 +295,11 @@ cpu_startup(dummy) > >>>> ?? ?? ?? vm_pager_bufferinit(); > >>>> > >>>> ?? ?? ?? cpu_setregs(); > >>>> + > >>>> + ?? ?? /* > >>>> + ?? ?? ??* Add BSP as an interrupt target. > >>>> + ?? ?? ??*/ > >>>> + ?? ?? intr_add_cpu(0); > >>>> ??} > >>> > >>> If I'm not mistaken, intr_add_cpu() is under #ifdef SMP, so it should be > >>> here as well. > >> > >> You are right, sorry, I did forgot to test without SMP. > >> I think we still need intr_add_cpu() on cpu_startup() because of the > >> case smp_disabled = 1. > >> I think the attached patch should make its dirty job, opinion? > > > > I currently fail to see why the latter approach would be necessary, > > i.e. IMO wrapping the intr_add_cpu() calls in cpu_startup() should > > be sufficient. In case the kernel is compiled without SMP support, > > interrupt balancing support isn't available in the first place and > > the BSP is always the only available target (see the UP version of > > intr_next_cpu() at the end of x86/x86/intr_machdep.c), so there's > > no need to add the BSP as a valid target. If an SMP kernel is run > > on a UP machine or with SMP disabled, interrupt balancing support > > is available but the intr_add_cpu() calls in cpu_startup() will add > > the BSP as (the only) target, so everything should be fine. Maybe > > you can elaborate on why you think an SMP kernel with SMP disabled > > needs special handling. > > > > Marius > > While functionally correct, I believe that wrapping intr_add_cpu() > in machdep.c in "SMP ifdefs" is inferior to calling it in all cases. > It invites questions like, "In the UP case, don't we have to ensure > that CPU0 is a valid interrupt target?" This is because casual > visitors to this file don't know that intr_add_cpu() only impacts > interrupt distribution. Of course, this is just an artifact of the > current implementation. #ifdefs should be as close to the implemenation > as possible. This simplifies the task of making future enhancments. > This is why I'd prefer to see these within the body of intr_add_cpu() > than where they are now. > Well, feel free to change the code like that. However, my perspective is that if these #ifdef SMP (which also are just one amongst several in these machdep.c) cause the casual visitors to actually look at the bigger picture than this is a good thing. Doing so probably would have avoided the bugs in r222813 and r233961. Marius