xref: /freebsd/usr.sbin/pmcstat/pmcstat.8 (revision 5de96e33d68b091cd1c8d682799606e2a3d8f6fa)
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.\"
28e22ee9b2SSean Bruno.Dd May 25, 2018
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
36ebccf1e3SJoseph Koshy.Op Fl C
3715139246SJoseph Koshy.Op Fl D Ar pathname
38f263522aSJoseph Koshy.Op Fl E
390b86b1bbSFabien Thomas.Op Fl F Ar pathname
40b6010f9eSJoseph Koshy.Op Fl G Ar pathname
41e22ee9b2SSean Bruno.Op Fl I
42959826caSMatt Macy.Op Fl L
4349874f6eSJoseph Koshy.Op Fl M Ar mapfilename
44b6010f9eSJoseph Koshy.Op Fl N
45ebccf1e3SJoseph Koshy.Op Fl O Ar logfilename
46ebccf1e3SJoseph Koshy.Op Fl P Ar event-spec
47f263522aSJoseph Koshy.Op Fl R Ar logfilename
48ebccf1e3SJoseph Koshy.Op Fl S Ar event-spec
490b86b1bbSFabien Thomas.Op Fl T
50*5de96e33SMatt Macy.Op Fl U
51f263522aSJoseph Koshy.Op Fl W
52f6f851a3SScott Long.Op Fl a Ar pathname
53ee4910b1SJoseph Koshy.Op Fl c Ar cpu-spec
54ebccf1e3SJoseph Koshy.Op Fl d
55465dadb5SJonathan T. Looney.Op Fl e
560b86b1bbSFabien Thomas.Op Fl f Ar pluginopt
57f263522aSJoseph Koshy.Op Fl g
58959826caSMatt Macy.Op Fl i Ar lwp
5949874f6eSJoseph Koshy.Op Fl k Ar kerneldir
6072fe532cSGeorge V. Neville-Neil.Op Fl l Ar secs
61c0252222SAttilio Rao.Op Fl m Ar pathname
6221ce09caSJoseph Koshy.Op Fl n Ar rate
63ebccf1e3SJoseph Koshy.Op Fl o Ar outputfile
64ebccf1e3SJoseph Koshy.Op Fl p Ar event-spec
6549874f6eSJoseph Koshy.Op Fl q
6649874f6eSJoseph Koshy.Op Fl r Ar fsroot
67ebccf1e3SJoseph Koshy.Op Fl s Ar event-spec
68fbd8b34aSJoseph Koshy.Op Fl t Ar process-spec
69959826caSMatt Macy.Op Fl u Ar event-spec
7049874f6eSJoseph Koshy.Op Fl v
7121ce09caSJoseph Koshy.Op Fl w Ar secs
72b6010f9eSJoseph Koshy.Op Fl z Ar graphdepth
7321ce09caSJoseph Koshy.Op Ar command Op Ar args
74ebccf1e3SJoseph Koshy.Sh DESCRIPTION
75ebccf1e3SJoseph KoshyThe
76ebccf1e3SJoseph Koshy.Nm
77ebccf1e3SJoseph Koshyutility measures system performance using the facilities provided by
78ebccf1e3SJoseph Koshy.Xr hwpmc 4 .
79ebccf1e3SJoseph Koshy.Pp
80ebccf1e3SJoseph KoshyThe
81ebccf1e3SJoseph Koshy.Nm
82ebccf1e3SJoseph Koshyutility can measure both hardware events seen by the system as a
83fbd8b34aSJoseph Koshywhole, and those seen when a specified set of processes are executing
84fbd8b34aSJoseph Koshyon the system's CPUs.
85fbd8b34aSJoseph KoshyIf a specific set of processes is being targeted (for example,
86ebccf1e3SJoseph Koshyif the
87fbd8b34aSJoseph Koshy.Fl t Ar process-spec
88ebccf1e3SJoseph Koshyoption is specified, or if a command line is specified using
89ebccf1e3SJoseph Koshy.Ar command ) ,
90fbd8b34aSJoseph Koshythen measurement occurs till
91fbd8b34aSJoseph Koshy.Ar command
92fbd8b34aSJoseph Koshyexits, or till all target processes specified by the
93fbd8b34aSJoseph Koshy.Fl t Ar process-spec
94fbd8b34aSJoseph Koshyoptions exit, or till the
95ebccf1e3SJoseph Koshy.Nm
96ebccf1e3SJoseph Koshyutility is interrupted by the user.
97fbd8b34aSJoseph KoshyIf a specific set of processes is not targeted for measurement, then
98ebccf1e3SJoseph Koshy.Nm
99ebccf1e3SJoseph Koshywill perform system-wide measurements till interrupted by the
100ebccf1e3SJoseph Koshyuser.
101ebccf1e3SJoseph Koshy.Pp
102ebccf1e3SJoseph KoshyA given invocation of
103ebccf1e3SJoseph Koshy.Nm
104ebccf1e3SJoseph Koshycan mix allocations of system-mode and process-mode PMCs, of both
105ebccf1e3SJoseph Koshycounting and sampling flavors.
106ebccf1e3SJoseph KoshyThe values of all counting PMCs are printed in human readable form
107ebccf1e3SJoseph Koshyat regular intervals by
108ebccf1e3SJoseph Koshy.Nm .
109f263522aSJoseph KoshyThe output of sampling PMCs may be configured to go to a log file for
110f263522aSJoseph Koshysubsequent offline analysis, or, at the expense of greater
11121ce09caSJoseph Koshyoverhead, may be configured to be printed in text form on the fly.
112ebccf1e3SJoseph Koshy.Pp
113ebccf1e3SJoseph KoshyHardware events to measure are specified to
114ebccf1e3SJoseph Koshy.Nm
115ebccf1e3SJoseph Koshyusing event specifier strings
116ebccf1e3SJoseph Koshy.Ar event-spec .
117ebccf1e3SJoseph KoshyThe syntax of these event specifiers is machine dependent and is
118ebccf1e3SJoseph Koshydocumented in
119ebccf1e3SJoseph Koshy.Xr pmc 3 .
120ebccf1e3SJoseph Koshy.Pp
121ebccf1e3SJoseph KoshyA process-mode PMC may be configured to be inheritable by the target
122ebccf1e3SJoseph Koshyprocess' current and future children.
123ebccf1e3SJoseph Koshy.Sh OPTIONS
124ebccf1e3SJoseph KoshyThe following options are available:
125ebccf1e3SJoseph Koshy.Bl -tag -width indent
126ebccf1e3SJoseph Koshy.It Fl C
127f263522aSJoseph KoshyToggle between showing cumulative or incremental counts for
128ebccf1e3SJoseph Koshysubsequent counting mode PMCs specified on the command line.
129ebccf1e3SJoseph KoshyThe default is to show incremental counts.
130f263522aSJoseph Koshy.It Fl D Ar pathname
131f263522aSJoseph KoshyCreate files with per-program samples in the directory named
132f263522aSJoseph Koshyby
133f263522aSJoseph Koshy.Ar pathname .
134f263522aSJoseph KoshyThe default is to create these files in the current directory.
135f263522aSJoseph Koshy.It Fl E
136f263522aSJoseph KoshyToggle showing per-process counts at the time a tracked process
137f263522aSJoseph Koshyexits for subsequent process-mode PMCs specified on the command line.
138f263522aSJoseph KoshyThis option is useful for mapping the performance characteristics of a
139f263522aSJoseph Koshycomplex pipeline of processes when used in conjunction with the
140f263522aSJoseph Koshy.Fl d
141f263522aSJoseph Koshyoption.
142f263522aSJoseph KoshyThe default is to not to enable per-process tracking.
1430b86b1bbSFabien Thomas.It Fl F Ar pathname
1440b86b1bbSFabien ThomasPrint calltree (Kcachegrind) information to file
1450b86b1bbSFabien Thomas.Ar pathname .
1460b86b1bbSFabien ThomasIf argument
1470b86b1bbSFabien Thomas.Ar pathname
1480b86b1bbSFabien Thomasis a
1490b86b1bbSFabien Thomas.Dq Li -
1500b86b1bbSFabien Thomasthis information is sent to the output file specified by the
1510b86b1bbSFabien Thomas.Fl o
1520b86b1bbSFabien Thomasoption.
153b6010f9eSJoseph Koshy.It Fl G Ar pathname
154b6010f9eSJoseph KoshyPrint callchain information to file
155b6010f9eSJoseph Koshy.Ar pathname .
156b6010f9eSJoseph KoshyIf argument
157b6010f9eSJoseph Koshy.Ar pathname
158b6010f9eSJoseph Koshyis a
159b6010f9eSJoseph Koshy.Dq Li -
160b6010f9eSJoseph Koshythis information is sent to the output file specified by the
161b6010f9eSJoseph Koshy.Fl o
162b6010f9eSJoseph Koshyoption.
163e22ee9b2SSean Bruno.It Fl I
164e22ee9b2SSean BrunoSkip symbol lookup and display address instead.
165959826caSMatt Macy.It Fl L
166959826caSMatt MacyList all event names.
16749874f6eSJoseph Koshy.It Fl M Ar mapfilename
16849874f6eSJoseph KoshyWrite the mapping between executable objects encountered in the event
16949874f6eSJoseph Koshylog and the abbreviated pathnames used for
17049874f6eSJoseph Koshy.Xr gprof 1
17149874f6eSJoseph Koshyprofiles to file
17249874f6eSJoseph Koshy.Ar mapfilename .
17349874f6eSJoseph KoshyIf this option is not specified, mapping information is not written.
17449874f6eSJoseph KoshyArgument
17549874f6eSJoseph Koshy.Ar mapfilename
17649874f6eSJoseph Koshymay be a
17749874f6eSJoseph Koshy.Dq Li -
17849874f6eSJoseph Koshyin which case this mapping information is sent to the output
17949874f6eSJoseph Koshyfile configured by the
18049874f6eSJoseph Koshy.Fl o
18149874f6eSJoseph Koshyoption.
182b6010f9eSJoseph Koshy.It Fl N
183b6010f9eSJoseph KoshyToggle capturing callchain information for subsequent sampling PMCs.
184b6010f9eSJoseph KoshyThe default is for sampling PMCs to capture callchain information.
185ebccf1e3SJoseph Koshy.It Fl O Ar logfilename
18621ce09caSJoseph KoshySend logging output to file
187ebccf1e3SJoseph Koshy.Ar logfilename .
188302cbb90SJoseph KoshyIf
189302cbb90SJoseph Koshy.Ar logfilename
190302cbb90SJoseph Koshyis of the form
191302cbb90SJoseph Koshy.Ar hostname Ns : Ns Ar port ,
192302cbb90SJoseph Koshywhere
193302cbb90SJoseph Koshy.Ar hostname
194302cbb90SJoseph Koshydoes not start with a
195bc84aa4bSRuslan Ermilov.Ql \&.
196302cbb90SJoseph Koshyor a
197bc84aa4bSRuslan Ermilov.Ql / ,
198302cbb90SJoseph Koshythen
199302cbb90SJoseph Koshy.Nm
200302cbb90SJoseph Koshywill open a network socket to host
201302cbb90SJoseph Koshy.Ar hostname
202302cbb90SJoseph Koshyon port
203302cbb90SJoseph Koshy.Ar port .
204302cbb90SJoseph Koshy.Pp
205302cbb90SJoseph KoshyIf the
206302cbb90SJoseph Koshy.Fl O
207302cbb90SJoseph Koshyoption is not specified and one of the logging options is requested,
208302cbb90SJoseph Koshythen
209f263522aSJoseph Koshy.Nm
21021ce09caSJoseph Koshywill print a textual form of the logged events to the configured
211f263522aSJoseph Koshyoutput file.
212ebccf1e3SJoseph Koshy.It Fl P Ar event-spec
213ebccf1e3SJoseph KoshyAllocate a process mode sampling PMC measuring hardware events
214ebccf1e3SJoseph Koshyspecified in
215ebccf1e3SJoseph Koshy.Ar event-spec .
216f263522aSJoseph Koshy.It Fl R Ar logfilename
217f263522aSJoseph KoshyPerform offline analysis using sampling data in file
218f263522aSJoseph Koshy.Ar logfilename .
219ebccf1e3SJoseph Koshy.It Fl S Ar event-spec
220ebccf1e3SJoseph KoshyAllocate a system mode sampling PMC measuring hardware events
221ebccf1e3SJoseph Koshyspecified in
222ebccf1e3SJoseph Koshy.Ar event-spec .
2230b86b1bbSFabien Thomas.It Fl T
2240b86b1bbSFabien ThomasUse a top like mode for sampling PMCs. The following hotkeys
2250b86b1bbSFabien Thomascan be used: 'c+a' switch to accumulative mode, 'c+d' switch
2260b86b1bbSFabien Thomasto delta mode, 'm' merge PMCs, 'n' change view, 'p' show next
2270b86b1bbSFabien ThomasPMC, ' ' pause, 'q' quit. calltree only: 'f' cost under threshold
2280b86b1bbSFabien Thomasis seen as a dot.
229*5de96e33SMatt Macy.It Fl U
230*5de96e33SMatt MacyToggle capturing user-space call traces while in kernel mode.
231*5de96e33SMatt MacyThe default is for sampling PMCs to capture user-space callchain information
232*5de96e33SMatt Macywhile in user-space mode, and kernel callchain information while in kernel mode.
233f263522aSJoseph Koshy.It Fl W
234f263522aSJoseph KoshyToggle logging the incremental counts seen by the threads of a
235f263522aSJoseph Koshytracked process each time they are scheduled on a CPU.
236f263522aSJoseph KoshyThis is an experimental feature intended to help analyse the
237f263522aSJoseph Koshydynamic behaviour of processes in the system.
238f263522aSJoseph KoshyIt may incur substantial overhead if enabled.
239f263522aSJoseph KoshyThe default is for this feature to be disabled.
240f6f851a3SScott Long.It Fl a Ar pathname
241f6f851a3SScott LongPerform a symbol and file:line lookup for each address in each
242f6f851a3SScott Longcallgraph and save the output to
243f6f851a3SScott Long.Ar pathname .
244f6f851a3SScott LongUnlike
245f6f851a3SScott Long.Fl m
246f6f851a3SScott Longthat only resolves the first symbol in the graph, this resolves
247f6f851a3SScott Longevery node in the callgraph, or prints out addresses if no
248f6f851a3SScott Longlookup information is available.
249f6f851a3SScott LongThis option requires the
250f6f851a3SScott Long.Fl R
251f6f851a3SScott Longoption to read in samples that were previously collected and
252f6f851a3SScott Longsaved with the
25310813ab3SEric van Gyzen.Fl O
254f6f851a3SScott Longoption.
255ee4910b1SJoseph Koshy.It Fl c Ar cpu-spec
256ee4910b1SJoseph KoshySet the cpus for subsequent system mode PMCs specified on the
257ebccf1e3SJoseph Koshycommand line to
258ee4910b1SJoseph Koshy.Ar cpu-spec .
259ee4910b1SJoseph KoshyArgument
260ee4910b1SJoseph Koshy.Ar cpu-spec
261ee4910b1SJoseph Koshyis a comma separated list of CPU numbers, or the literal
262ee4910b1SJoseph Koshy.Sq *
263ef16b9abSJohn Baldwindenoting all available CPUs.
264ef16b9abSJohn BaldwinThe default is to allocate system mode PMCs on all available
2655477328dSJoseph KoshyCPUs.
266ebccf1e3SJoseph Koshy.It Fl d
267ebccf1e3SJoseph KoshyToggle between process mode PMCs measuring events for the target
268ebccf1e3SJoseph Koshyprocess' current and future children or only measuring events for
269f263522aSJoseph Koshythe target process.
270ebccf1e3SJoseph KoshyThe default is to measure events for the target process alone.
27199e33eabSBaptiste Daroussin(it has to be passed in the command line prior to
27299e33eabSBaptiste Daroussin.Fl p ,
27399e33eabSBaptiste Daroussin.Fl s ,
27499e33eabSBaptiste Daroussin.Fl P ,
27599e33eabSBaptiste Daroussinor
276f42d8decSBaptiste Daroussin.Fl S ) .
277465dadb5SJonathan T. Looney.It Fl e
278465dadb5SJonathan T. LooneySpecify that the gprof profile files will use a wide history counter.
279465dadb5SJonathan T. LooneyThese files are produced in a format compatible with
280465dadb5SJonathan T. Looney.Xr gprof 1 .
281465dadb5SJonathan T. LooneyHowever, other tools that cannot fully parse a BSD-style
282465dadb5SJonathan T. Looneygmon header might be unable to correctly parse these files.
2830b86b1bbSFabien Thomas.It Fl f Ar pluginopt
2840b86b1bbSFabien ThomasPass option string to the active plugin.
2850b86b1bbSFabien Thomas.br
2860b86b1bbSFabien Thomasthreshold=<float> do not display cost under specified value (Top).
2870b86b1bbSFabien Thomas.br
2880b86b1bbSFabien Thomasskiplink=0|1 replace node with cost under threshold by a dot (Top).
289f263522aSJoseph Koshy.It Fl g
290b6010f9eSJoseph KoshyProduce profiles in a format compatible with
291f263522aSJoseph Koshy.Xr gprof 1 .
2921fdbf256SJoseph KoshyA separate profile file is generated for each executable object
2931fdbf256SJoseph Koshyencountered.
2941fdbf256SJoseph KoshyProfile files are placed in sub-directories named by their PMC
2951fdbf256SJoseph Koshyevent name.
296959826caSMatt Macy.It Fl i Ar lwp
297959826caSMatt MacyFilter on thread ID
298959826caSMatt Macy.Ar lwp ,
299959826caSMatt Macywhich you can get from
300959826caSMatt Macy.Xr ps 1
301959826caSMatt Macy.Fl o
302959826caSMatt Macy.Li lwp .
30349874f6eSJoseph Koshy.It Fl k Ar kerneldir
30449874f6eSJoseph KoshySet the pathname of the kernel directory to argument
30549874f6eSJoseph Koshy.Ar kerneldir .
30649874f6eSJoseph KoshyThis directory specifies where
30749874f6eSJoseph Koshy.Nm
30849874f6eSJoseph Koshyshould look for the kernel and its modules.
30938fd3834SJohn BaldwinThe default is to use the path of the running kernel obtained from the
31038fd3834SJohn Baldwin.Va kern.bootfile
31138fd3834SJohn Baldwinsysctl.
31272fe532cSGeorge V. Neville-Neil.It Fl l Ar secs
31372fe532cSGeorge V. Neville-NeilSet system-wide performance measurement duration for
31472fe532cSGeorge V. Neville-Neil.Ar secs
31572fe532cSGeorge V. Neville-Neilseconds.
31672fe532cSGeorge V. Neville-NeilThe argument
31772fe532cSGeorge V. Neville-Neil.Ar secs
31872fe532cSGeorge V. Neville-Neilmay be a fractional value.
319c0252222SAttilio Rao.It Fl m Ar pathname
320c0252222SAttilio RaoPrint the sampled PCs with the name, the start and ending addresses
321c0252222SAttilio Raoof the function within they live.
322c0252222SAttilio RaoThe
323c0252222SAttilio Rao.Ar pathname
3248972c8b6SJoel Dahlargument is mandatory and indicates where the information will be stored.
325c0252222SAttilio RaoIf argument
326c0252222SAttilio Rao.Ar pathname
327c0252222SAttilio Raois a
328c0252222SAttilio Rao.Dq Li -
329c0252222SAttilio Raothis information is sent to the output file specified by the
330c0252222SAttilio Rao.Fl o
331c0252222SAttilio Raooption.
33210813ab3SEric van GyzenThis option requires the
33310813ab3SEric van Gyzen.Fl R
33410813ab3SEric van Gyzenoption to read in samples that were previously collected and
33510813ab3SEric van Gyzensaved with the
33610813ab3SEric van Gyzen.Fl O
33710813ab3SEric van Gyzenoption.
338ebccf1e3SJoseph Koshy.It Fl n Ar rate
339ebccf1e3SJoseph KoshySet the default sampling rate for subsequent sampling mode
340ebccf1e3SJoseph KoshyPMCs specified on the command line.
341ebccf1e3SJoseph KoshyThe default is to configure PMCs to sample the CPU's instruction
342ebccf1e3SJoseph Koshypointer every 65536 events.
343ebccf1e3SJoseph Koshy.It Fl o Ar outputfile
34421ce09caSJoseph KoshySend counter readings and textual representations of logged data
345ebccf1e3SJoseph Koshyto file
346ebccf1e3SJoseph Koshy.Ar outputfile .
347ebccf1e3SJoseph KoshyThe default is to send output to
348b6010f9eSJoseph Koshy.Pa stderr
349b6010f9eSJoseph Koshywhen collecting live data and to
350b6010f9eSJoseph Koshy.Pa stdout
351b6010f9eSJoseph Koshywhen processing a pre-existing logfile.
352ebccf1e3SJoseph Koshy.It Fl p Ar event-spec
353ebccf1e3SJoseph KoshyAllocate a process mode counting PMC measuring hardware events
354ebccf1e3SJoseph Koshyspecified in
355ebccf1e3SJoseph Koshy.Ar event-spec .
35649874f6eSJoseph Koshy.It Fl q
35749874f6eSJoseph KoshyDecrease verbosity.
35849874f6eSJoseph Koshy.It Fl r Ar fsroot
35949874f6eSJoseph KoshySet the top of the filesystem hierarchy under which executables
36049874f6eSJoseph Koshyare located to argument
36149874f6eSJoseph Koshy.Ar fsroot .
36249874f6eSJoseph KoshyThe default is
36349874f6eSJoseph Koshy.Pa / .
364ebccf1e3SJoseph Koshy.It Fl s Ar event-spec
365ebccf1e3SJoseph KoshyAllocate a system mode counting PMC measuring hardware events
366ebccf1e3SJoseph Koshyspecified in
367ebccf1e3SJoseph Koshy.Ar event-spec .
368fbd8b34aSJoseph Koshy.It Fl t Ar process-spec
369fbd8b34aSJoseph KoshyAttach process mode PMCs to the processes named by argument
370fbd8b34aSJoseph Koshy.Ar process-spec .
371fbd8b34aSJoseph KoshyArgument
372fbd8b34aSJoseph Koshy.Ar process-spec
373fbd8b34aSJoseph Koshymay be a non-negative integer denoting a specific process id, or a
374fbd8b34aSJoseph Koshyregular expression for selecting processes based on their command names.
375959826caSMatt Macy.It Fl u Ar event-spec
376959826caSMatt MacyProvide short description of event.
37749874f6eSJoseph Koshy.It Fl v
37849874f6eSJoseph KoshyIncrease verbosity.
379ebccf1e3SJoseph Koshy.It Fl w Ar secs
3800b86b1bbSFabien ThomasPrint the values of all counting mode PMCs or sampling mode PMCs
3810b86b1bbSFabien Thomasfor top mode every
382ebccf1e3SJoseph Koshy.Ar secs
383ebccf1e3SJoseph Koshyseconds.
384ebccf1e3SJoseph KoshyThe argument
385ebccf1e3SJoseph Koshy.Ar secs
386ebccf1e3SJoseph Koshymay be a fractional value.
387ebccf1e3SJoseph KoshyThe default interval is 5 seconds.
388b6010f9eSJoseph Koshy.It Fl z Ar graphdepth
389b6010f9eSJoseph KoshyWhen printing system-wide callgraphs, limit callgraphs to the depth
390b6010f9eSJoseph Koshyspecified by argument
391b6010f9eSJoseph Koshy.Ar graphdepth .
392ebccf1e3SJoseph Koshy.El
393ebccf1e3SJoseph Koshy.Pp
394ebccf1e3SJoseph KoshyIf
395ebccf1e3SJoseph Koshy.Ar command
396ebccf1e3SJoseph Koshyis specified, it is executed using
397ebccf1e3SJoseph Koshy.Xr execvp 3 .
398ebccf1e3SJoseph Koshy.Sh EXAMPLES
399ebccf1e3SJoseph KoshyTo perform system-wide statistical sampling on an AMD Athlon CPU with
400ebccf1e3SJoseph Koshysamples taken every 32768 instruction retirals and data being sampled
401ebccf1e3SJoseph Koshyto file
40221ce09caSJoseph Koshy.Pa sample.stat ,
403ebccf1e3SJoseph Koshyuse:
40400028966SRobert Watson.Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions"
405ebccf1e3SJoseph Koshy.Pp
406ebccf1e3SJoseph KoshyTo execute
407a2c0b3aeSJoseph Koshy.Nm firefox
408ebccf1e3SJoseph Koshyand measure the number of data cache misses suffered
409ebccf1e3SJoseph Koshyby it and its children every 12 seconds on an AMD Athlon, use:
410a2c0b3aeSJoseph Koshy.Dl "pmcstat -d -w 12 -p k7-dc-misses firefox"
4111fdbf256SJoseph Koshy.Pp
4122c79db51SJoseph KoshyTo measure instructions retired for all processes named
413fbd8b34aSJoseph Koshy.Dq emacs
414fbd8b34aSJoseph Koshyuse:
415fbd8b34aSJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions"
416fbd8b34aSJoseph Koshy.Pp
4172c79db51SJoseph KoshyTo measure instructions retired for processes named
4182c79db51SJoseph Koshy.Dq emacs
4192c79db51SJoseph Koshyfor a period of 10 seconds use:
4202c79db51SJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions sleep 10"
4212c79db51SJoseph Koshy.Pp
422ee4910b1SJoseph KoshyTo count instruction tlb-misses on CPUs 0 and 2 on a Intel
423ee4910b1SJoseph KoshyPentium Pro/Pentium III SMP system use:
424ee4910b1SJoseph Koshy.Dl "pmcstat -c 0,2 -s p6-itlb-miss"
425ee4910b1SJoseph Koshy.Pp
426b6010f9eSJoseph KoshyTo collect profiling information for a specific process with pid 1234
427b6010f9eSJoseph Koshybased on instruction cache misses seen by it use:
428b6010f9eSJoseph Koshy.Dl "pmcstat -P ic-misses -t 1234 -O /tmp/sample.out"
429b6010f9eSJoseph Koshy.Pp
430ee4910b1SJoseph KoshyTo perform system-wide sampling on all configured processors
431ee4910b1SJoseph Koshybased on processor instructions retired use:
4321fdbf256SJoseph Koshy.Dl "pmcstat -S instructions -O /tmp/sample.out"
433b6010f9eSJoseph KoshyIf callgraph capture is not desired use:
434b6010f9eSJoseph Koshy.Dl "pmcstat -N -S instructions -O /tmp/sample.out"
4351fdbf256SJoseph Koshy.Pp
436302cbb90SJoseph KoshyTo send the generated event log to a remote machine use:
437302cbb90SJoseph Koshy.Dl "pmcstat -S instructions -O remotehost:port"
438302cbb90SJoseph KoshyOn the remote machine, the sample log can be collected using
439302cbb90SJoseph Koshy.Xr nc 1 :
440302cbb90SJoseph Koshy.Dl "nc -l remotehost port > /tmp/sample.out"
441302cbb90SJoseph Koshy.Pp
4421fdbf256SJoseph KoshyTo generate
4431fdbf256SJoseph Koshy.Xr gprof 1
444b6010f9eSJoseph Koshycompatible profiles from a sample file use:
4451fdbf256SJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -g"
446b6010f9eSJoseph Koshy.Pp
447b6010f9eSJoseph KoshyTo print a system-wide profile with callgraphs to file
448b6010f9eSJoseph Koshy.Pa "foo.graph"
449b6010f9eSJoseph Koshyuse:
450b6010f9eSJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -G foo.graph"
451ebccf1e3SJoseph Koshy.Sh DIAGNOSTICS
452e572c7a7SJoseph KoshyIf option
453e572c7a7SJoseph Koshy.Fl v
454e572c7a7SJoseph Koshyis specified,
455e572c7a7SJoseph Koshy.Nm
456e572c7a7SJoseph Koshymay issue the following diagnostic messages:
45746355096SJoel Dahl.Bl -diag
458e572c7a7SJoseph Koshy.It "#callchain/dubious-frames"
459e572c7a7SJoseph KoshyThe number of callchain records that had an
460e572c7a7SJoseph Koshy.Dq impossible
461e572c7a7SJoseph Koshyvalue for a return address.
462e572c7a7SJoseph Koshy.It "#exec handling errors"
463e572c7a7SJoseph KoshyThe number of
464e572c7a7SJoseph Koshy.Xr exec 2
465e572c7a7SJoseph Koshyevents in the log file that named executables that could not be
466e572c7a7SJoseph Koshyanalyzed.
467e572c7a7SJoseph Koshy.It "#exec/elf"
468e572c7a7SJoseph KoshyThe number of
469e572c7a7SJoseph Koshy.Xr exec 2
470e572c7a7SJoseph Koshyevents that named ELF executables.
471e572c7a7SJoseph Koshy.It "#exec/unknown"
472e572c7a7SJoseph KoshyThe number of
473e572c7a7SJoseph Koshy.Xr exec 2
474e572c7a7SJoseph Koshyevents that named executables with unrecognized formats.
475e572c7a7SJoseph Koshy.It "#samples/total"
476e572c7a7SJoseph KoshyThe total number of samples in the log file.
477e572c7a7SJoseph Koshy.It "#samples/unclaimed"
478e572c7a7SJoseph KoshyThe number of samples that could not be correlated to a known
479e572c7a7SJoseph Koshyexecutable object (i.e., to an executable, shared library, the
480e572c7a7SJoseph Koshykernel or the runtime loader).
481e572c7a7SJoseph Koshy.It "#samples/unknown-object"
482e572c7a7SJoseph KoshyThe number of samples that were associated with an executable
483e572c7a7SJoseph Koshywith an unrecognized object format.
484e572c7a7SJoseph Koshy.El
485e572c7a7SJoseph Koshy.Pp
48621ce09caSJoseph Koshy.Ex -std
487b6010f9eSJoseph Koshy.Sh COMPATIBILITY
488b6010f9eSJoseph KoshyDue to the limitations of the
489b6010f9eSJoseph Koshy.Pa gmon.out
490b6010f9eSJoseph Koshyfile format,
491b6010f9eSJoseph Koshy.Xr gprof 1
492b6010f9eSJoseph Koshycompatible profiles generated by the
493b6010f9eSJoseph Koshy.Fl g
494b6010f9eSJoseph Koshyoption do not contain information about calls that cross executable
495b6010f9eSJoseph Koshyboundaries.
496b6010f9eSJoseph KoshyThe generated
497b6010f9eSJoseph Koshy.Pa gmon.out
498b6010f9eSJoseph Koshyfiles are also only meaningful for native executables.
499ebccf1e3SJoseph Koshy.Sh SEE ALSO
500f263522aSJoseph Koshy.Xr gprof 1 ,
501302cbb90SJoseph Koshy.Xr nc 1 ,
502ebccf1e3SJoseph Koshy.Xr execvp 3 ,
503ebccf1e3SJoseph Koshy.Xr pmc 3 ,
50421ce09caSJoseph Koshy.Xr pmclog 3 ,
505ebccf1e3SJoseph Koshy.Xr hwpmc 4 ,
506ebccf1e3SJoseph Koshy.Xr pmccontrol 8 ,
507ebccf1e3SJoseph Koshy.Xr sysctl 8
50821ce09caSJoseph Koshy.Sh HISTORY
50921ce09caSJoseph KoshyThe
51021ce09caSJoseph Koshy.Nm
51121ce09caSJoseph Koshyutility first appeared in
51221ce09caSJoseph Koshy.Fx 6.0 .
5131fdbf256SJoseph KoshyIt is
5141fdbf256SJoseph Koshy.Ud
51521ce09caSJoseph Koshy.Sh AUTHORS
51601c2b8acSBaptiste Daroussin.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org
5179f8adcefSJoseph Koshy.Sh BUGS
518bc84aa4bSRuslan ErmilovThe
5199f8adcefSJoseph Koshy.Nm
520bc84aa4bSRuslan Ermilovutility cannot yet analyse
521302cbb90SJoseph Koshy.Xr hwpmc 4
522302cbb90SJoseph Koshylogs generated by non-native architectures.
523