NetBSD/sbin/dmesg/dmesg.8
kre 7008793d77 Correct the 6 second offset issue between the time reported by
dmesg -T and the actual time a message was produced, noted on
current-users by Geoff Wing (Oct 27, 2018).

The size of the offset would depend upon architecture, and processor,
but was the delay from starting the clocks to initialising the time
of day (after mounting root, in case that is needed).

Change the kernel to set boottime to be the time at which the
clocks were started, rather than the time at which it is init'd
(by subtracting the interval between).

Correct dmesg to properly compute the ToD based upon the
boottime (which is a timespec, not a timeval, and has been
since Jan 2009) and the time logged in the message.

Note that this can (rarely) be 1 second earlier than date reports.
This occurs  when the time when the message was logged was actually
in the next second, but the timecounters have not yet processed
the tick, and so the time of the last tick, near the end of the
previous second, is reported instead.   Since times are always
truncated, rather than rounded, it is occasionally possible to
observe that disparity (if you try hard enough).

IOW: sys/kern/subr_prf.c:addtstamp() uses getnanouptime() rather
than nanouptime().

Note in dmesg(8) that -T conversions are gibberish other than
when the message comes from current the running kernel.  (It
could be fixed when -M is used, for messages generated by the
kernel whose corpse is being observed.   But hasn't been...)
2018-10-30 19:40:35 +00:00

123 lines
4.1 KiB
Groff

.\" $NetBSD: dmesg.8,v 1.26 2018/10/30 19:40:36 kre Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)dmesg.8 8.1 (Berkeley) 6/5/93
.\"
.Dd October 30, 2018
.Dt DMESG 8
.Os
.Sh NAME
.Nm dmesg
.Nd display the system message buffer
.Sh SYNOPSIS
.Nm
.Op Fl dTt
.Op Fl M Ar core
.Op Fl N Ar system
.Sh DESCRIPTION
.Nm
displays the contents of the system message buffer.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl d
Show the timestamp deltas.
Used together with
.Fl t
only the deltas are shown.
.It Fl M
Extract values associated with the name list from the specified core
instead of the default ``/dev/mem''.
.It Fl N
Extract the name list from the specified system instead of the default
``/netbsd''.
.It Fl T
Format uptime timestamps in a human readable form (using
.Xr ctime 3 )
using output suitable for the local locale as set in the environment.
Repeating this option prints the uptime in ISO 8601 duration form,
giving the duration since boot, in hours, minutes, and seconds (to
millisecond resolution).
A third occurrence causes the duration to always be represented
to millisecond precision, even where that means trailing zeroes
appear.
.It Fl t
Quiet printing, don't print timestamps.
.El
.Pp
The system message buffer is a circular buffer of a fixed size.
If the buffer has been filled, the first line of the
.Nm
output may not be complete.
The size of the message buffer is configurable at compile-time on
most systems with the
.Dv MSGBUFSIZE
kernel option.
Look for
.Dv MSGBUFSIZE
in
.Xr options 4
for details.
.Sh FILES
.Bl -tag -width /var/run/dmesg.boot -compact
.It Pa /var/run/dmesg.boot
copy of dmesg at the time of last boot.
.El
.Sh SEE ALSO
.Xr options 4 ,
.Xr syslogd 8
.Sh HISTORY
The
.Nm
command appeared in
.Bx 3.0 .
.Sh BUGS
The
.Fl T
option will report nonsense when displaying lines from
the message buffer that were not added by the current
running kernel.
.Pp
When
.Fl TT
is used, the duration is always given with maximum units of hours,
even when the number of hours is in the hundreds, thousands, or more.
This is because converting hours to days, over periods when
.Dq time skips
occur, such as summer time beginning or ending, is not trivial.
A duration of 26 hours might be 1D3H or 1D1H at such events,
rather than the usual 1D2H,
and when a time zone alters its offset,
even more complex calculations are needed.
None of those calculations are done
.Pq even to account for sub-hour time zone shifts ,
the duration indicated is always calculated by simple division of
seconds by 60 to produce minutes, and again to produce hours.
Most of the time\ [!] this is correct.