xref: /freebsd/usr.sbin/pmcstat/pmcstat.8 (revision 047ce3db97769968f6777be456cbf196c65eb455)
1e572c7a7SJoseph Koshy.\" Copyright (c) 2003-2008 Joseph Koshy
2b6010f9eSJoseph Koshy.\" Copyright (c) 2007 The FreeBSD Foundation
3b6010f9eSJoseph Koshy.\" All rights reserved.
4ebccf1e3SJoseph Koshy.\"
5ebccf1e3SJoseph Koshy.\" Redistribution and use in source and binary forms, with or without
6ebccf1e3SJoseph Koshy.\" modification, are permitted provided that the following conditions
7ebccf1e3SJoseph Koshy.\" are met:
8ebccf1e3SJoseph Koshy.\" 1. Redistributions of source code must retain the above copyright
9ebccf1e3SJoseph Koshy.\"    notice, this list of conditions and the following disclaimer.
10ebccf1e3SJoseph Koshy.\" 2. Redistributions in binary form must reproduce the above copyright
11ebccf1e3SJoseph Koshy.\"    notice, this list of conditions and the following disclaimer in the
12ebccf1e3SJoseph Koshy.\"    documentation and/or other materials provided with the distribution.
13ebccf1e3SJoseph Koshy.\"
14ebccf1e3SJoseph Koshy.\" This software is provided by Joseph Koshy ``as is'' and
15ebccf1e3SJoseph Koshy.\" any express or implied warranties, including, but not limited to, the
16ebccf1e3SJoseph Koshy.\" implied warranties of merchantability and fitness for a particular purpose
17ebccf1e3SJoseph Koshy.\" are disclaimed.  in no event shall Joseph Koshy be liable
18ebccf1e3SJoseph Koshy.\" for any direct, indirect, incidental, special, exemplary, or consequential
19ebccf1e3SJoseph Koshy.\" damages (including, but not limited to, procurement of substitute goods
20ebccf1e3SJoseph Koshy.\" or services; loss of use, data, or profits; or business interruption)
21ebccf1e3SJoseph Koshy.\" however caused and on any theory of liability, whether in contract, strict
22ebccf1e3SJoseph Koshy.\" liability, or tort (including negligence or otherwise) arising in any way
23ebccf1e3SJoseph Koshy.\" out of the use of this software, even if advised of the possibility of
24ebccf1e3SJoseph Koshy.\" such damage.
25ebccf1e3SJoseph Koshy.\"
26ebccf1e3SJoseph Koshy.\" $FreeBSD$
27ebccf1e3SJoseph Koshy.\"
28*047ce3dbSJoseph Koshy.Dd March 24, 2023
29ebccf1e3SJoseph Koshy.Dt PMCSTAT 8
30aa12cea2SUlrich Spörlein.Os
31ebccf1e3SJoseph Koshy.Sh NAME
32ebccf1e3SJoseph Koshy.Nm pmcstat
3321ce09caSJoseph Koshy.Nd "performance measurement with performance monitoring hardware"
34ebccf1e3SJoseph Koshy.Sh SYNOPSIS
35ebccf1e3SJoseph Koshy.Nm
3694e9ef85SMateusz Guzik.Op Fl A
37ebccf1e3SJoseph Koshy.Op Fl C
3815139246SJoseph Koshy.Op Fl D Ar pathname
39f263522aSJoseph Koshy.Op Fl E
400b86b1bbSFabien Thomas.Op Fl F Ar pathname
41b6010f9eSJoseph Koshy.Op Fl G Ar pathname
42e22ee9b2SSean Bruno.Op Fl I
43959826caSMatt Macy.Op Fl L
4449874f6eSJoseph Koshy.Op Fl M Ar mapfilename
45b6010f9eSJoseph Koshy.Op Fl N
46ebccf1e3SJoseph Koshy.Op Fl O Ar logfilename
47ebccf1e3SJoseph Koshy.Op Fl P Ar event-spec
48f263522aSJoseph Koshy.Op Fl R Ar logfilename
49ebccf1e3SJoseph Koshy.Op Fl S Ar event-spec
500b86b1bbSFabien Thomas.Op Fl T
515de96e33SMatt Macy.Op Fl U
52f263522aSJoseph Koshy.Op Fl W
53f6f851a3SScott Long.Op Fl a Ar pathname
54ee4910b1SJoseph Koshy.Op Fl c Ar cpu-spec
55ebccf1e3SJoseph Koshy.Op Fl d
56465dadb5SJonathan T. Looney.Op Fl e
570b86b1bbSFabien Thomas.Op Fl f Ar pluginopt
58f263522aSJoseph Koshy.Op Fl g
59959826caSMatt Macy.Op Fl i Ar lwp
6049874f6eSJoseph Koshy.Op Fl k Ar kerneldir
6172fe532cSGeorge V. Neville-Neil.Op Fl l Ar secs
62c0252222SAttilio Rao.Op Fl m Ar pathname
6321ce09caSJoseph Koshy.Op Fl n Ar rate
64ebccf1e3SJoseph Koshy.Op Fl o Ar outputfile
65ebccf1e3SJoseph Koshy.Op Fl p Ar event-spec
6649874f6eSJoseph Koshy.Op Fl q
6749874f6eSJoseph Koshy.Op Fl r Ar fsroot
68ebccf1e3SJoseph Koshy.Op Fl s Ar event-spec
69fbd8b34aSJoseph Koshy.Op Fl t Ar process-spec
70959826caSMatt Macy.Op Fl u Ar event-spec
7149874f6eSJoseph Koshy.Op Fl v
7221ce09caSJoseph Koshy.Op Fl w Ar secs
73b6010f9eSJoseph Koshy.Op Fl z Ar graphdepth
7421ce09caSJoseph Koshy.Op Ar command Op Ar args
75ebccf1e3SJoseph Koshy.Sh DESCRIPTION
76ebccf1e3SJoseph KoshyThe
77ebccf1e3SJoseph Koshy.Nm
78ebccf1e3SJoseph Koshyutility measures system performance using the facilities provided by
79ebccf1e3SJoseph Koshy.Xr hwpmc 4 .
80ebccf1e3SJoseph Koshy.Pp
81ebccf1e3SJoseph KoshyThe
82ebccf1e3SJoseph Koshy.Nm
83ebccf1e3SJoseph Koshyutility can measure both hardware events seen by the system as a
84fbd8b34aSJoseph Koshywhole, and those seen when a specified set of processes are executing
85fbd8b34aSJoseph Koshyon the system's CPUs.
86fbd8b34aSJoseph KoshyIf a specific set of processes is being targeted (for example,
87ebccf1e3SJoseph Koshyif the
88fbd8b34aSJoseph Koshy.Fl t Ar process-spec
89ebccf1e3SJoseph Koshyoption is specified, or if a command line is specified using
90ebccf1e3SJoseph Koshy.Ar command ) ,
91fbd8b34aSJoseph Koshythen measurement occurs till
92fbd8b34aSJoseph Koshy.Ar command
93fbd8b34aSJoseph Koshyexits, or till all target processes specified by the
94fbd8b34aSJoseph Koshy.Fl t Ar process-spec
95fbd8b34aSJoseph Koshyoptions exit, or till the
96ebccf1e3SJoseph Koshy.Nm
97ebccf1e3SJoseph Koshyutility is interrupted by the user.
98fbd8b34aSJoseph KoshyIf a specific set of processes is not targeted for measurement, then
99ebccf1e3SJoseph Koshy.Nm
100ebccf1e3SJoseph Koshywill perform system-wide measurements till interrupted by the
101ebccf1e3SJoseph Koshyuser.
102ebccf1e3SJoseph Koshy.Pp
103ebccf1e3SJoseph KoshyA given invocation of
104ebccf1e3SJoseph Koshy.Nm
105ebccf1e3SJoseph Koshycan mix allocations of system-mode and process-mode PMCs, of both
106ebccf1e3SJoseph Koshycounting and sampling flavors.
107ebccf1e3SJoseph KoshyThe values of all counting PMCs are printed in human readable form
108ebccf1e3SJoseph Koshyat regular intervals by
109ebccf1e3SJoseph Koshy.Nm .
110*047ce3dbSJoseph KoshyThe format of
111*047ce3dbSJoseph Koshy.Nm Ns 's
112*047ce3dbSJoseph Koshyhuman-readable textual output is not stable, and could change
113*047ce3dbSJoseph Koshyin the future.
114f263522aSJoseph KoshyThe output of sampling PMCs may be configured to go to a log file for
115f263522aSJoseph Koshysubsequent offline analysis, or, at the expense of greater
11621ce09caSJoseph Koshyoverhead, may be configured to be printed in text form on the fly.
117ebccf1e3SJoseph Koshy.Pp
118ebccf1e3SJoseph KoshyHardware events to measure are specified to
119ebccf1e3SJoseph Koshy.Nm
120ebccf1e3SJoseph Koshyusing event specifier strings
121ebccf1e3SJoseph Koshy.Ar event-spec .
122ebccf1e3SJoseph KoshyThe syntax of these event specifiers is machine dependent and is
123ebccf1e3SJoseph Koshydocumented in
124ebccf1e3SJoseph Koshy.Xr pmc 3 .
125ebccf1e3SJoseph Koshy.Pp
126ebccf1e3SJoseph KoshyA process-mode PMC may be configured to be inheritable by the target
127ebccf1e3SJoseph Koshyprocess' current and future children.
128ebccf1e3SJoseph Koshy.Sh OPTIONS
129ebccf1e3SJoseph KoshyThe following options are available:
130ebccf1e3SJoseph Koshy.Bl -tag -width indent
13194e9ef85SMateusz Guzik.It Fl A
13294e9ef85SMateusz GuzikSkip symbol lookup and display address instead.
133ebccf1e3SJoseph Koshy.It Fl C
134f263522aSJoseph KoshyToggle between showing cumulative or incremental counts for
135ebccf1e3SJoseph Koshysubsequent counting mode PMCs specified on the command line.
136ebccf1e3SJoseph KoshyThe default is to show incremental counts.
137f263522aSJoseph Koshy.It Fl D Ar pathname
138f263522aSJoseph KoshyCreate files with per-program samples in the directory named
139f263522aSJoseph Koshyby
140f263522aSJoseph Koshy.Ar pathname .
141f263522aSJoseph KoshyThe default is to create these files in the current directory.
142f263522aSJoseph Koshy.It Fl E
143f263522aSJoseph KoshyToggle showing per-process counts at the time a tracked process
144f263522aSJoseph Koshyexits for subsequent process-mode PMCs specified on the command line.
145f263522aSJoseph KoshyThis option is useful for mapping the performance characteristics of a
146f263522aSJoseph Koshycomplex pipeline of processes when used in conjunction with the
147f263522aSJoseph Koshy.Fl d
148f263522aSJoseph Koshyoption.
149f263522aSJoseph KoshyThe default is to not to enable per-process tracking.
1500b86b1bbSFabien Thomas.It Fl F Ar pathname
1510b86b1bbSFabien ThomasPrint calltree (Kcachegrind) information to file
1520b86b1bbSFabien Thomas.Ar pathname .
1530b86b1bbSFabien ThomasIf argument
1540b86b1bbSFabien Thomas.Ar pathname
1550b86b1bbSFabien Thomasis a
1560b86b1bbSFabien Thomas.Dq Li -
1570b86b1bbSFabien Thomasthis information is sent to the output file specified by the
1580b86b1bbSFabien Thomas.Fl o
1590b86b1bbSFabien Thomasoption.
160b6010f9eSJoseph Koshy.It Fl G Ar pathname
161b6010f9eSJoseph KoshyPrint callchain information to file
162b6010f9eSJoseph Koshy.Ar pathname .
163b6010f9eSJoseph KoshyIf argument
164b6010f9eSJoseph Koshy.Ar pathname
165b6010f9eSJoseph Koshyis a
166b6010f9eSJoseph Koshy.Dq Li -
167b6010f9eSJoseph Koshythis information is sent to the output file specified by the
168b6010f9eSJoseph Koshy.Fl o
169b6010f9eSJoseph Koshyoption.
170e22ee9b2SSean Bruno.It Fl I
17194e9ef85SMateusz GuzikShow the offset of the instruction pointer into the symbol.
172959826caSMatt Macy.It Fl L
173959826caSMatt MacyList all event names.
17449874f6eSJoseph Koshy.It Fl M Ar mapfilename
17549874f6eSJoseph KoshyWrite the mapping between executable objects encountered in the event
17649874f6eSJoseph Koshylog and the abbreviated pathnames used for
17749874f6eSJoseph Koshy.Xr gprof 1
17849874f6eSJoseph Koshyprofiles to file
17949874f6eSJoseph Koshy.Ar mapfilename .
18049874f6eSJoseph KoshyIf this option is not specified, mapping information is not written.
18149874f6eSJoseph KoshyArgument
18249874f6eSJoseph Koshy.Ar mapfilename
18349874f6eSJoseph Koshymay be a
18449874f6eSJoseph Koshy.Dq Li -
18549874f6eSJoseph Koshyin which case this mapping information is sent to the output
18649874f6eSJoseph Koshyfile configured by the
18749874f6eSJoseph Koshy.Fl o
18849874f6eSJoseph Koshyoption.
189b6010f9eSJoseph Koshy.It Fl N
190b6010f9eSJoseph KoshyToggle capturing callchain information for subsequent sampling PMCs.
191b6010f9eSJoseph KoshyThe default is for sampling PMCs to capture callchain information.
192ebccf1e3SJoseph Koshy.It Fl O Ar logfilename
19321ce09caSJoseph KoshySend logging output to file
194ebccf1e3SJoseph Koshy.Ar logfilename .
195302cbb90SJoseph KoshyIf
196302cbb90SJoseph Koshy.Ar logfilename
197302cbb90SJoseph Koshyis of the form
198302cbb90SJoseph Koshy.Ar hostname Ns : Ns Ar port ,
199302cbb90SJoseph Koshywhere
200302cbb90SJoseph Koshy.Ar hostname
201302cbb90SJoseph Koshydoes not start with a
202bc84aa4bSRuslan Ermilov.Ql \&.
203302cbb90SJoseph Koshyor a
204bc84aa4bSRuslan Ermilov.Ql / ,
205302cbb90SJoseph Koshythen
206302cbb90SJoseph Koshy.Nm
207302cbb90SJoseph Koshywill open a network socket to host
208302cbb90SJoseph Koshy.Ar hostname
209302cbb90SJoseph Koshyon port
210302cbb90SJoseph Koshy.Ar port .
211302cbb90SJoseph Koshy.Pp
212302cbb90SJoseph KoshyIf the
213302cbb90SJoseph Koshy.Fl O
214302cbb90SJoseph Koshyoption is not specified and one of the logging options is requested,
215302cbb90SJoseph Koshythen
216f263522aSJoseph Koshy.Nm
21721ce09caSJoseph Koshywill print a textual form of the logged events to the configured
218f263522aSJoseph Koshyoutput file.
219ebccf1e3SJoseph Koshy.It Fl P Ar event-spec
220ebccf1e3SJoseph KoshyAllocate a process mode sampling PMC measuring hardware events
221ebccf1e3SJoseph Koshyspecified in
222ebccf1e3SJoseph Koshy.Ar event-spec .
223f263522aSJoseph Koshy.It Fl R Ar logfilename
224f263522aSJoseph KoshyPerform offline analysis using sampling data in file
225f263522aSJoseph Koshy.Ar logfilename .
226ebccf1e3SJoseph Koshy.It Fl S Ar event-spec
227ebccf1e3SJoseph KoshyAllocate a system mode sampling PMC measuring hardware events
228ebccf1e3SJoseph Koshyspecified in
229ebccf1e3SJoseph Koshy.Ar event-spec .
2300b86b1bbSFabien Thomas.It Fl T
23151ae4071SMateusz PiotrowskiUse a
23251ae4071SMateusz Piotrowski.Xr top 1 Ns -like
23351ae4071SMateusz Piotrowskimode for sampling PMCs. The following hotkeys
23451ae4071SMateusz Piotrowskican be used:
23551ae4071SMateusz Piotrowski.Pp
23651ae4071SMateusz Piotrowski.Bl -tag -compact -width "Ctrl+a" -offset 4n
23751ae4071SMateusz Piotrowski.It Ic A
23851ae4071SMateusz PiotrowskiToggle symbol resolution
23951ae4071SMateusz Piotrowski.Sm off
24051ae4071SMateusz Piotrowski.It Ic Ctrl + a
24151ae4071SMateusz Piotrowski.Sm on
24251ae4071SMateusz PiotrowskiSwitch to accumulative mode
24351ae4071SMateusz Piotrowski.Sm off
24451ae4071SMateusz Piotrowski.It Ic Ctrl + d
24551ae4071SMateusz Piotrowski.Sm on
24651ae4071SMateusz PiotrowskiSwitch to delta mode
24751ae4071SMateusz Piotrowski.It Ic f
24851ae4071SMateusz PiotrowskiRepresent the
24951ae4071SMateusz Piotrowski.Dq f
25051ae4071SMateusz Piotrowskicost under
25151ae4071SMateusz Piotrowskithreshold as a dot (calltree only)
25251ae4071SMateusz Piotrowski.It Ic I
25351ae4071SMateusz PiotrowskiToggle showing offsets into symbols
25451ae4071SMateusz Piotrowski.It Ic m
25551ae4071SMateusz PiotrowskiMerge PMCs
25651ae4071SMateusz Piotrowski.It Ic n
25751ae4071SMateusz PiotrowskiChange view
25851ae4071SMateusz Piotrowski.It Ic p
25951ae4071SMateusz PiotrowskiShow next PMC
26051ae4071SMateusz Piotrowski.It Ic q
26151ae4071SMateusz PiotrowskiQuit
26251ae4071SMateusz Piotrowski.It Ic Space
26351ae4071SMateusz PiotrowskiPause
26451ae4071SMateusz Piotrowski.El
2655de96e33SMatt Macy.It Fl U
2665de96e33SMatt MacyToggle capturing user-space call traces while in kernel mode.
2675de96e33SMatt MacyThe default is for sampling PMCs to capture user-space callchain information
2685de96e33SMatt Macywhile in user-space mode, and kernel callchain information while in kernel mode.
269f263522aSJoseph Koshy.It Fl W
270f263522aSJoseph KoshyToggle logging the incremental counts seen by the threads of a
271f263522aSJoseph Koshytracked process each time they are scheduled on a CPU.
272f263522aSJoseph KoshyThis is an experimental feature intended to help analyse the
273f263522aSJoseph Koshydynamic behaviour of processes in the system.
274f263522aSJoseph KoshyIt may incur substantial overhead if enabled.
275f263522aSJoseph KoshyThe default is for this feature to be disabled.
276f6f851a3SScott Long.It Fl a Ar pathname
277f6f851a3SScott LongPerform a symbol and file:line lookup for each address in each
278f6f851a3SScott Longcallgraph and save the output to
279f6f851a3SScott Long.Ar pathname .
280f6f851a3SScott LongUnlike
281f6f851a3SScott Long.Fl m
282f6f851a3SScott Longthat only resolves the first symbol in the graph, this resolves
283f6f851a3SScott Longevery node in the callgraph, or prints out addresses if no
284f6f851a3SScott Longlookup information is available.
285f6f851a3SScott LongThis option requires the
286f6f851a3SScott Long.Fl R
287f6f851a3SScott Longoption to read in samples that were previously collected and
288f6f851a3SScott Longsaved with the
28910813ab3SEric van Gyzen.Fl O
290f6f851a3SScott Longoption.
291ee4910b1SJoseph Koshy.It Fl c Ar cpu-spec
292ee4910b1SJoseph KoshySet the cpus for subsequent system mode PMCs specified on the
293ebccf1e3SJoseph Koshycommand line to
294ee4910b1SJoseph Koshy.Ar cpu-spec .
295ee4910b1SJoseph KoshyArgument
296ee4910b1SJoseph Koshy.Ar cpu-spec
297ee4910b1SJoseph Koshyis a comma separated list of CPU numbers, or the literal
298ee4910b1SJoseph Koshy.Sq *
299ef16b9abSJohn Baldwindenoting all available CPUs.
300ef16b9abSJohn BaldwinThe default is to allocate system mode PMCs on all available
3015477328dSJoseph KoshyCPUs.
302ebccf1e3SJoseph Koshy.It Fl d
303ebccf1e3SJoseph KoshyToggle between process mode PMCs measuring events for the target
304ebccf1e3SJoseph Koshyprocess' current and future children or only measuring events for
305f263522aSJoseph Koshythe target process.
306ebccf1e3SJoseph KoshyThe default is to measure events for the target process alone.
30799e33eabSBaptiste Daroussin(it has to be passed in the command line prior to
30899e33eabSBaptiste Daroussin.Fl p ,
30999e33eabSBaptiste Daroussin.Fl s ,
31099e33eabSBaptiste Daroussin.Fl P ,
31199e33eabSBaptiste Daroussinor
312f42d8decSBaptiste Daroussin.Fl S ) .
313465dadb5SJonathan T. Looney.It Fl e
314465dadb5SJonathan T. LooneySpecify that the gprof profile files will use a wide history counter.
315465dadb5SJonathan T. LooneyThese files are produced in a format compatible with
316465dadb5SJonathan T. Looney.Xr gprof 1 .
317465dadb5SJonathan T. LooneyHowever, other tools that cannot fully parse a BSD-style
318465dadb5SJonathan T. Looneygmon header might be unable to correctly parse these files.
3190b86b1bbSFabien Thomas.It Fl f Ar pluginopt
3200b86b1bbSFabien ThomasPass option string to the active plugin.
3210b86b1bbSFabien Thomas.br
3220b86b1bbSFabien Thomasthreshold=<float> do not display cost under specified value (Top).
3230b86b1bbSFabien Thomas.br
3240b86b1bbSFabien Thomasskiplink=0|1 replace node with cost under threshold by a dot (Top).
325f263522aSJoseph Koshy.It Fl g
326b6010f9eSJoseph KoshyProduce profiles in a format compatible with
327f263522aSJoseph Koshy.Xr gprof 1 .
3281fdbf256SJoseph KoshyA separate profile file is generated for each executable object
3291fdbf256SJoseph Koshyencountered.
3301fdbf256SJoseph KoshyProfile files are placed in sub-directories named by their PMC
3311fdbf256SJoseph Koshyevent name.
332959826caSMatt Macy.It Fl i Ar lwp
333959826caSMatt MacyFilter on thread ID
334959826caSMatt Macy.Ar lwp ,
335959826caSMatt Macywhich you can get from
336959826caSMatt Macy.Xr ps 1
337959826caSMatt Macy.Fl o
338959826caSMatt Macy.Li lwp .
33949874f6eSJoseph Koshy.It Fl k Ar kerneldir
34049874f6eSJoseph KoshySet the pathname of the kernel directory to argument
34149874f6eSJoseph Koshy.Ar kerneldir .
34249874f6eSJoseph KoshyThis directory specifies where
34349874f6eSJoseph Koshy.Nm
34449874f6eSJoseph Koshyshould look for the kernel and its modules.
34538fd3834SJohn BaldwinThe default is to use the path of the running kernel obtained from the
34638fd3834SJohn Baldwin.Va kern.bootfile
34738fd3834SJohn Baldwinsysctl.
348797711a8SRyan MoellerModules will also be searched for in /boot/modules if not found in
349797711a8SRyan Moeller.Ar kerneldir .
35072fe532cSGeorge V. Neville-Neil.It Fl l Ar secs
35172fe532cSGeorge V. Neville-NeilSet system-wide performance measurement duration for
35272fe532cSGeorge V. Neville-Neil.Ar secs
35372fe532cSGeorge V. Neville-Neilseconds.
35472fe532cSGeorge V. Neville-NeilThe argument
35572fe532cSGeorge V. Neville-Neil.Ar secs
35672fe532cSGeorge V. Neville-Neilmay be a fractional value.
357c0252222SAttilio Rao.It Fl m Ar pathname
358c0252222SAttilio RaoPrint the sampled PCs with the name, the start and ending addresses
359c0252222SAttilio Raoof the function within they live.
360c0252222SAttilio RaoThe
361c0252222SAttilio Rao.Ar pathname
3628972c8b6SJoel Dahlargument is mandatory and indicates where the information will be stored.
363c0252222SAttilio RaoIf argument
364c0252222SAttilio Rao.Ar pathname
365c0252222SAttilio Raois a
366c0252222SAttilio Rao.Dq Li -
367c0252222SAttilio Raothis information is sent to the output file specified by the
368c0252222SAttilio Rao.Fl o
369c0252222SAttilio Raooption.
37010813ab3SEric van GyzenThis option requires the
37110813ab3SEric van Gyzen.Fl R
37210813ab3SEric van Gyzenoption to read in samples that were previously collected and
37310813ab3SEric van Gyzensaved with the
37410813ab3SEric van Gyzen.Fl O
37510813ab3SEric van Gyzenoption.
376ebccf1e3SJoseph Koshy.It Fl n Ar rate
377ebccf1e3SJoseph KoshySet the default sampling rate for subsequent sampling mode
378ebccf1e3SJoseph KoshyPMCs specified on the command line.
379ebccf1e3SJoseph KoshyThe default is to configure PMCs to sample the CPU's instruction
380ebccf1e3SJoseph Koshypointer every 65536 events.
381ebccf1e3SJoseph Koshy.It Fl o Ar outputfile
38221ce09caSJoseph KoshySend counter readings and textual representations of logged data
383ebccf1e3SJoseph Koshyto file
384ebccf1e3SJoseph Koshy.Ar outputfile .
385ebccf1e3SJoseph KoshyThe default is to send output to
386b6010f9eSJoseph Koshy.Pa stderr
387b6010f9eSJoseph Koshywhen collecting live data and to
388b6010f9eSJoseph Koshy.Pa stdout
389b6010f9eSJoseph Koshywhen processing a pre-existing logfile.
390ebccf1e3SJoseph Koshy.It Fl p Ar event-spec
391ebccf1e3SJoseph KoshyAllocate a process mode counting PMC measuring hardware events
392ebccf1e3SJoseph Koshyspecified in
393ebccf1e3SJoseph Koshy.Ar event-spec .
39449874f6eSJoseph Koshy.It Fl q
39549874f6eSJoseph KoshyDecrease verbosity.
39649874f6eSJoseph Koshy.It Fl r Ar fsroot
39749874f6eSJoseph KoshySet the top of the filesystem hierarchy under which executables
39849874f6eSJoseph Koshyare located to argument
39949874f6eSJoseph Koshy.Ar fsroot .
40049874f6eSJoseph KoshyThe default is
40149874f6eSJoseph Koshy.Pa / .
402ebccf1e3SJoseph Koshy.It Fl s Ar event-spec
403ebccf1e3SJoseph KoshyAllocate a system mode counting PMC measuring hardware events
404ebccf1e3SJoseph Koshyspecified in
405ebccf1e3SJoseph Koshy.Ar event-spec .
406fbd8b34aSJoseph Koshy.It Fl t Ar process-spec
407fbd8b34aSJoseph KoshyAttach process mode PMCs to the processes named by argument
408fbd8b34aSJoseph Koshy.Ar process-spec .
409fbd8b34aSJoseph KoshyArgument
410fbd8b34aSJoseph Koshy.Ar process-spec
411fbd8b34aSJoseph Koshymay be a non-negative integer denoting a specific process id, or a
412fbd8b34aSJoseph Koshyregular expression for selecting processes based on their command names.
413959826caSMatt Macy.It Fl u Ar event-spec
414959826caSMatt MacyProvide short description of event.
41549874f6eSJoseph Koshy.It Fl v
41649874f6eSJoseph KoshyIncrease verbosity.
417ebccf1e3SJoseph Koshy.It Fl w Ar secs
4180b86b1bbSFabien ThomasPrint the values of all counting mode PMCs or sampling mode PMCs
4190b86b1bbSFabien Thomasfor top mode every
420ebccf1e3SJoseph Koshy.Ar secs
421ebccf1e3SJoseph Koshyseconds.
422ebccf1e3SJoseph KoshyThe argument
423ebccf1e3SJoseph Koshy.Ar secs
424ebccf1e3SJoseph Koshymay be a fractional value.
425ebccf1e3SJoseph KoshyThe default interval is 5 seconds.
426b6010f9eSJoseph Koshy.It Fl z Ar graphdepth
427b6010f9eSJoseph KoshyWhen printing system-wide callgraphs, limit callgraphs to the depth
428b6010f9eSJoseph Koshyspecified by argument
429b6010f9eSJoseph Koshy.Ar graphdepth .
430ebccf1e3SJoseph Koshy.El
431ebccf1e3SJoseph Koshy.Pp
432ebccf1e3SJoseph KoshyIf
433ebccf1e3SJoseph Koshy.Ar command
434ebccf1e3SJoseph Koshyis specified, it is executed using
435ebccf1e3SJoseph Koshy.Xr execvp 3 .
436ebccf1e3SJoseph Koshy.Sh EXAMPLES
437ebccf1e3SJoseph KoshyTo perform system-wide statistical sampling on an AMD Athlon CPU with
438ebccf1e3SJoseph Koshysamples taken every 32768 instruction retirals and data being sampled
439ebccf1e3SJoseph Koshyto file
44021ce09caSJoseph Koshy.Pa sample.stat ,
441ebccf1e3SJoseph Koshyuse:
44200028966SRobert Watson.Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions"
443ebccf1e3SJoseph Koshy.Pp
444ebccf1e3SJoseph KoshyTo execute
445a2c0b3aeSJoseph Koshy.Nm firefox
446ebccf1e3SJoseph Koshyand measure the number of data cache misses suffered
447ebccf1e3SJoseph Koshyby it and its children every 12 seconds on an AMD Athlon, use:
448a2c0b3aeSJoseph Koshy.Dl "pmcstat -d -w 12 -p k7-dc-misses firefox"
4491fdbf256SJoseph Koshy.Pp
4502c79db51SJoseph KoshyTo measure instructions retired for all processes named
451fbd8b34aSJoseph Koshy.Dq emacs
452fbd8b34aSJoseph Koshyuse:
453fbd8b34aSJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions"
454fbd8b34aSJoseph Koshy.Pp
4552c79db51SJoseph KoshyTo measure instructions retired for processes named
4562c79db51SJoseph Koshy.Dq emacs
4572c79db51SJoseph Koshyfor a period of 10 seconds use:
4582c79db51SJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions sleep 10"
4592c79db51SJoseph Koshy.Pp
460ee4910b1SJoseph KoshyTo count instruction tlb-misses on CPUs 0 and 2 on a Intel
461ee4910b1SJoseph KoshyPentium Pro/Pentium III SMP system use:
462ee4910b1SJoseph Koshy.Dl "pmcstat -c 0,2 -s p6-itlb-miss"
463ee4910b1SJoseph Koshy.Pp
464b6010f9eSJoseph KoshyTo collect profiling information for a specific process with pid 1234
465b6010f9eSJoseph Koshybased on instruction cache misses seen by it use:
466b6010f9eSJoseph Koshy.Dl "pmcstat -P ic-misses -t 1234 -O /tmp/sample.out"
467b6010f9eSJoseph Koshy.Pp
468ee4910b1SJoseph KoshyTo perform system-wide sampling on all configured processors
469ee4910b1SJoseph Koshybased on processor instructions retired use:
4701fdbf256SJoseph Koshy.Dl "pmcstat -S instructions -O /tmp/sample.out"
471b6010f9eSJoseph KoshyIf callgraph capture is not desired use:
472b6010f9eSJoseph Koshy.Dl "pmcstat -N -S instructions -O /tmp/sample.out"
4731fdbf256SJoseph Koshy.Pp
474302cbb90SJoseph KoshyTo send the generated event log to a remote machine use:
475302cbb90SJoseph Koshy.Dl "pmcstat -S instructions -O remotehost:port"
476302cbb90SJoseph KoshyOn the remote machine, the sample log can be collected using
477302cbb90SJoseph Koshy.Xr nc 1 :
478302cbb90SJoseph Koshy.Dl "nc -l remotehost port > /tmp/sample.out"
479302cbb90SJoseph Koshy.Pp
4801fdbf256SJoseph KoshyTo generate
4811fdbf256SJoseph Koshy.Xr gprof 1
482b6010f9eSJoseph Koshycompatible profiles from a sample file use:
4831fdbf256SJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -g"
484b6010f9eSJoseph Koshy.Pp
485b6010f9eSJoseph KoshyTo print a system-wide profile with callgraphs to file
486b6010f9eSJoseph Koshy.Pa "foo.graph"
487b6010f9eSJoseph Koshyuse:
488b6010f9eSJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -G foo.graph"
489ebccf1e3SJoseph Koshy.Sh DIAGNOSTICS
490e572c7a7SJoseph KoshyIf option
491e572c7a7SJoseph Koshy.Fl v
492e572c7a7SJoseph Koshyis specified,
493e572c7a7SJoseph Koshy.Nm
494e572c7a7SJoseph Koshymay issue the following diagnostic messages:
49546355096SJoel Dahl.Bl -diag
496e572c7a7SJoseph Koshy.It "#callchain/dubious-frames"
497e572c7a7SJoseph KoshyThe number of callchain records that had an
498e572c7a7SJoseph Koshy.Dq impossible
499e572c7a7SJoseph Koshyvalue for a return address.
500e572c7a7SJoseph Koshy.It "#exec handling errors"
501e572c7a7SJoseph KoshyThe number of
502e572c7a7SJoseph Koshy.Xr exec 2
503e572c7a7SJoseph Koshyevents in the log file that named executables that could not be
504e572c7a7SJoseph Koshyanalyzed.
505e572c7a7SJoseph Koshy.It "#exec/elf"
506e572c7a7SJoseph KoshyThe number of
507e572c7a7SJoseph Koshy.Xr exec 2
508e572c7a7SJoseph Koshyevents that named ELF executables.
509e572c7a7SJoseph Koshy.It "#exec/unknown"
510e572c7a7SJoseph KoshyThe number of
511e572c7a7SJoseph Koshy.Xr exec 2
512e572c7a7SJoseph Koshyevents that named executables with unrecognized formats.
513e572c7a7SJoseph Koshy.It "#samples/total"
514e572c7a7SJoseph KoshyThe total number of samples in the log file.
515e572c7a7SJoseph Koshy.It "#samples/unclaimed"
516e572c7a7SJoseph KoshyThe number of samples that could not be correlated to a known
517e572c7a7SJoseph Koshyexecutable object (i.e., to an executable, shared library, the
518e572c7a7SJoseph Koshykernel or the runtime loader).
519e572c7a7SJoseph Koshy.It "#samples/unknown-object"
520e572c7a7SJoseph KoshyThe number of samples that were associated with an executable
521e572c7a7SJoseph Koshywith an unrecognized object format.
522e572c7a7SJoseph Koshy.El
523e572c7a7SJoseph Koshy.Pp
52421ce09caSJoseph Koshy.Ex -std
525b6010f9eSJoseph Koshy.Sh COMPATIBILITY
526b6010f9eSJoseph KoshyDue to the limitations of the
527b6010f9eSJoseph Koshy.Pa gmon.out
528b6010f9eSJoseph Koshyfile format,
529b6010f9eSJoseph Koshy.Xr gprof 1
530b6010f9eSJoseph Koshycompatible profiles generated by the
531b6010f9eSJoseph Koshy.Fl g
532b6010f9eSJoseph Koshyoption do not contain information about calls that cross executable
533b6010f9eSJoseph Koshyboundaries.
534b6010f9eSJoseph KoshyThe generated
535b6010f9eSJoseph Koshy.Pa gmon.out
536b6010f9eSJoseph Koshyfiles are also only meaningful for native executables.
537ebccf1e3SJoseph Koshy.Sh SEE ALSO
538f263522aSJoseph Koshy.Xr gprof 1 ,
539302cbb90SJoseph Koshy.Xr nc 1 ,
540ebccf1e3SJoseph Koshy.Xr execvp 3 ,
541ebccf1e3SJoseph Koshy.Xr pmc 3 ,
54221ce09caSJoseph Koshy.Xr pmclog 3 ,
543ebccf1e3SJoseph Koshy.Xr hwpmc 4 ,
544ebccf1e3SJoseph Koshy.Xr pmccontrol 8 ,
545ebccf1e3SJoseph Koshy.Xr sysctl 8
54621ce09caSJoseph Koshy.Sh HISTORY
54721ce09caSJoseph KoshyThe
54821ce09caSJoseph Koshy.Nm
54921ce09caSJoseph Koshyutility first appeared in
55021ce09caSJoseph Koshy.Fx 6.0 .
5511fdbf256SJoseph KoshyIt is
5521fdbf256SJoseph Koshy.Ud
55321ce09caSJoseph Koshy.Sh AUTHORS
55401c2b8acSBaptiste Daroussin.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org
5559f8adcefSJoseph Koshy.Sh BUGS
556bc84aa4bSRuslan ErmilovThe
5579f8adcefSJoseph Koshy.Nm
558bc84aa4bSRuslan Ermilovutility cannot yet analyse
559302cbb90SJoseph Koshy.Xr hwpmc 4
560302cbb90SJoseph Koshylogs generated by non-native architectures.
561