From owner-svn-src-head@freebsd.org Fri Aug 10 01:49:15 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 774B91054CCF; Fri, 10 Aug 2018 01:49:15 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id C4F0D71DDA; Fri, 10 Aug 2018 01:49:13 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id A92A93CA0D1; Fri, 10 Aug 2018 11:49:04 +1000 (AEST) Date: Fri, 10 Aug 2018 11:49:03 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Kyle Evans cc: Bruce Evans , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r337518 - in head/sys: kern sys In-Reply-To: Message-ID: <20180810105239.J1482@besplex.bde.org> References: <201808090132.w791WAQm057199@repo.freebsd.org> <20180810081913.P1108@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=EseilWUA c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=x7bEGLp0ZPQA:10 a=PO7r1zJSAAAA:8 a=6I5d2MoRAAAA:8 a=QtvNg27y_NiTNPgunEoA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 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: Fri, 10 Aug 2018 01:49:15 -0000 On Thu, 9 Aug 2018, Kyle Evans wrote: > On Thu, Aug 9, 2018 at 6:22 PM, Bruce Evans wrote: >> ... >> The only obvious bug in (a later version of) the output is a missing newline >> for the tag. >> >> My dmesg output on amd64: >> X ---<>------<>---Test of early printf to msgbuf >> X GDB: debug ports: sio >> X KDB: current port: sio >> X KDB: debugger backends: ddb gdb >> X KDB: current backend: ddb >> X Copyright (c) 1992-2018 The FreeBSD Project. >> X ... >> >> In -current, all of the lines before the copyright except the tag are broken >> by printf() of them to an unmapped msgbuf. (The above output is without -v. >> Many more lines are lost with -v.) In my version, msgbufinit() is called >> earlier with a small message buffer to hold the early output. > > I've not seen a compelling reason to switch this to printf() rather > than direct addition to the msgbuf after it's initialized, but I'll > humor you on this one because I don't really care either way and > you've been at this a lot longer than I have. Thanks. > When you say you call msgbufinit() earlier-- before the static > environment is even setup, or at least after that? The above is with a simplified version that first calls msgbufinit() after the static env is set up. In other working versions, msgbufinit() is called long before the static env is set up. In a commented out version, a small MI msgbuf is statically initalized so that some msgbuf is always mapped, but msgbufmapped still starts as 0 and msgbufinit() must still be called to synchronize. Some synchronization is needed since the msgbuf uses broken mutex locking and mutexes use curthread and curthread is not initialized early. The simplified versions delay the msgbufinit() calls until mutexes are initialized enough, and this accidentally moves them after other initializations. So the tunable is unavailable in the best version :-(. The small initial msgbuf could even start with the statically initialized buffer containing the tag, and must if it is to be ready to go without a synchronization call. I haven't really noticed the need for this feature. I edit /var/log/messages a lot and need to find the start of the data for each boot, and just grep for kern.bootfile. But this depends on the message buffer being clobbered by reboot, so that syslogd always adds the kern.bootfile message before the data for the new boot. When the data spans multiple boots, the kern.bootfile message is very misplaced timestamps are wrong for the old data, and ... >> Output across reboots also works right except for the missing newline: >> >> X ---<>------<>---Test of early printf to msgbuf >> .... >> X All buffers synced. >> X ---<>------<>---Test of early printf to msgbuf ... actually, the output across reboots doesn't work write (unless you modified dmesg and syslogd to use the tag to drop duplicates). dmesg show the old boot messages by default, but syslogd shouldn't log them again by default. > Right- I tried to maintain the form of the original patch and also > overlooked this. My revised patch [1] prints the boot tag only upon > first init of the message buffer, swaps it over to printf, and adds a > newline to whatever's been chosen as the boot tag. > > [1] https://people.freebsd.org/~kevans/bde-boottag.diff I won't have much time to check it for a few weeks. Bruce