Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Aug 2018 09:22:11 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Kyle Evans <kevans@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r337518 - in head/sys: kern sys
Message-ID:  <20180810081913.P1108@besplex.bde.org>
In-Reply-To: <201808090132.w791WAQm057199@repo.freebsd.org>
References:  <201808090132.w791WAQm057199@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 9 Aug 2018, Kyle Evans wrote:

> Log:
>  kern: Add a BOOT_TAG marker at the beginning of boot dmesg
>
>  From the "newly licensed to drive" PR department, add a BOOT_TAG marker (by
>  default, --<<BOOT>>--, to the beginning of each boot's dmesg. This makes it
>  easier to do textproc magic to locate the start of each boot and, of
>  particular interest to some, the dmesg of the current boot.
>
>  The PR has a dmesg(8) component as well that I've opted not to include for
>  the moment- it was the more contentious part of this PR.
>
>  bde@ also made the statement that this boot tag should be written with an
>  ordinary printf, which I've- for the moment- declined to change about this
>  patch to keep it more transparent to observer of the boot process.

Yes, it should be written with an ordinary printf.

> Modified: head/sys/kern/subr_prf.c
> ==============================================================================
> --- head/sys/kern/subr_prf.c	Thu Aug  9 01:17:35 2018	(r337517)
> +++ head/sys/kern/subr_prf.c	Thu Aug  9 01:32:09 2018	(r337518)
> @@ -1027,6 +1027,7 @@ msgbufinit(void *ptr, int size)
> 	cp = (char *)ptr;
> 	msgbufp = (struct msgbuf *)(cp + size);
> 	msgbuf_reinit(msgbufp, cp, size);
> +	msgbuf_addstr(msgbufp, -1, BOOT_TAG, 0);
> 	if (msgbufmapped && oldp != msgbufp)
> 		msgbuf_copy(oldp, msgbufp);
> 	msgbufmapped = 1;

This seems to be wrong, since it writes the tag for all calls to
msgbufinit(), giving multiple tags for multiple calls, but there should be
only 1 per boot.  msgbufinit() should be called multiple times to bootstrap
it.  My version does this.

The only obvious bug in (a later version of) the output is a missing newline
for the tag.

My dmesg output on amd64:
X ---<<BOOT>>------<<BOOT>>---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.

Output across reboots also works right except for the missing newline:

X ---<<BOOT>>------<<BOOT>>---Test of early printf to msgbuf
X GDB: debug ports: sio
X GDB: current port: sio
X KDB: debugger backends: ddb gdb
X KDB: current backend: ddb
X Copyright (c) 1992-2018 The FreeBSD Project.
X ...
X Waiting (max 60 seconds) for system process `vnlru' to stop... done
X Waiting (max 60 seconds) for system process `syncer' to stop... 
X Syncing disks, vnodes remaining... 0 0 0 done
X Waiting (max 60 seconds) for system thread `bufdaemon' to stop... done
X Waiting (max 60 seconds) for system thread `bufspacedaemon-0' to stop... done
X Waiting (max 60 seconds) for system thread `bufspacedaemon-1' to stop... done
X Waiting (max 60 seconds) for system thread `bufspacedaemon-2' to stop... done
X Waiting (max 60 seconds) for system thread `bufspacedaemon-3' to stop... done
X Waiting (max 60 seconds) for system thread `bufspacedaemon-4' to stop... done
X Waiting (max 60 seconds) for system thread `bufspacedaemon-5' to stop... done
X Waiting (max 60 seconds) for system thread `bufspacedaemon-6' to stop... done
X All buffers synced.
X ---<<BOOT>>------<<BOOT>>---Test of early printf to msgbuf
X GDB: debug ports: sio
X GDB: current port: sio
X KDB: debugger backends: ddb gdb
X KDB: current backend: ddb
X Copyright (c) 1992-2018 The FreeBSD Project.
X ...

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180810081913.P1108>