Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / usr.bin / ktrdump / ktrdump.8
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 .\" $DragonFly: src/usr.bin/ktrdump/ktrdump.8,v 1.14 2007/09/14 23:47:53 swildner Exp $
28 .\"
29 .Dd June 8, 2007
30 .Dt KTRDUMP 8
31 .Os
32 .Sh NAME
33 .Nm ktrdump
34 .Nd print kernel ktr trace buffer
35 .Sh SYNOPSIS
36 .Nm
37 .Op Fl acfilnpqrstx
38 .Op Fl N Ar execfile
39 .Op Fl M Ar corefile
40 .Op Fl o Ar outfile
41 .Sh DESCRIPTION
42 The
43 .Nm
44 utility is used to dump the contents of the kernel ktr trace buffer.
45 .Pp
46 The following options are available:
47 .Bl -tag -width ".Fl N Ar execfile"
48 .It Fl a
49 Print most fields.  Implies
50 .Fl c
51 .Fl i
52 .Fl r
53 .Fl x
54 .Fl p
55 .Fl r ,
56 and
57 .Fl s .
58 Note that
59 .Fl f
60 is not included.
61 .It Fl c
62 Print the CPU number that each entry was logged from.
63 .It Fl f
64 Print the file and line number that each entry was logged from.
65 .It Fl i
66 Print the ID string field, identifying the facility being logged.
67 .It Fl l
68 .Nm
69 will loop waiting for new data rather than exit.
70 .It Fl n
71 .Nm
72 normally tries to translate the caller fields and (when easily parsed)
73 trace arguments into symbols.  This option forces hex values to be
74 displayed instead.  This option will also cause relative timestamps to
75 be displayed as TSC timestamps rather than converted to microseconds.
76 .It Fl p
77 Print the trace data.
78 .It Fl q
79 Quiet mode; do not print the column header.
80 .It Fl r
81 Print relative timestamps in microseconds, rather than absolute TSC
82 timestamps.
83 .It Fl s
84 Attempt to merge the KTR logs for all cpus into a single time-sorted
85 log.  For the numbers to make any sense you probably want to turn
86 on the
87 .Va debug.ktr.resynchronize
88 .Xr sysctl 3
89 variable.  This sysctl causes the kernel to periodically
90 calculate the drift between each CPU's TSC and apply a correction.
91 .It Fl x
92 Print the call chain leading up to the procedure which issued
93 the KTR.
94 .It Fl t
95 Print the timestamp for each entry.
96 .It Fl N Ar execfile
97 The kernel image to resolve symbols from.
98 The default is the value returned via
99 .Xr getbootfile 3 .
100 .It Fl M Ar corefile
101 The core file or memory image to read from.
102 The default is
103 .Pa /dev/mem .
104 .It Fl o Ar outfile
105 The file to write the output to.
106 The default is standard output.
107 .El
108 .Sh OPERATIONAL NOTES
109 Users of
110 .Nm
111 should keep in mind that the act of trace logging will itself affect
112 execution overheads.  On a 2Ghz cpu a logging call can take anywhere
113 from 40ns to 150ns to run.
114 .Pp
115 The TSC counter is used on cpus equipped with it (which is all modern cpus).
116 The TSC counters may not be synchronized on SMP systems and may drift even
117 between cores on multi-core cpus.  Enabling synchronization between cpus
118 via the
119 .Va debug.ktr.resynchronize
120 sysctl will impose additional system overheads and will generally only be
121 accurate to within 100ns or so (and perhaps not even that good).
122 Resynchronization only occurs 10 times a second and serious drift will
123 cause a great deal of measurement noise when trying to compare events occurring
124 on two different cpus.
125 .Pp
126 Users using the
127 .Fl s
128 option should be aware that events for each cpu are independently logged
129 and one cpu might have more events logged then another, causing earlier
130 events to be discarded sooner then other cpus.  The beginning portion of
131 the sorted output may thus show MP related events for one cpu with no
132 corresponding events for other cpus.
133 .Pp
134 It is possible to somewhat characterize KTR logging overheads by setting
135 the
136 .Va debug.ktr.testlogcnt
137 sysctl and then observing test logging events in the KTR output.  Tests 1-3
138 log four dummy arguments while tests 4-6 log no arguments.
139 .Pp
140 It is possible to characterize IPI messaging latencies by setting the
141 .Va debug.ktr.testipicnt
142 sysctl.   A small number between 1 and 1000 is recommended.  This will
143 cause the system to ping pong a single IPI message between cpu 0 and cpu 1
144 asynchronously that number of times, as fast as it can.  A
145 .Nm
146 should be performed almost immediately after setting the sysctl or you
147 might miss the logged events.
148 .Sh SEE ALSO
149 .Xr ktr 4 ,
150 .Xr ktr 9
151 .Sh HISTORY
152 The
153 .Nm
154 utility first appeared in
155 .Fx 5.0 .
156 .Sh AUTHORS
157 .An -nosplit
158 The
159 .Nm
160 utility was originally implemented by
161 .An Jake Burkholder Aq jake@FreeBSD.org .
162 This manual page was originally written by
163 .An Chad David Aq davidc@FreeBSD.org .
164 The program and manual page were rewritten pretty much from
165 scratch by
166 .An Matthew Dillon
167 for
168 .Dx .