From owner-freebsd-current@FreeBSD.ORG Thu Nov 1 12:27:48 2007 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DDD6316A419 for ; Thu, 1 Nov 2007 12:27:48 +0000 (UTC) (envelope-from brucec@muon.bluestop.org) Received: from muon.bluestop.org (muon.bluestop.org [IPv6:2001:41c8:1:548a::2]) by mx1.freebsd.org (Postfix) with ESMTP id 5725713C4AC for ; Thu, 1 Nov 2007 12:27:48 +0000 (UTC) (envelope-from brucec@muon.bluestop.org) Received: by muon.bluestop.org (Postfix, from userid 1000) id 8BAC330180; Thu, 1 Nov 2007 12:27:46 +0000 (GMT) Date: Thu, 1 Nov 2007 12:27:46 +0000 From: bruce@cran.org.uk To: "Stephan F. Yaraghchi" Message-ID: <20071101122745.GA16586@muon.bluestop.org> References: <25f52a3d0710300732x425f0c45vde1a29361096c018@mail.gmail.com> <47284E4F.5030008@FreeBSD.org> <25f52a3d0710310303w7138bf5ds92698f1b6af2f655@mail.gmail.com> <4728F43A.1030500@FreeBSD.org> <25f52a3d0711010027t6b124227gfbddcada12b16e24@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25f52a3d0711010027t6b124227gfbddcada12b16e24@mail.gmail.com> User-Agent: Mutt/1.5.13 (2006-08-11) Cc: freebsd-current@freebsd.org Subject: Re: loader breaks with -O2 optimizations X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2007 12:27:49 -0000 On Thu, Nov 01, 2007 at 08:27:26AM +0100, Stephan F. Yaraghchi wrote: > On 10/31/07, Kris Kennaway wrote: > > Stephan F. Yaraghchi wrote: > > > On 10/31/07, Kris Kennaway wrote: > > >> Stephan F. Yaraghchi wrote: > > >>> After making world on a freshly installed 7.0-BETA1 > > >>> the system does not boot anymore due to a broken loader: > > >>> > > >>> > > >>> FreeBSD/i386 bootstrap loader, Revision 1.1 > > >>> (root@bigblue, Tue Oct 30 11:26:32 CET 2007) > > >>> Can't work out which disk we are booting from. > > >>> Guessed BIOS device 0xffffffff not found by probes defaulting to disk0: > > >>> > > >>> panic: free: guard1 fail@ 0x6ded4 from > > >>> /usr/src/sys/boot/i386/loader/../../common/module.c:959 > > >>> > > >>> --> Press a key on the console to reboot <-- > > >>> > > >>> > > >>> I found out that the following line in my make.conf causes > > >>> the problem: > > >>> > > >>> CFLAGS= -O2 -funroll-loops -pipe > > >>> > > >>> > > >>> After changing down to -O1 and making /usr/src/sys/boot again > > >>> the systems behaves properly at boot. > > >>> > > >>> Is this behavior intended? > > >> Maybe, what happens if you use just -O2 -pipe? -funroll-loops is not an > > >> appropriate thing to be using globally anyway, unless your intention is > > >> to randomly make some code slower. > > >> > > >> Kris > > >> > > > > > > Hi Kris, > > > > > > I tried all possible combinations of these switches -- only -O2 led to > > > the described > > > behaviour. > > > > Presumably you mean -O2 -funroll-loops, not -O2. Or are you saying the > > latter also breaks the loader? > > > > > Anyway, it's very interesting to hear that adding these optimizations > > > to make.conf > > > is not recommended, even that -funroll-loops is possibly slowing down > > > certain code. > > > > > > I'm sure many people use it since it's a common tuning tip found on the web. > > > I read about it in Dru Lavigne's "BSD Hacks" (O'Reilly)... > > > > Yes, unfortunately it's bogus advice. What does she say this option is > > good for? > > > > Kris > > > > Hi Kris, > > you are right: It's the combination of both that causes loader to break. > > Oliver suggested the defaults (-O2 -fno-strict-aliasing -pipe) and it works. > > By the way: "BSD Hacks" is a collection of hacks compiled by Dru. > Hack #69 deals with tuning and is authored by Avleen Vig. > It says: "The -funroll-loops saves one CPU register that would otherwise > be tied up in tracking the iteration of the loop, but at the expense of making > a slightly larger binary." > > -- > Stephan > There's a good thread explaining why -funroll-loops is generally bad and why it breaks the loader at http://lists.freebsd.org/pipermail/freebsd-stable/2006-September/028340.html -- Bruce