xref: /dragonfly/usr.bin/ktrdump/ktrdump.8 (revision d4ef6694)
1.\"-
2.\" Copyright (c) 2002 Chad David
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD: src/usr.bin/ktrdump/ktrdump.8,v 1.7 2005/03/08 06:58:56 hmp Exp $
27.\"
28.Dd November 9, 2008
29.Dt KTRDUMP 8
30.Os
31.Sh NAME
32.Nm ktrdump
33.Nd print kernel ktr trace buffer
34.Sh SYNOPSIS
35.Nm
36.Op Fl acdfilnpqrstx
37.Op Fl A Ar factor
38.Op Fl N Ar execfile
39.Op Fl M Ar corefile
40.Op Fl o Ar outfile
41.Sh DESCRIPTION
42The
43.Nm
44utility is used to dump the contents of the kernel ktr trace buffer.
45.Pp
46The following options are available:
47.Bl -tag -width ".Fl N Ar execfile"
48.It Fl a
49Print most fields.
50Implies
51.Fl c
52.Fl i
53.Fl x
54.Fl p
55.Fl r ,
56and
57.Fl s .
58Note that
59.Fl f
60is not included.
61.It Fl c
62Print the CPU number that each entry was logged from.
63.It Fl d
64Dump an event stream to the file specified with
65.Fl o .
66This stream can be examined with
67.Xr evtranalyze 1 .
68.It Fl f
69Print the file and line number that each entry was logged from.
70.It Fl i
71Print the ID string field, identifying the facility being logged.
72.It Fl l
73.Nm
74will loop waiting for new data rather than exit.
75.It Fl n
76.Nm
77normally tries to translate the caller fields and (when easily parsed)
78trace arguments into symbols.
79This option forces hex values to be displayed instead.
80This option will also cause relative timestamps to
81be displayed as TSC timestamps rather than converted to microseconds.
82.It Fl p
83Print the trace data.
84.It Fl q
85Quiet mode; do not print the column header.
86.It Fl r
87Print relative timestamps in microseconds, rather than absolute TSC
88timestamps.
89.It Fl s
90Attempt to merge the KTR logs for all cpus into a single time-sorted
91log.
92For the numbers to make any sense you probably want to turn on the
93.Va debug.ktr.resynchronize
94.Xr sysctl 3
95variable.
96This sysctl causes the kernel to periodically
97calculate the drift between each CPU's TSC and apply a correction.
98.It Fl t
99Print the timestamp for each entry.
100.It Fl x
101Print the call chain leading up to the procedure which issued
102the KTR.
103.It Fl A Ar factor
104Specify a correction factor to be applied to attempt to remove the
105overhead of the KTR logging call itself.
106.It Fl N Ar execfile
107The kernel image to resolve symbols from.
108The default is the value returned via
109.Xr getbootfile 3 .
110.It Fl M Ar corefile
111The core file or memory image to read from.
112The default is
113.Pa /dev/mem .
114.It Fl o Ar outfile
115The file to write the output to.
116The default is standard output.
117.El
118.Sh OPERATIONAL NOTES
119Users of
120.Nm
121should keep in mind that the act of trace logging will itself affect
122execution overheads.
123On a 2Ghz cpu a logging call can take anywhere from 40ns to 150ns to run.
124.Pp
125The TSC counter is used on cpus equipped with it (which is all modern cpus).
126The TSC counters may not be synchronized on SMP systems and may drift even
127between cores on multi-core cpus.
128Enabling synchronization between cpus via the
129.Va debug.ktr.resynchronize
130sysctl will impose additional system overheads and will generally only be
131accurate to within 100ns or so (and perhaps not even that good).
132Resynchronization only occurs 10 times a second and serious drift will
133cause a great deal of measurement noise when trying to compare events occurring
134on two different cpus.
135.Pp
136Users using the
137.Fl s
138option should be aware that events for each cpu are independently logged
139and one cpu might have more events logged then another, causing earlier
140events to be discarded sooner than other cpus.
141The beginning portion of
142the sorted output may thus show MP related events for one cpu with no
143corresponding events for other cpus.
144.Pp
145It is possible to somewhat characterize KTR logging overheads by setting
146the
147.Va debug.ktr.testlogcnt
148sysctl and then observing test logging events in the KTR output.
149Tests 1-3 log four dummy arguments while tests 4-6 log no arguments.
150.Pp
151It is possible to characterize IPI messaging latencies by setting the
152.Va debug.ktr.testipicnt
153sysctl.
154A small number between 1 and 1000 is recommended.
155This will
156cause the system to ping pong a single IPI message between cpu 0 and cpu 1
157asynchronously that number of times, as fast as it can.
158A
159.Nm
160should be performed almost immediately after setting the sysctl or you
161might miss the logged events.
162.Sh SEE ALSO
163.Xr ktr 4 ,
164.Xr ktr 9
165.Sh HISTORY
166The
167.Nm
168utility first appeared in
169.Fx 5.0 .
170.Sh AUTHORS
171.An -nosplit
172The
173.Nm
174utility was originally implemented by
175.An Jake Burkholder Aq Mt jake@FreeBSD.org .
176This manual page was originally written by
177.An Chad David Aq Mt davidc@FreeBSD.org .
178The program and manual page were rewritten pretty much from
179scratch by
180.An Matthew Dillon
181for
182.Dx .
183