xref: /netbsd-src/usr.sbin/tprof/tprof.8 (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1.\"	$NetBSD: tprof.8,v 1.8 2018/07/13 12:04:50 maxv Exp $
2.\"
3.\" Copyright (c)2011 YAMAMOTO Takashi,
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.Dd July 13, 2018
28.Dt TPROF 8
29.Os
30.Sh NAME
31.Nm tprof
32.Nd record tprof profiling samples
33.Sh SYNOPSIS
34.Nm
35.Ar op
36.Op Ar arguments
37.Sh DESCRIPTION
38The
39.Nm
40tool can be used to monitor hardware events (PMCs) during the execution of
41certain commands.
42.Pp
43The
44.Nm
45utility makes the kernel driver start profiling,
46executes the specified command,
47keeps recording samples from the kernel driver until the command finishes,
48and reports statistics to the standard error.
49.Pp
50The
51.Nm tprof
52pseudo driver and a suitable backend should be loaded beforehand.
53.Pp
54The
55.Nm
56utility accepts the following options.
57The first argument,
58.Ar op ,
59specifies the action to take.
60Valid actions are:
61.Bl -tag -width offline
62.It list
63Display a list of performance counter events available on the system.
64.It monitor Xo
65.Fl e
66.Ar name:option
67.Op Fl o Ar outfile
68.Ar command
69.Xc
70Monitor the execution of command
71.Ar command .
72.Ar name
73specifies the name of the event to count; it must be taken from the list of
74available events.
75.Ar option
76specifies the source of the event; it must be a combination of
77.Ar u
78(userland) and
79.Ar k
80(kernel).
81The collected samples are written into the file
82.Ar outfile
83if specified.
84The default is
85.Dq Pa tprof.out .
86.It analyze Xo
87.Op Fl C
88.Op Fl k
89.Op Fl L
90.Op Fl P
91.Op Fl p Ar pid
92.Op Fl s
93.Ar file
94.Xc
95Analyze the samples produced by a previous run of
96.Nm tprof ,
97stored in
98.Ar file ,
99and generate a plain text representation of them.
100.It Fl C
101Don't distinguish CPUs.
102All samples are treated as its CPU number is 0.
103.It Fl k
104Kernel only.
105Ignore samples for userland code.
106.It Fl L
107Don't distinguish LWPs.
108All samples are treated as its LWP ID is 0.
109.It Fl P
110Don't distinguish processes.
111All samples are treated as its PID is 0.
112.It Fl p Ar pid
113Process only samples for the process with PID
114.Ar pid
115and ignore the rest.
116.It Fl s
117Per symbol.
118.El
119.Sh EXAMPLES
120The following command profiles the system during 20 seconds and writes the
121samples into the file myfile.out.
122.Dl # tprof monitor -e llc-misses:k -o myfile.out sleep 20
123The following command displays the results of the sampling.
124.Dl # tprof analyze myfile.out
125.Ed
126.Sh DIAGNOSTICS
127The
128.Nm
129utility reports the following statistics about the activities of the
130.Nm tprof
131pseudo driver.
132.Bl -tag -width dropbuf_samples
133.It sample
134The number of samples collected and prepared for userland consumption.
135.It overflow
136The number of samples dropped because the per-CPU buffer was full.
137.It buf
138The number of buffers successfully prepared for userland consumption.
139.It emptybuf
140The number of buffers which have been dropped because they were empty.
141.It dropbuf
142The number of buffers dropped because the number of buffers kept in the kernel
143exceeds the limit.
144.It dropbuf_samples
145The number of samples dropped because the buffers containing the samples
146were dropped.
147.El
148.Sh SEE ALSO
149.Xr tprof 4
150.Sh AUTHORS
151The
152.Nm
153utility is written by
154.An YAMAMOTO Takashi .
155It was revamped by
156.An Maxime Villard
157in 2018.
158.Sh CAVEATS
159The contents and representation of recorded samples are undocumented and
160will likely be changed for future releases of
161.Nx
162in an incompatible way.
163