xref: /freebsd/usr.sbin/pmcstat/pmcstat.8 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
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.\"
26296a0987SJessica Clarke.Dd May 31, 2023
27ebccf1e3SJoseph Koshy.Dt PMCSTAT 8
28aa12cea2SUlrich Spörlein.Os
29ebccf1e3SJoseph Koshy.Sh NAME
30ebccf1e3SJoseph Koshy.Nm pmcstat
3121ce09caSJoseph Koshy.Nd "performance measurement with performance monitoring hardware"
32ebccf1e3SJoseph Koshy.Sh SYNOPSIS
33ebccf1e3SJoseph Koshy.Nm
3494e9ef85SMateusz Guzik.Op Fl A
35ebccf1e3SJoseph Koshy.Op Fl C
3615139246SJoseph Koshy.Op Fl D Ar pathname
37f263522aSJoseph Koshy.Op Fl E
380b86b1bbSFabien Thomas.Op Fl F Ar pathname
39b6010f9eSJoseph Koshy.Op Fl G Ar pathname
40e22ee9b2SSean Bruno.Op Fl I
41959826caSMatt Macy.Op Fl L
4249874f6eSJoseph Koshy.Op Fl M Ar mapfilename
43b6010f9eSJoseph Koshy.Op Fl N
44ebccf1e3SJoseph Koshy.Op Fl O Ar logfilename
45ebccf1e3SJoseph Koshy.Op Fl P Ar event-spec
46f263522aSJoseph Koshy.Op Fl R Ar logfilename
47ebccf1e3SJoseph Koshy.Op Fl S Ar event-spec
480b86b1bbSFabien Thomas.Op Fl T
495de96e33SMatt Macy.Op Fl U
50f263522aSJoseph Koshy.Op Fl W
51f6f851a3SScott Long.Op Fl a Ar pathname
52ee4910b1SJoseph Koshy.Op Fl c Ar cpu-spec
53ebccf1e3SJoseph Koshy.Op Fl d
54465dadb5SJonathan T. Looney.Op Fl e
550b86b1bbSFabien Thomas.Op Fl f Ar pluginopt
56f263522aSJoseph Koshy.Op Fl g
57959826caSMatt Macy.Op Fl i Ar lwp
5872fe532cSGeorge V. Neville-Neil.Op Fl l Ar secs
59c0252222SAttilio Rao.Op Fl m Ar pathname
6021ce09caSJoseph Koshy.Op Fl n Ar rate
61ebccf1e3SJoseph Koshy.Op Fl o Ar outputfile
62ebccf1e3SJoseph Koshy.Op Fl p Ar event-spec
6349874f6eSJoseph Koshy.Op Fl q
6449874f6eSJoseph Koshy.Op Fl r Ar fsroot
65ebccf1e3SJoseph Koshy.Op Fl s Ar event-spec
66fbd8b34aSJoseph Koshy.Op Fl t Ar process-spec
67959826caSMatt Macy.Op Fl u Ar event-spec
6849874f6eSJoseph Koshy.Op Fl v
6921ce09caSJoseph Koshy.Op Fl w Ar secs
70b6010f9eSJoseph Koshy.Op Fl z Ar graphdepth
7121ce09caSJoseph Koshy.Op Ar command Op Ar args
72ebccf1e3SJoseph Koshy.Sh DESCRIPTION
73ebccf1e3SJoseph KoshyThe
74ebccf1e3SJoseph Koshy.Nm
75ebccf1e3SJoseph Koshyutility measures system performance using the facilities provided by
76ebccf1e3SJoseph Koshy.Xr hwpmc 4 .
77ebccf1e3SJoseph Koshy.Pp
78ebccf1e3SJoseph KoshyThe
79ebccf1e3SJoseph Koshy.Nm
80ebccf1e3SJoseph Koshyutility can measure both hardware events seen by the system as a
81fbd8b34aSJoseph Koshywhole, and those seen when a specified set of processes are executing
82fbd8b34aSJoseph Koshyon the system's CPUs.
83fbd8b34aSJoseph KoshyIf a specific set of processes is being targeted (for example,
84ebccf1e3SJoseph Koshyif the
85fbd8b34aSJoseph Koshy.Fl t Ar process-spec
86ebccf1e3SJoseph Koshyoption is specified, or if a command line is specified using
87ebccf1e3SJoseph Koshy.Ar command ) ,
88fbd8b34aSJoseph Koshythen measurement occurs till
89fbd8b34aSJoseph Koshy.Ar command
90fbd8b34aSJoseph Koshyexits, or till all target processes specified by the
91fbd8b34aSJoseph Koshy.Fl t Ar process-spec
92fbd8b34aSJoseph Koshyoptions exit, or till the
93ebccf1e3SJoseph Koshy.Nm
94ebccf1e3SJoseph Koshyutility is interrupted by the user.
95fbd8b34aSJoseph KoshyIf a specific set of processes is not targeted for measurement, then
96ebccf1e3SJoseph Koshy.Nm
97ebccf1e3SJoseph Koshywill perform system-wide measurements till interrupted by the
98ebccf1e3SJoseph Koshyuser.
99ebccf1e3SJoseph Koshy.Pp
100ebccf1e3SJoseph KoshyA given invocation of
101ebccf1e3SJoseph Koshy.Nm
102ebccf1e3SJoseph Koshycan mix allocations of system-mode and process-mode PMCs, of both
103ebccf1e3SJoseph Koshycounting and sampling flavors.
104ebccf1e3SJoseph KoshyThe values of all counting PMCs are printed in human readable form
105ebccf1e3SJoseph Koshyat regular intervals by
106ebccf1e3SJoseph Koshy.Nm .
107047ce3dbSJoseph KoshyThe format of
108047ce3dbSJoseph Koshy.Nm Ns 's
109047ce3dbSJoseph Koshyhuman-readable textual output is not stable, and could change
110047ce3dbSJoseph Koshyin the future.
111f263522aSJoseph KoshyThe output of sampling PMCs may be configured to go to a log file for
112f263522aSJoseph Koshysubsequent offline analysis, or, at the expense of greater
11321ce09caSJoseph Koshyoverhead, may be configured to be printed in text form on the fly.
114ebccf1e3SJoseph Koshy.Pp
115ebccf1e3SJoseph KoshyHardware events to measure are specified to
116ebccf1e3SJoseph Koshy.Nm
117ebccf1e3SJoseph Koshyusing event specifier strings
118ebccf1e3SJoseph Koshy.Ar event-spec .
119ebccf1e3SJoseph KoshyThe syntax of these event specifiers is machine dependent and is
120ebccf1e3SJoseph Koshydocumented in
121ebccf1e3SJoseph Koshy.Xr pmc 3 .
122ebccf1e3SJoseph Koshy.Pp
123ebccf1e3SJoseph KoshyA process-mode PMC may be configured to be inheritable by the target
124ebccf1e3SJoseph Koshyprocess' current and future children.
125ebccf1e3SJoseph Koshy.Sh OPTIONS
126ebccf1e3SJoseph KoshyThe following options are available:
127ebccf1e3SJoseph Koshy.Bl -tag -width indent
12894e9ef85SMateusz Guzik.It Fl A
12994e9ef85SMateusz GuzikSkip symbol lookup and display address instead.
130ebccf1e3SJoseph Koshy.It Fl C
131f263522aSJoseph KoshyToggle between showing cumulative or incremental counts for
132ebccf1e3SJoseph Koshysubsequent counting mode PMCs specified on the command line.
133ebccf1e3SJoseph KoshyThe default is to show incremental counts.
134f263522aSJoseph Koshy.It Fl D Ar pathname
135f263522aSJoseph KoshyCreate files with per-program samples in the directory named
136f263522aSJoseph Koshyby
137f263522aSJoseph Koshy.Ar pathname .
138f263522aSJoseph KoshyThe default is to create these files in the current directory.
139f263522aSJoseph Koshy.It Fl E
140f263522aSJoseph KoshyToggle showing per-process counts at the time a tracked process
141f263522aSJoseph Koshyexits for subsequent process-mode PMCs specified on the command line.
142f263522aSJoseph KoshyThis option is useful for mapping the performance characteristics of a
143f263522aSJoseph Koshycomplex pipeline of processes when used in conjunction with the
144f263522aSJoseph Koshy.Fl d
145f263522aSJoseph Koshyoption.
146f263522aSJoseph KoshyThe default is to not to enable per-process tracking.
1470b86b1bbSFabien Thomas.It Fl F Ar pathname
1480b86b1bbSFabien ThomasPrint calltree (Kcachegrind) information to file
1490b86b1bbSFabien Thomas.Ar pathname .
1500b86b1bbSFabien ThomasIf argument
1510b86b1bbSFabien Thomas.Ar pathname
1520b86b1bbSFabien Thomasis a
1530b86b1bbSFabien Thomas.Dq Li -
1540b86b1bbSFabien Thomasthis information is sent to the output file specified by the
1550b86b1bbSFabien Thomas.Fl o
1560b86b1bbSFabien Thomasoption.
157b6010f9eSJoseph Koshy.It Fl G Ar pathname
158b6010f9eSJoseph KoshyPrint callchain information to file
159b6010f9eSJoseph Koshy.Ar pathname .
160b6010f9eSJoseph KoshyIf argument
161b6010f9eSJoseph Koshy.Ar pathname
162b6010f9eSJoseph Koshyis a
163b6010f9eSJoseph Koshy.Dq Li -
164b6010f9eSJoseph Koshythis information is sent to the output file specified by the
165b6010f9eSJoseph Koshy.Fl o
166b6010f9eSJoseph Koshyoption.
167e22ee9b2SSean Bruno.It Fl I
16894e9ef85SMateusz GuzikShow the offset of the instruction pointer into the symbol.
169959826caSMatt Macy.It Fl L
170959826caSMatt MacyList all event names.
17149874f6eSJoseph Koshy.It Fl M Ar mapfilename
17249874f6eSJoseph KoshyWrite the mapping between executable objects encountered in the event
17349874f6eSJoseph Koshylog and the abbreviated pathnames used for
17449874f6eSJoseph Koshy.Xr gprof 1
17549874f6eSJoseph Koshyprofiles to file
17649874f6eSJoseph Koshy.Ar mapfilename .
17749874f6eSJoseph KoshyIf this option is not specified, mapping information is not written.
17849874f6eSJoseph KoshyArgument
17949874f6eSJoseph Koshy.Ar mapfilename
18049874f6eSJoseph Koshymay be a
18149874f6eSJoseph Koshy.Dq Li -
18249874f6eSJoseph Koshyin which case this mapping information is sent to the output
18349874f6eSJoseph Koshyfile configured by the
18449874f6eSJoseph Koshy.Fl o
18549874f6eSJoseph Koshyoption.
186b6010f9eSJoseph Koshy.It Fl N
187b6010f9eSJoseph KoshyToggle capturing callchain information for subsequent sampling PMCs.
188b6010f9eSJoseph KoshyThe default is for sampling PMCs to capture callchain information.
189ebccf1e3SJoseph Koshy.It Fl O Ar logfilename
19021ce09caSJoseph KoshySend logging output to file
191ebccf1e3SJoseph Koshy.Ar logfilename .
192302cbb90SJoseph KoshyIf
193302cbb90SJoseph Koshy.Ar logfilename
194302cbb90SJoseph Koshyis of the form
195302cbb90SJoseph Koshy.Ar hostname Ns : Ns Ar port ,
196302cbb90SJoseph Koshywhere
197302cbb90SJoseph Koshy.Ar hostname
198302cbb90SJoseph Koshydoes not start with a
199bc84aa4bSRuslan Ermilov.Ql \&.
200302cbb90SJoseph Koshyor a
201bc84aa4bSRuslan Ermilov.Ql / ,
202302cbb90SJoseph Koshythen
203302cbb90SJoseph Koshy.Nm
204302cbb90SJoseph Koshywill open a network socket to host
205302cbb90SJoseph Koshy.Ar hostname
206302cbb90SJoseph Koshyon port
207302cbb90SJoseph Koshy.Ar port .
208302cbb90SJoseph Koshy.Pp
209302cbb90SJoseph KoshyIf the
210302cbb90SJoseph Koshy.Fl O
211302cbb90SJoseph Koshyoption is not specified and one of the logging options is requested,
212302cbb90SJoseph Koshythen
213f263522aSJoseph Koshy.Nm
21421ce09caSJoseph Koshywill print a textual form of the logged events to the configured
215f263522aSJoseph Koshyoutput file.
216ebccf1e3SJoseph Koshy.It Fl P Ar event-spec
217ebccf1e3SJoseph KoshyAllocate a process mode sampling PMC measuring hardware events
218ebccf1e3SJoseph Koshyspecified in
219ebccf1e3SJoseph Koshy.Ar event-spec .
220f263522aSJoseph Koshy.It Fl R Ar logfilename
221f263522aSJoseph KoshyPerform offline analysis using sampling data in file
222f263522aSJoseph Koshy.Ar logfilename .
223ebccf1e3SJoseph Koshy.It Fl S Ar event-spec
224ebccf1e3SJoseph KoshyAllocate a system mode sampling PMC measuring hardware events
225ebccf1e3SJoseph Koshyspecified in
226ebccf1e3SJoseph Koshy.Ar event-spec .
2270b86b1bbSFabien Thomas.It Fl T
22851ae4071SMateusz PiotrowskiUse a
22951ae4071SMateusz Piotrowski.Xr top 1 Ns -like
230*a5b3e563SMitchell Hornemode for sampling PMCs.
231*a5b3e563SMitchell HorneThe following hotkeys can be used:
23251ae4071SMateusz Piotrowski.Pp
23351ae4071SMateusz Piotrowski.Bl -tag -compact -width "Ctrl+a" -offset 4n
23451ae4071SMateusz Piotrowski.It Ic A
23551ae4071SMateusz PiotrowskiToggle symbol resolution
23651ae4071SMateusz Piotrowski.Sm off
23751ae4071SMateusz Piotrowski.It Ic Ctrl + a
23851ae4071SMateusz Piotrowski.Sm on
23951ae4071SMateusz PiotrowskiSwitch to accumulative mode
24051ae4071SMateusz Piotrowski.Sm off
24151ae4071SMateusz Piotrowski.It Ic Ctrl + d
24251ae4071SMateusz Piotrowski.Sm on
24351ae4071SMateusz PiotrowskiSwitch to delta mode
24451ae4071SMateusz Piotrowski.It Ic f
24551ae4071SMateusz PiotrowskiRepresent the
24651ae4071SMateusz Piotrowski.Dq f
24751ae4071SMateusz Piotrowskicost under
24851ae4071SMateusz Piotrowskithreshold as a dot (calltree only)
24951ae4071SMateusz Piotrowski.It Ic I
25051ae4071SMateusz PiotrowskiToggle showing offsets into symbols
25151ae4071SMateusz Piotrowski.It Ic m
25251ae4071SMateusz PiotrowskiMerge PMCs
25351ae4071SMateusz Piotrowski.It Ic n
25451ae4071SMateusz PiotrowskiChange view
25551ae4071SMateusz Piotrowski.It Ic p
25651ae4071SMateusz PiotrowskiShow next PMC
25751ae4071SMateusz Piotrowski.It Ic q
25851ae4071SMateusz PiotrowskiQuit
25951ae4071SMateusz Piotrowski.It Ic Space
26051ae4071SMateusz PiotrowskiPause
26151ae4071SMateusz Piotrowski.El
2625de96e33SMatt Macy.It Fl U
2635de96e33SMatt MacyToggle capturing user-space call traces while in kernel mode.
2645de96e33SMatt MacyThe default is for sampling PMCs to capture user-space callchain information
2655de96e33SMatt Macywhile in user-space mode, and kernel callchain information while in kernel mode.
266f263522aSJoseph Koshy.It Fl W
267f263522aSJoseph KoshyToggle logging the incremental counts seen by the threads of a
268f263522aSJoseph Koshytracked process each time they are scheduled on a CPU.
269f263522aSJoseph KoshyThis is an experimental feature intended to help analyse the
270f263522aSJoseph Koshydynamic behaviour of processes in the system.
271f263522aSJoseph KoshyIt may incur substantial overhead if enabled.
272f263522aSJoseph KoshyThe default is for this feature to be disabled.
273f6f851a3SScott Long.It Fl a Ar pathname
274f6f851a3SScott LongPerform a symbol and file:line lookup for each address in each
275f6f851a3SScott Longcallgraph and save the output to
276f6f851a3SScott Long.Ar pathname .
277f6f851a3SScott LongUnlike
278f6f851a3SScott Long.Fl m
279f6f851a3SScott Longthat only resolves the first symbol in the graph, this resolves
280f6f851a3SScott Longevery node in the callgraph, or prints out addresses if no
281f6f851a3SScott Longlookup information is available.
282f6f851a3SScott LongThis option requires the
283f6f851a3SScott Long.Fl R
284f6f851a3SScott Longoption to read in samples that were previously collected and
285f6f851a3SScott Longsaved with the
28610813ab3SEric van Gyzen.Fl O
287f6f851a3SScott Longoption.
288ee4910b1SJoseph Koshy.It Fl c Ar cpu-spec
289ee4910b1SJoseph KoshySet the cpus for subsequent system mode PMCs specified on the
290ebccf1e3SJoseph Koshycommand line to
291ee4910b1SJoseph Koshy.Ar cpu-spec .
292ee4910b1SJoseph KoshyArgument
293ee4910b1SJoseph Koshy.Ar cpu-spec
294ee4910b1SJoseph Koshyis a comma separated list of CPU numbers, or the literal
295ee4910b1SJoseph Koshy.Sq *
296ef16b9abSJohn Baldwindenoting all available CPUs.
297ef16b9abSJohn BaldwinThe default is to allocate system mode PMCs on all available
2985477328dSJoseph KoshyCPUs.
299ebccf1e3SJoseph Koshy.It Fl d
300ebccf1e3SJoseph KoshyToggle between process mode PMCs measuring events for the target
301ebccf1e3SJoseph Koshyprocess' current and future children or only measuring events for
302f263522aSJoseph Koshythe target process.
303ebccf1e3SJoseph KoshyThe default is to measure events for the target process alone.
30499e33eabSBaptiste Daroussin(it has to be passed in the command line prior to
30599e33eabSBaptiste Daroussin.Fl p ,
30699e33eabSBaptiste Daroussin.Fl s ,
30799e33eabSBaptiste Daroussin.Fl P ,
30899e33eabSBaptiste Daroussinor
309f42d8decSBaptiste Daroussin.Fl S ) .
310465dadb5SJonathan T. Looney.It Fl e
311465dadb5SJonathan T. LooneySpecify that the gprof profile files will use a wide history counter.
312465dadb5SJonathan T. LooneyThese files are produced in a format compatible with
313465dadb5SJonathan T. Looney.Xr gprof 1 .
314465dadb5SJonathan T. LooneyHowever, other tools that cannot fully parse a BSD-style
315465dadb5SJonathan T. Looneygmon header might be unable to correctly parse these files.
3160b86b1bbSFabien Thomas.It Fl f Ar pluginopt
3170b86b1bbSFabien ThomasPass option string to the active plugin.
3180b86b1bbSFabien Thomas.br
3190b86b1bbSFabien Thomasthreshold=<float> do not display cost under specified value (Top).
3200b86b1bbSFabien Thomas.br
3210b86b1bbSFabien Thomasskiplink=0|1 replace node with cost under threshold by a dot (Top).
322f263522aSJoseph Koshy.It Fl g
323b6010f9eSJoseph KoshyProduce profiles in a format compatible with
324f263522aSJoseph Koshy.Xr gprof 1 .
3251fdbf256SJoseph KoshyA separate profile file is generated for each executable object
3261fdbf256SJoseph Koshyencountered.
3271fdbf256SJoseph KoshyProfile files are placed in sub-directories named by their PMC
3281fdbf256SJoseph Koshyevent name.
329959826caSMatt Macy.It Fl i Ar lwp
330959826caSMatt MacyFilter on thread ID
331959826caSMatt Macy.Ar lwp ,
332959826caSMatt Macywhich you can get from
333959826caSMatt Macy.Xr ps 1
334959826caSMatt Macy.Fl o
335959826caSMatt Macy.Li lwp .
33672fe532cSGeorge V. Neville-Neil.It Fl l Ar secs
33772fe532cSGeorge V. Neville-NeilSet system-wide performance measurement duration for
33872fe532cSGeorge V. Neville-Neil.Ar secs
33972fe532cSGeorge V. Neville-Neilseconds.
34072fe532cSGeorge V. Neville-NeilThe argument
34172fe532cSGeorge V. Neville-Neil.Ar secs
34272fe532cSGeorge V. Neville-Neilmay be a fractional value.
343c0252222SAttilio Rao.It Fl m Ar pathname
344c0252222SAttilio RaoPrint the sampled PCs with the name, the start and ending addresses
345c0252222SAttilio Raoof the function within they live.
346c0252222SAttilio RaoThe
347c0252222SAttilio Rao.Ar pathname
3488972c8b6SJoel Dahlargument is mandatory and indicates where the information will be stored.
349c0252222SAttilio RaoIf argument
350c0252222SAttilio Rao.Ar pathname
351c0252222SAttilio Raois a
352c0252222SAttilio Rao.Dq Li -
353c0252222SAttilio Raothis information is sent to the output file specified by the
354c0252222SAttilio Rao.Fl o
355c0252222SAttilio Raooption.
35610813ab3SEric van GyzenThis option requires the
35710813ab3SEric van Gyzen.Fl R
35810813ab3SEric van Gyzenoption to read in samples that were previously collected and
35910813ab3SEric van Gyzensaved with the
36010813ab3SEric van Gyzen.Fl O
36110813ab3SEric van Gyzenoption.
362ebccf1e3SJoseph Koshy.It Fl n Ar rate
363ebccf1e3SJoseph KoshySet the default sampling rate for subsequent sampling mode
364ebccf1e3SJoseph KoshyPMCs specified on the command line.
365ebccf1e3SJoseph KoshyThe default is to configure PMCs to sample the CPU's instruction
366ebccf1e3SJoseph Koshypointer every 65536 events.
367ebccf1e3SJoseph Koshy.It Fl o Ar outputfile
36821ce09caSJoseph KoshySend counter readings and textual representations of logged data
369ebccf1e3SJoseph Koshyto file
370ebccf1e3SJoseph Koshy.Ar outputfile .
371ebccf1e3SJoseph KoshyThe default is to send output to
372b6010f9eSJoseph Koshy.Pa stderr
373b6010f9eSJoseph Koshywhen collecting live data and to
374b6010f9eSJoseph Koshy.Pa stdout
375b6010f9eSJoseph Koshywhen processing a pre-existing logfile.
376ebccf1e3SJoseph Koshy.It Fl p Ar event-spec
377ebccf1e3SJoseph KoshyAllocate a process mode counting PMC measuring hardware events
378ebccf1e3SJoseph Koshyspecified in
379ebccf1e3SJoseph Koshy.Ar event-spec .
38049874f6eSJoseph Koshy.It Fl q
38149874f6eSJoseph KoshyDecrease verbosity.
38249874f6eSJoseph Koshy.It Fl r Ar fsroot
38349874f6eSJoseph KoshySet the top of the filesystem hierarchy under which executables
38449874f6eSJoseph Koshyare located to argument
38549874f6eSJoseph Koshy.Ar fsroot .
38649874f6eSJoseph KoshyThe default is
38749874f6eSJoseph Koshy.Pa / .
388ebccf1e3SJoseph Koshy.It Fl s Ar event-spec
389ebccf1e3SJoseph KoshyAllocate a system mode counting PMC measuring hardware events
390ebccf1e3SJoseph Koshyspecified in
391ebccf1e3SJoseph Koshy.Ar event-spec .
392fbd8b34aSJoseph Koshy.It Fl t Ar process-spec
393fbd8b34aSJoseph KoshyAttach process mode PMCs to the processes named by argument
394fbd8b34aSJoseph Koshy.Ar process-spec .
395fbd8b34aSJoseph KoshyArgument
396fbd8b34aSJoseph Koshy.Ar process-spec
397fbd8b34aSJoseph Koshymay be a non-negative integer denoting a specific process id, or a
398fbd8b34aSJoseph Koshyregular expression for selecting processes based on their command names.
399959826caSMatt Macy.It Fl u Ar event-spec
400959826caSMatt MacyProvide short description of event.
40149874f6eSJoseph Koshy.It Fl v
40249874f6eSJoseph KoshyIncrease verbosity.
403ebccf1e3SJoseph Koshy.It Fl w Ar secs
4040b86b1bbSFabien ThomasPrint the values of all counting mode PMCs or sampling mode PMCs
4050b86b1bbSFabien Thomasfor top mode every
406ebccf1e3SJoseph Koshy.Ar secs
407ebccf1e3SJoseph Koshyseconds.
408ebccf1e3SJoseph KoshyThe argument
409ebccf1e3SJoseph Koshy.Ar secs
410ebccf1e3SJoseph Koshymay be a fractional value.
411ebccf1e3SJoseph KoshyThe default interval is 5 seconds.
412b6010f9eSJoseph Koshy.It Fl z Ar graphdepth
413b6010f9eSJoseph KoshyWhen printing system-wide callgraphs, limit callgraphs to the depth
414b6010f9eSJoseph Koshyspecified by argument
415b6010f9eSJoseph Koshy.Ar graphdepth .
416ebccf1e3SJoseph Koshy.El
417ebccf1e3SJoseph Koshy.Pp
418ebccf1e3SJoseph KoshyIf
419ebccf1e3SJoseph Koshy.Ar command
420ebccf1e3SJoseph Koshyis specified, it is executed using
421ebccf1e3SJoseph Koshy.Xr execvp 3 .
422ebccf1e3SJoseph Koshy.Sh EXAMPLES
423ebccf1e3SJoseph KoshyTo perform system-wide statistical sampling on an AMD Athlon CPU with
424ebccf1e3SJoseph Koshysamples taken every 32768 instruction retirals and data being sampled
425ebccf1e3SJoseph Koshyto file
42621ce09caSJoseph Koshy.Pa sample.stat ,
427ebccf1e3SJoseph Koshyuse:
42800028966SRobert Watson.Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions"
429ebccf1e3SJoseph Koshy.Pp
430ebccf1e3SJoseph KoshyTo execute
431a2c0b3aeSJoseph Koshy.Nm firefox
432ebccf1e3SJoseph Koshyand measure the number of data cache misses suffered
433ebccf1e3SJoseph Koshyby it and its children every 12 seconds on an AMD Athlon, use:
434a2c0b3aeSJoseph Koshy.Dl "pmcstat -d -w 12 -p k7-dc-misses firefox"
4351fdbf256SJoseph Koshy.Pp
4362c79db51SJoseph KoshyTo measure instructions retired for all processes named
437fbd8b34aSJoseph Koshy.Dq emacs
438fbd8b34aSJoseph Koshyuse:
439fbd8b34aSJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions"
440fbd8b34aSJoseph Koshy.Pp
4412c79db51SJoseph KoshyTo measure instructions retired for processes named
4422c79db51SJoseph Koshy.Dq emacs
4432c79db51SJoseph Koshyfor a period of 10 seconds use:
4442c79db51SJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions sleep 10"
4452c79db51SJoseph Koshy.Pp
446ee4910b1SJoseph KoshyTo count instruction tlb-misses on CPUs 0 and 2 on a Intel
447ee4910b1SJoseph KoshyPentium Pro/Pentium III SMP system use:
448ee4910b1SJoseph Koshy.Dl "pmcstat -c 0,2 -s p6-itlb-miss"
449ee4910b1SJoseph Koshy.Pp
450b6010f9eSJoseph KoshyTo collect profiling information for a specific process with pid 1234
451b6010f9eSJoseph Koshybased on instruction cache misses seen by it use:
452b6010f9eSJoseph Koshy.Dl "pmcstat -P ic-misses -t 1234 -O /tmp/sample.out"
453b6010f9eSJoseph Koshy.Pp
454ee4910b1SJoseph KoshyTo perform system-wide sampling on all configured processors
455ee4910b1SJoseph Koshybased on processor instructions retired use:
4561fdbf256SJoseph Koshy.Dl "pmcstat -S instructions -O /tmp/sample.out"
457b6010f9eSJoseph KoshyIf callgraph capture is not desired use:
458b6010f9eSJoseph Koshy.Dl "pmcstat -N -S instructions -O /tmp/sample.out"
4591fdbf256SJoseph Koshy.Pp
460302cbb90SJoseph KoshyTo send the generated event log to a remote machine use:
461302cbb90SJoseph Koshy.Dl "pmcstat -S instructions -O remotehost:port"
462302cbb90SJoseph KoshyOn the remote machine, the sample log can be collected using
463302cbb90SJoseph Koshy.Xr nc 1 :
464302cbb90SJoseph Koshy.Dl "nc -l remotehost port > /tmp/sample.out"
465302cbb90SJoseph Koshy.Pp
4661fdbf256SJoseph KoshyTo generate
4671fdbf256SJoseph Koshy.Xr gprof 1
468b6010f9eSJoseph Koshycompatible profiles from a sample file use:
4691fdbf256SJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -g"
470b6010f9eSJoseph Koshy.Pp
471b6010f9eSJoseph KoshyTo print a system-wide profile with callgraphs to file
472b6010f9eSJoseph Koshy.Pa "foo.graph"
473b6010f9eSJoseph Koshyuse:
474b6010f9eSJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -G foo.graph"
475ebccf1e3SJoseph Koshy.Sh DIAGNOSTICS
476e572c7a7SJoseph KoshyIf option
477e572c7a7SJoseph Koshy.Fl v
478e572c7a7SJoseph Koshyis specified,
479e572c7a7SJoseph Koshy.Nm
480e572c7a7SJoseph Koshymay issue the following diagnostic messages:
48146355096SJoel Dahl.Bl -diag
482e572c7a7SJoseph Koshy.It "#callchain/dubious-frames"
483e572c7a7SJoseph KoshyThe number of callchain records that had an
484e572c7a7SJoseph Koshy.Dq impossible
485e572c7a7SJoseph Koshyvalue for a return address.
486e572c7a7SJoseph Koshy.It "#exec handling errors"
487e572c7a7SJoseph KoshyThe number of
488e572c7a7SJoseph Koshy.Xr exec 2
489e572c7a7SJoseph Koshyevents in the log file that named executables that could not be
490e572c7a7SJoseph Koshyanalyzed.
491e572c7a7SJoseph Koshy.It "#exec/elf"
492e572c7a7SJoseph KoshyThe number of
493e572c7a7SJoseph Koshy.Xr exec 2
494e572c7a7SJoseph Koshyevents that named ELF executables.
495e572c7a7SJoseph Koshy.It "#exec/unknown"
496e572c7a7SJoseph KoshyThe number of
497e572c7a7SJoseph Koshy.Xr exec 2
498e572c7a7SJoseph Koshyevents that named executables with unrecognized formats.
499e572c7a7SJoseph Koshy.It "#samples/total"
500e572c7a7SJoseph KoshyThe total number of samples in the log file.
501e572c7a7SJoseph Koshy.It "#samples/unclaimed"
502e572c7a7SJoseph KoshyThe number of samples that could not be correlated to a known
503e572c7a7SJoseph Koshyexecutable object (i.e., to an executable, shared library, the
504e572c7a7SJoseph Koshykernel or the runtime loader).
505e572c7a7SJoseph Koshy.It "#samples/unknown-object"
506e572c7a7SJoseph KoshyThe number of samples that were associated with an executable
507e572c7a7SJoseph Koshywith an unrecognized object format.
508e572c7a7SJoseph Koshy.El
509e572c7a7SJoseph Koshy.Pp
51021ce09caSJoseph Koshy.Ex -std
511b6010f9eSJoseph Koshy.Sh COMPATIBILITY
512b6010f9eSJoseph KoshyDue to the limitations of the
513b6010f9eSJoseph Koshy.Pa gmon.out
514b6010f9eSJoseph Koshyfile format,
515b6010f9eSJoseph Koshy.Xr gprof 1
516b6010f9eSJoseph Koshycompatible profiles generated by the
517b6010f9eSJoseph Koshy.Fl g
518b6010f9eSJoseph Koshyoption do not contain information about calls that cross executable
519b6010f9eSJoseph Koshyboundaries.
520b6010f9eSJoseph KoshyThe generated
521b6010f9eSJoseph Koshy.Pa gmon.out
522b6010f9eSJoseph Koshyfiles are also only meaningful for native executables.
523ebccf1e3SJoseph Koshy.Sh SEE ALSO
524f263522aSJoseph Koshy.Xr gprof 1 ,
525302cbb90SJoseph Koshy.Xr nc 1 ,
526ebccf1e3SJoseph Koshy.Xr execvp 3 ,
527ebccf1e3SJoseph Koshy.Xr pmc 3 ,
52821ce09caSJoseph Koshy.Xr pmclog 3 ,
529ebccf1e3SJoseph Koshy.Xr hwpmc 4 ,
530ebccf1e3SJoseph Koshy.Xr pmccontrol 8 ,
531ebccf1e3SJoseph Koshy.Xr sysctl 8
53221ce09caSJoseph Koshy.Sh HISTORY
53321ce09caSJoseph KoshyThe
53421ce09caSJoseph Koshy.Nm
53521ce09caSJoseph Koshyutility first appeared in
53621ce09caSJoseph Koshy.Fx 6.0 .
53721ce09caSJoseph Koshy.Sh AUTHORS
53801c2b8acSBaptiste Daroussin.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org
5399f8adcefSJoseph Koshy.Sh BUGS
540bc84aa4bSRuslan ErmilovThe
5419f8adcefSJoseph Koshy.Nm
542bc84aa4bSRuslan Ermilovutility cannot yet analyse
543302cbb90SJoseph Koshy.Xr hwpmc 4
544302cbb90SJoseph Koshylogs generated by non-native architectures.
545