xref: /freebsd/usr.sbin/pmcstat/pmcstat.8 (revision 10813ab3806be47ee4cd59d7992dc4cfd3c3242d)
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*10813ab3SEric van Gyzen.Dd March 27, 2015
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
4149874f6eSJoseph Koshy.Op Fl M Ar mapfilename
42b6010f9eSJoseph Koshy.Op Fl N
43ebccf1e3SJoseph Koshy.Op Fl O Ar logfilename
44ebccf1e3SJoseph Koshy.Op Fl P Ar event-spec
45f263522aSJoseph Koshy.Op Fl R Ar logfilename
46ebccf1e3SJoseph Koshy.Op Fl S Ar event-spec
470b86b1bbSFabien Thomas.Op Fl T
48f263522aSJoseph Koshy.Op Fl W
49f6f851a3SScott Long.Op Fl a Ar pathname
50ee4910b1SJoseph Koshy.Op Fl c Ar cpu-spec
51ebccf1e3SJoseph Koshy.Op Fl d
520b86b1bbSFabien Thomas.Op Fl f Ar pluginopt
53f263522aSJoseph Koshy.Op Fl g
5449874f6eSJoseph Koshy.Op Fl k Ar kerneldir
5572fe532cSGeorge V. Neville-Neil.Op Fl l Ar secs
56c0252222SAttilio Rao.Op Fl m Ar pathname
5721ce09caSJoseph Koshy.Op Fl n Ar rate
58ebccf1e3SJoseph Koshy.Op Fl o Ar outputfile
59ebccf1e3SJoseph Koshy.Op Fl p Ar event-spec
6049874f6eSJoseph Koshy.Op Fl q
6149874f6eSJoseph Koshy.Op Fl r Ar fsroot
62ebccf1e3SJoseph Koshy.Op Fl s Ar event-spec
63fbd8b34aSJoseph Koshy.Op Fl t Ar process-spec
6449874f6eSJoseph Koshy.Op Fl v
6521ce09caSJoseph Koshy.Op Fl w Ar secs
66b6010f9eSJoseph Koshy.Op Fl z Ar graphdepth
6721ce09caSJoseph Koshy.Op Ar command Op Ar args
68ebccf1e3SJoseph Koshy.Sh DESCRIPTION
69ebccf1e3SJoseph KoshyThe
70ebccf1e3SJoseph Koshy.Nm
71ebccf1e3SJoseph Koshyutility measures system performance using the facilities provided by
72ebccf1e3SJoseph Koshy.Xr hwpmc 4 .
73ebccf1e3SJoseph Koshy.Pp
74ebccf1e3SJoseph KoshyThe
75ebccf1e3SJoseph Koshy.Nm
76ebccf1e3SJoseph Koshyutility can measure both hardware events seen by the system as a
77fbd8b34aSJoseph Koshywhole, and those seen when a specified set of processes are executing
78fbd8b34aSJoseph Koshyon the system's CPUs.
79fbd8b34aSJoseph KoshyIf a specific set of processes is being targeted (for example,
80ebccf1e3SJoseph Koshyif the
81fbd8b34aSJoseph Koshy.Fl t Ar process-spec
82ebccf1e3SJoseph Koshyoption is specified, or if a command line is specified using
83ebccf1e3SJoseph Koshy.Ar command ) ,
84fbd8b34aSJoseph Koshythen measurement occurs till
85fbd8b34aSJoseph Koshy.Ar command
86fbd8b34aSJoseph Koshyexits, or till all target processes specified by the
87fbd8b34aSJoseph Koshy.Fl t Ar process-spec
88fbd8b34aSJoseph Koshyoptions exit, or till the
89ebccf1e3SJoseph Koshy.Nm
90ebccf1e3SJoseph Koshyutility is interrupted by the user.
91fbd8b34aSJoseph KoshyIf a specific set of processes is not targeted for measurement, then
92ebccf1e3SJoseph Koshy.Nm
93ebccf1e3SJoseph Koshywill perform system-wide measurements till interrupted by the
94ebccf1e3SJoseph Koshyuser.
95ebccf1e3SJoseph Koshy.Pp
96ebccf1e3SJoseph KoshyA given invocation of
97ebccf1e3SJoseph Koshy.Nm
98ebccf1e3SJoseph Koshycan mix allocations of system-mode and process-mode PMCs, of both
99ebccf1e3SJoseph Koshycounting and sampling flavors.
100ebccf1e3SJoseph KoshyThe values of all counting PMCs are printed in human readable form
101ebccf1e3SJoseph Koshyat regular intervals by
102ebccf1e3SJoseph Koshy.Nm .
103f263522aSJoseph KoshyThe output of sampling PMCs may be configured to go to a log file for
104f263522aSJoseph Koshysubsequent offline analysis, or, at the expense of greater
10521ce09caSJoseph Koshyoverhead, may be configured to be printed in text form on the fly.
106ebccf1e3SJoseph Koshy.Pp
107ebccf1e3SJoseph KoshyHardware events to measure are specified to
108ebccf1e3SJoseph Koshy.Nm
109ebccf1e3SJoseph Koshyusing event specifier strings
110ebccf1e3SJoseph Koshy.Ar event-spec .
111ebccf1e3SJoseph KoshyThe syntax of these event specifiers is machine dependent and is
112ebccf1e3SJoseph Koshydocumented in
113ebccf1e3SJoseph Koshy.Xr pmc 3 .
114ebccf1e3SJoseph Koshy.Pp
115ebccf1e3SJoseph KoshyA process-mode PMC may be configured to be inheritable by the target
116ebccf1e3SJoseph Koshyprocess' current and future children.
117ebccf1e3SJoseph Koshy.Sh OPTIONS
118ebccf1e3SJoseph KoshyThe following options are available:
119ebccf1e3SJoseph Koshy.Bl -tag -width indent
120ebccf1e3SJoseph Koshy.It Fl C
121f263522aSJoseph KoshyToggle between showing cumulative or incremental counts for
122ebccf1e3SJoseph Koshysubsequent counting mode PMCs specified on the command line.
123ebccf1e3SJoseph KoshyThe default is to show incremental counts.
124f263522aSJoseph Koshy.It Fl D Ar pathname
125f263522aSJoseph KoshyCreate files with per-program samples in the directory named
126f263522aSJoseph Koshyby
127f263522aSJoseph Koshy.Ar pathname .
128f263522aSJoseph KoshyThe default is to create these files in the current directory.
129f263522aSJoseph Koshy.It Fl E
130f263522aSJoseph KoshyToggle showing per-process counts at the time a tracked process
131f263522aSJoseph Koshyexits for subsequent process-mode PMCs specified on the command line.
132f263522aSJoseph KoshyThis option is useful for mapping the performance characteristics of a
133f263522aSJoseph Koshycomplex pipeline of processes when used in conjunction with the
134f263522aSJoseph Koshy.Fl d
135f263522aSJoseph Koshyoption.
136f263522aSJoseph KoshyThe default is to not to enable per-process tracking.
1370b86b1bbSFabien Thomas.It Fl F Ar pathname
1380b86b1bbSFabien ThomasPrint calltree (Kcachegrind) information to file
1390b86b1bbSFabien Thomas.Ar pathname .
1400b86b1bbSFabien ThomasIf argument
1410b86b1bbSFabien Thomas.Ar pathname
1420b86b1bbSFabien Thomasis a
1430b86b1bbSFabien Thomas.Dq Li -
1440b86b1bbSFabien Thomasthis information is sent to the output file specified by the
1450b86b1bbSFabien Thomas.Fl o
1460b86b1bbSFabien Thomasoption.
147b6010f9eSJoseph Koshy.It Fl G Ar pathname
148b6010f9eSJoseph KoshyPrint callchain information to file
149b6010f9eSJoseph Koshy.Ar pathname .
150b6010f9eSJoseph KoshyIf argument
151b6010f9eSJoseph Koshy.Ar pathname
152b6010f9eSJoseph Koshyis a
153b6010f9eSJoseph Koshy.Dq Li -
154b6010f9eSJoseph Koshythis information is sent to the output file specified by the
155b6010f9eSJoseph Koshy.Fl o
156b6010f9eSJoseph Koshyoption.
15749874f6eSJoseph Koshy.It Fl M Ar mapfilename
15849874f6eSJoseph KoshyWrite the mapping between executable objects encountered in the event
15949874f6eSJoseph Koshylog and the abbreviated pathnames used for
16049874f6eSJoseph Koshy.Xr gprof 1
16149874f6eSJoseph Koshyprofiles to file
16249874f6eSJoseph Koshy.Ar mapfilename .
16349874f6eSJoseph KoshyIf this option is not specified, mapping information is not written.
16449874f6eSJoseph KoshyArgument
16549874f6eSJoseph Koshy.Ar mapfilename
16649874f6eSJoseph Koshymay be a
16749874f6eSJoseph Koshy.Dq Li -
16849874f6eSJoseph Koshyin which case this mapping information is sent to the output
16949874f6eSJoseph Koshyfile configured by the
17049874f6eSJoseph Koshy.Fl o
17149874f6eSJoseph Koshyoption.
172b6010f9eSJoseph Koshy.It Fl N
173b6010f9eSJoseph KoshyToggle capturing callchain information for subsequent sampling PMCs.
174b6010f9eSJoseph KoshyThe default is for sampling PMCs to capture callchain information.
175ebccf1e3SJoseph Koshy.It Fl O Ar logfilename
17621ce09caSJoseph KoshySend logging output to file
177ebccf1e3SJoseph Koshy.Ar logfilename .
178302cbb90SJoseph KoshyIf
179302cbb90SJoseph Koshy.Ar logfilename
180302cbb90SJoseph Koshyis of the form
181302cbb90SJoseph Koshy.Ar hostname Ns : Ns Ar port ,
182302cbb90SJoseph Koshywhere
183302cbb90SJoseph Koshy.Ar hostname
184302cbb90SJoseph Koshydoes not start with a
185bc84aa4bSRuslan Ermilov.Ql \&.
186302cbb90SJoseph Koshyor a
187bc84aa4bSRuslan Ermilov.Ql / ,
188302cbb90SJoseph Koshythen
189302cbb90SJoseph Koshy.Nm
190302cbb90SJoseph Koshywill open a network socket to host
191302cbb90SJoseph Koshy.Ar hostname
192302cbb90SJoseph Koshyon port
193302cbb90SJoseph Koshy.Ar port .
194302cbb90SJoseph Koshy.Pp
195302cbb90SJoseph KoshyIf the
196302cbb90SJoseph Koshy.Fl O
197302cbb90SJoseph Koshyoption is not specified and one of the logging options is requested,
198302cbb90SJoseph Koshythen
199f263522aSJoseph Koshy.Nm
20021ce09caSJoseph Koshywill print a textual form of the logged events to the configured
201f263522aSJoseph Koshyoutput file.
202ebccf1e3SJoseph Koshy.It Fl P Ar event-spec
203ebccf1e3SJoseph KoshyAllocate a process mode sampling PMC measuring hardware events
204ebccf1e3SJoseph Koshyspecified in
205ebccf1e3SJoseph Koshy.Ar event-spec .
206f263522aSJoseph Koshy.It Fl R Ar logfilename
207f263522aSJoseph KoshyPerform offline analysis using sampling data in file
208f263522aSJoseph Koshy.Ar logfilename .
209ebccf1e3SJoseph Koshy.It Fl S Ar event-spec
210ebccf1e3SJoseph KoshyAllocate a system mode sampling PMC measuring hardware events
211ebccf1e3SJoseph Koshyspecified in
212ebccf1e3SJoseph Koshy.Ar event-spec .
2130b86b1bbSFabien Thomas.It Fl T
2140b86b1bbSFabien ThomasUse a top like mode for sampling PMCs. The following hotkeys
2150b86b1bbSFabien Thomascan be used: 'c+a' switch to accumulative mode, 'c+d' switch
2160b86b1bbSFabien Thomasto delta mode, 'm' merge PMCs, 'n' change view, 'p' show next
2170b86b1bbSFabien ThomasPMC, ' ' pause, 'q' quit. calltree only: 'f' cost under threshold
2180b86b1bbSFabien Thomasis seen as a dot.
219f263522aSJoseph Koshy.It Fl W
220f263522aSJoseph KoshyToggle logging the incremental counts seen by the threads of a
221f263522aSJoseph Koshytracked process each time they are scheduled on a CPU.
222f263522aSJoseph KoshyThis is an experimental feature intended to help analyse the
223f263522aSJoseph Koshydynamic behaviour of processes in the system.
224f263522aSJoseph KoshyIt may incur substantial overhead if enabled.
225f263522aSJoseph KoshyThe default is for this feature to be disabled.
226f6f851a3SScott Long.It Fl a Ar pathname
227f6f851a3SScott LongPerform a symbol and file:line lookup for each address in each
228f6f851a3SScott Longcallgraph and save the output to
229f6f851a3SScott Long.Ar pathname .
230f6f851a3SScott LongUnlike
231f6f851a3SScott Long.Fl m
232f6f851a3SScott Longthat only resolves the first symbol in the graph, this resolves
233f6f851a3SScott Longevery node in the callgraph, or prints out addresses if no
234f6f851a3SScott Longlookup information is available.
235f6f851a3SScott LongThis option requires the
236f6f851a3SScott Long.Fl R
237f6f851a3SScott Longoption to read in samples that were previously collected and
238f6f851a3SScott Longsaved with the
239*10813ab3SEric van Gyzen.Fl O
240f6f851a3SScott Longoption.
241ee4910b1SJoseph Koshy.It Fl c Ar cpu-spec
242ee4910b1SJoseph KoshySet the cpus for subsequent system mode PMCs specified on the
243ebccf1e3SJoseph Koshycommand line to
244ee4910b1SJoseph Koshy.Ar cpu-spec .
245ee4910b1SJoseph KoshyArgument
246ee4910b1SJoseph Koshy.Ar cpu-spec
247ee4910b1SJoseph Koshyis a comma separated list of CPU numbers, or the literal
248ee4910b1SJoseph Koshy.Sq *
2495477328dSJoseph Koshydenoting all unhalted CPUs.
2505477328dSJoseph KoshyThe default is to allocate system mode PMCs on all unhalted
2515477328dSJoseph KoshyCPUs.
252ebccf1e3SJoseph Koshy.It Fl d
253ebccf1e3SJoseph KoshyToggle between process mode PMCs measuring events for the target
254ebccf1e3SJoseph Koshyprocess' current and future children or only measuring events for
255f263522aSJoseph Koshythe target process.
256ebccf1e3SJoseph KoshyThe default is to measure events for the target process alone.
25799e33eabSBaptiste Daroussin(it has to be passed in the command line prior to
25899e33eabSBaptiste Daroussin.Fl p ,
25999e33eabSBaptiste Daroussin.Fl s ,
26099e33eabSBaptiste Daroussin.Fl P ,
26199e33eabSBaptiste Daroussinor
262f42d8decSBaptiste Daroussin.Fl S ) .
2630b86b1bbSFabien Thomas.It Fl f Ar pluginopt
2640b86b1bbSFabien ThomasPass option string to the active plugin.
2650b86b1bbSFabien Thomas.br
2660b86b1bbSFabien Thomasthreshold=<float> do not display cost under specified value (Top).
2670b86b1bbSFabien Thomas.br
2680b86b1bbSFabien Thomasskiplink=0|1 replace node with cost under threshold by a dot (Top).
269f263522aSJoseph Koshy.It Fl g
270b6010f9eSJoseph KoshyProduce profiles in a format compatible with
271f263522aSJoseph Koshy.Xr gprof 1 .
2721fdbf256SJoseph KoshyA separate profile file is generated for each executable object
2731fdbf256SJoseph Koshyencountered.
2741fdbf256SJoseph KoshyProfile files are placed in sub-directories named by their PMC
2751fdbf256SJoseph Koshyevent name.
27649874f6eSJoseph Koshy.It Fl k Ar kerneldir
27749874f6eSJoseph KoshySet the pathname of the kernel directory to argument
27849874f6eSJoseph Koshy.Ar kerneldir .
27949874f6eSJoseph KoshyThis directory specifies where
28049874f6eSJoseph Koshy.Nm
28149874f6eSJoseph Koshyshould look for the kernel and its modules.
28215139246SJoseph KoshyThe default is
28349874f6eSJoseph Koshy.Pa /boot/kernel .
28472fe532cSGeorge V. Neville-Neil.It Fl l Ar secs
28572fe532cSGeorge V. Neville-NeilSet system-wide performance measurement duration for
28672fe532cSGeorge V. Neville-Neil.Ar secs
28772fe532cSGeorge V. Neville-Neilseconds.
28872fe532cSGeorge V. Neville-NeilThe argument
28972fe532cSGeorge V. Neville-Neil.Ar secs
29072fe532cSGeorge V. Neville-Neilmay be a fractional value.
291c0252222SAttilio Rao.It Fl m Ar pathname
292c0252222SAttilio RaoPrint the sampled PCs with the name, the start and ending addresses
293c0252222SAttilio Raoof the function within they live.
294c0252222SAttilio RaoThe
295c0252222SAttilio Rao.Ar pathname
2968972c8b6SJoel Dahlargument is mandatory and indicates where the information will be stored.
297c0252222SAttilio RaoIf argument
298c0252222SAttilio Rao.Ar pathname
299c0252222SAttilio Raois a
300c0252222SAttilio Rao.Dq Li -
301c0252222SAttilio Raothis information is sent to the output file specified by the
302c0252222SAttilio Rao.Fl o
303c0252222SAttilio Raooption.
304*10813ab3SEric van GyzenThis option requires the
305*10813ab3SEric van Gyzen.Fl R
306*10813ab3SEric van Gyzenoption to read in samples that were previously collected and
307*10813ab3SEric van Gyzensaved with the
308*10813ab3SEric van Gyzen.Fl O
309*10813ab3SEric van Gyzenoption.
310ebccf1e3SJoseph Koshy.It Fl n Ar rate
311ebccf1e3SJoseph KoshySet the default sampling rate for subsequent sampling mode
312ebccf1e3SJoseph KoshyPMCs specified on the command line.
313ebccf1e3SJoseph KoshyThe default is to configure PMCs to sample the CPU's instruction
314ebccf1e3SJoseph Koshypointer every 65536 events.
315ebccf1e3SJoseph Koshy.It Fl o Ar outputfile
31621ce09caSJoseph KoshySend counter readings and textual representations of logged data
317ebccf1e3SJoseph Koshyto file
318ebccf1e3SJoseph Koshy.Ar outputfile .
319ebccf1e3SJoseph KoshyThe default is to send output to
320b6010f9eSJoseph Koshy.Pa stderr
321b6010f9eSJoseph Koshywhen collecting live data and to
322b6010f9eSJoseph Koshy.Pa stdout
323b6010f9eSJoseph Koshywhen processing a pre-existing logfile.
324ebccf1e3SJoseph Koshy.It Fl p Ar event-spec
325ebccf1e3SJoseph KoshyAllocate a process mode counting PMC measuring hardware events
326ebccf1e3SJoseph Koshyspecified in
327ebccf1e3SJoseph Koshy.Ar event-spec .
32849874f6eSJoseph Koshy.It Fl q
32949874f6eSJoseph KoshyDecrease verbosity.
33049874f6eSJoseph Koshy.It Fl r Ar fsroot
33149874f6eSJoseph KoshySet the top of the filesystem hierarchy under which executables
33249874f6eSJoseph Koshyare located to argument
33349874f6eSJoseph Koshy.Ar fsroot .
33449874f6eSJoseph KoshyThe default is
33549874f6eSJoseph Koshy.Pa / .
336ebccf1e3SJoseph Koshy.It Fl s Ar event-spec
337ebccf1e3SJoseph KoshyAllocate a system mode counting PMC measuring hardware events
338ebccf1e3SJoseph Koshyspecified in
339ebccf1e3SJoseph Koshy.Ar event-spec .
340fbd8b34aSJoseph Koshy.It Fl t Ar process-spec
341fbd8b34aSJoseph KoshyAttach process mode PMCs to the processes named by argument
342fbd8b34aSJoseph Koshy.Ar process-spec .
343fbd8b34aSJoseph KoshyArgument
344fbd8b34aSJoseph Koshy.Ar process-spec
345fbd8b34aSJoseph Koshymay be a non-negative integer denoting a specific process id, or a
346fbd8b34aSJoseph Koshyregular expression for selecting processes based on their command names.
34749874f6eSJoseph Koshy.It Fl v
34849874f6eSJoseph KoshyIncrease verbosity.
349ebccf1e3SJoseph Koshy.It Fl w Ar secs
3500b86b1bbSFabien ThomasPrint the values of all counting mode PMCs or sampling mode PMCs
3510b86b1bbSFabien Thomasfor top mode every
352ebccf1e3SJoseph Koshy.Ar secs
353ebccf1e3SJoseph Koshyseconds.
354ebccf1e3SJoseph KoshyThe argument
355ebccf1e3SJoseph Koshy.Ar secs
356ebccf1e3SJoseph Koshymay be a fractional value.
357ebccf1e3SJoseph KoshyThe default interval is 5 seconds.
358b6010f9eSJoseph Koshy.It Fl z Ar graphdepth
359b6010f9eSJoseph KoshyWhen printing system-wide callgraphs, limit callgraphs to the depth
360b6010f9eSJoseph Koshyspecified by argument
361b6010f9eSJoseph Koshy.Ar graphdepth .
362ebccf1e3SJoseph Koshy.El
363ebccf1e3SJoseph Koshy.Pp
364ebccf1e3SJoseph KoshyIf
365ebccf1e3SJoseph Koshy.Ar command
366ebccf1e3SJoseph Koshyis specified, it is executed using
367ebccf1e3SJoseph Koshy.Xr execvp 3 .
368ebccf1e3SJoseph Koshy.Sh EXAMPLES
369ebccf1e3SJoseph KoshyTo perform system-wide statistical sampling on an AMD Athlon CPU with
370ebccf1e3SJoseph Koshysamples taken every 32768 instruction retirals and data being sampled
371ebccf1e3SJoseph Koshyto file
37221ce09caSJoseph Koshy.Pa sample.stat ,
373ebccf1e3SJoseph Koshyuse:
37400028966SRobert Watson.Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions"
375ebccf1e3SJoseph Koshy.Pp
376ebccf1e3SJoseph KoshyTo execute
377a2c0b3aeSJoseph Koshy.Nm firefox
378ebccf1e3SJoseph Koshyand measure the number of data cache misses suffered
379ebccf1e3SJoseph Koshyby it and its children every 12 seconds on an AMD Athlon, use:
380a2c0b3aeSJoseph Koshy.Dl "pmcstat -d -w 12 -p k7-dc-misses firefox"
3811fdbf256SJoseph Koshy.Pp
3822c79db51SJoseph KoshyTo measure instructions retired for all processes named
383fbd8b34aSJoseph Koshy.Dq emacs
384fbd8b34aSJoseph Koshyuse:
385fbd8b34aSJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions"
386fbd8b34aSJoseph Koshy.Pp
3872c79db51SJoseph KoshyTo measure instructions retired for processes named
3882c79db51SJoseph Koshy.Dq emacs
3892c79db51SJoseph Koshyfor a period of 10 seconds use:
3902c79db51SJoseph Koshy.Dl "pmcstat -t '^emacs$' -p instructions sleep 10"
3912c79db51SJoseph Koshy.Pp
392ee4910b1SJoseph KoshyTo count instruction tlb-misses on CPUs 0 and 2 on a Intel
393ee4910b1SJoseph KoshyPentium Pro/Pentium III SMP system use:
394ee4910b1SJoseph Koshy.Dl "pmcstat -c 0,2 -s p6-itlb-miss"
395ee4910b1SJoseph Koshy.Pp
396b6010f9eSJoseph KoshyTo collect profiling information for a specific process with pid 1234
397b6010f9eSJoseph Koshybased on instruction cache misses seen by it use:
398b6010f9eSJoseph Koshy.Dl "pmcstat -P ic-misses -t 1234 -O /tmp/sample.out"
399b6010f9eSJoseph Koshy.Pp
400ee4910b1SJoseph KoshyTo perform system-wide sampling on all configured processors
401ee4910b1SJoseph Koshybased on processor instructions retired use:
4021fdbf256SJoseph Koshy.Dl "pmcstat -S instructions -O /tmp/sample.out"
403b6010f9eSJoseph KoshyIf callgraph capture is not desired use:
404b6010f9eSJoseph Koshy.Dl "pmcstat -N -S instructions -O /tmp/sample.out"
4051fdbf256SJoseph Koshy.Pp
406302cbb90SJoseph KoshyTo send the generated event log to a remote machine use:
407302cbb90SJoseph Koshy.Dl "pmcstat -S instructions -O remotehost:port"
408302cbb90SJoseph KoshyOn the remote machine, the sample log can be collected using
409302cbb90SJoseph Koshy.Xr nc 1 :
410302cbb90SJoseph Koshy.Dl "nc -l remotehost port > /tmp/sample.out"
411302cbb90SJoseph Koshy.Pp
4121fdbf256SJoseph KoshyTo generate
4131fdbf256SJoseph Koshy.Xr gprof 1
414b6010f9eSJoseph Koshycompatible profiles from a sample file use:
4151fdbf256SJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -g"
416b6010f9eSJoseph Koshy.Pp
417b6010f9eSJoseph KoshyTo print a system-wide profile with callgraphs to file
418b6010f9eSJoseph Koshy.Pa "foo.graph"
419b6010f9eSJoseph Koshyuse:
420b6010f9eSJoseph Koshy.Dl "pmcstat -R /tmp/sample.out -G foo.graph"
421ebccf1e3SJoseph Koshy.Sh DIAGNOSTICS
422e572c7a7SJoseph KoshyIf option
423e572c7a7SJoseph Koshy.Fl v
424e572c7a7SJoseph Koshyis specified,
425e572c7a7SJoseph Koshy.Nm
426e572c7a7SJoseph Koshymay issue the following diagnostic messages:
42746355096SJoel Dahl.Bl -diag
428e572c7a7SJoseph Koshy.It "#callchain/dubious-frames"
429e572c7a7SJoseph KoshyThe number of callchain records that had an
430e572c7a7SJoseph Koshy.Dq impossible
431e572c7a7SJoseph Koshyvalue for a return address.
432e572c7a7SJoseph Koshy.It "#exec handling errors"
433e572c7a7SJoseph KoshyThe number of
434e572c7a7SJoseph Koshy.Xr exec 2
435e572c7a7SJoseph Koshyevents in the log file that named executables that could not be
436e572c7a7SJoseph Koshyanalyzed.
437e572c7a7SJoseph Koshy.It "#exec/elf"
438e572c7a7SJoseph KoshyThe number of
439e572c7a7SJoseph Koshy.Xr exec 2
440e572c7a7SJoseph Koshyevents that named ELF executables.
441e572c7a7SJoseph Koshy.It "#exec/unknown"
442e572c7a7SJoseph KoshyThe number of
443e572c7a7SJoseph Koshy.Xr exec 2
444e572c7a7SJoseph Koshyevents that named executables with unrecognized formats.
445e572c7a7SJoseph Koshy.It "#samples/total"
446e572c7a7SJoseph KoshyThe total number of samples in the log file.
447e572c7a7SJoseph Koshy.It "#samples/unclaimed"
448e572c7a7SJoseph KoshyThe number of samples that could not be correlated to a known
449e572c7a7SJoseph Koshyexecutable object (i.e., to an executable, shared library, the
450e572c7a7SJoseph Koshykernel or the runtime loader).
451e572c7a7SJoseph Koshy.It "#samples/unknown-object"
452e572c7a7SJoseph KoshyThe number of samples that were associated with an executable
453e572c7a7SJoseph Koshywith an unrecognized object format.
454e572c7a7SJoseph Koshy.El
455e572c7a7SJoseph Koshy.Pp
45621ce09caSJoseph Koshy.Ex -std
457b6010f9eSJoseph Koshy.Sh COMPATIBILITY
458b6010f9eSJoseph KoshyDue to the limitations of the
459b6010f9eSJoseph Koshy.Pa gmon.out
460b6010f9eSJoseph Koshyfile format,
461b6010f9eSJoseph Koshy.Xr gprof 1
462b6010f9eSJoseph Koshycompatible profiles generated by the
463b6010f9eSJoseph Koshy.Fl g
464b6010f9eSJoseph Koshyoption do not contain information about calls that cross executable
465b6010f9eSJoseph Koshyboundaries.
466b6010f9eSJoseph KoshyThe generated
467b6010f9eSJoseph Koshy.Pa gmon.out
468b6010f9eSJoseph Koshyfiles are also only meaningful for native executables.
469ebccf1e3SJoseph Koshy.Sh SEE ALSO
470f263522aSJoseph Koshy.Xr gprof 1 ,
471302cbb90SJoseph Koshy.Xr nc 1 ,
472ebccf1e3SJoseph Koshy.Xr execvp 3 ,
473ebccf1e3SJoseph Koshy.Xr pmc 3 ,
47421ce09caSJoseph Koshy.Xr pmclog 3 ,
475ebccf1e3SJoseph Koshy.Xr hwpmc 4 ,
476ebccf1e3SJoseph Koshy.Xr pmccontrol 8 ,
477ebccf1e3SJoseph Koshy.Xr sysctl 8
47821ce09caSJoseph Koshy.Sh HISTORY
47921ce09caSJoseph KoshyThe
48021ce09caSJoseph Koshy.Nm
48121ce09caSJoseph Koshyutility first appeared in
48221ce09caSJoseph Koshy.Fx 6.0 .
4831fdbf256SJoseph KoshyIt is
4841fdbf256SJoseph Koshy.Ud
48521ce09caSJoseph Koshy.Sh AUTHORS
48601c2b8acSBaptiste Daroussin.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org
4879f8adcefSJoseph Koshy.Sh BUGS
488bc84aa4bSRuslan ErmilovThe
4899f8adcefSJoseph Koshy.Nm
490bc84aa4bSRuslan Ermilovutility cannot yet analyse
491302cbb90SJoseph Koshy.Xr hwpmc 4
492302cbb90SJoseph Koshylogs generated by non-native architectures.
493