]> CyberLeo.Net >> Repos - FreeBSD/releng/9.3.git/blob - usr.sbin/pmcstat/pmcstat.8
Fix possible login(1) argument injection in telnetd(8). [SA-16:36]
[FreeBSD/releng/9.3.git] / usr.sbin / pmcstat / pmcstat.8
1 .\" Copyright (c) 2003-2008 Joseph Koshy
2 .\" Copyright (c) 2007 The FreeBSD Foundation
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" This software is provided by Joseph Koshy ``as is'' and
15 .\" any express or implied warranties, including, but not limited to, the
16 .\" implied warranties of merchantability and fitness for a particular purpose
17 .\" are disclaimed.  in no event shall Joseph Koshy be liable
18 .\" for any direct, indirect, incidental, special, exemplary, or consequential
19 .\" damages (including, but not limited to, procurement of substitute goods
20 .\" or services; loss of use, data, or profits; or business interruption)
21 .\" however caused and on any theory of liability, whether in contract, strict
22 .\" liability, or tort (including negligence or otherwise) arising in any way
23 .\" out of the use of this software, even if advised of the possibility of
24 .\" such damage.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd May 16, 2014
29 .Dt PMCSTAT 8
30 .Os
31 .Sh NAME
32 .Nm pmcstat
33 .Nd "performance measurement with performance monitoring hardware"
34 .Sh SYNOPSIS
35 .Nm
36 .Op Fl C
37 .Op Fl D Ar pathname
38 .Op Fl E
39 .Op Fl F Ar pathname
40 .Op Fl G Ar pathname
41 .Op Fl M Ar mapfilename
42 .Op Fl N
43 .Op Fl O Ar logfilename
44 .Op Fl P Ar event-spec
45 .Op Fl R Ar logfilename
46 .Op Fl S Ar event-spec
47 .Op Fl T
48 .Op Fl W
49 .Op Fl c Ar cpu-spec
50 .Op Fl d
51 .Op Fl f Ar pluginopt
52 .Op Fl g
53 .Op Fl k Ar kerneldir
54 .Op Fl l Ar secs
55 .Op Fl m Ar pathname
56 .Op Fl n Ar rate
57 .Op Fl o Ar outputfile
58 .Op Fl p Ar event-spec
59 .Op Fl q
60 .Op Fl r Ar fsroot
61 .Op Fl s Ar event-spec
62 .Op Fl t Ar process-spec
63 .Op Fl v
64 .Op Fl w Ar secs
65 .Op Fl z Ar graphdepth
66 .Op Ar command Op Ar args
67 .Sh DESCRIPTION
68 The
69 .Nm
70 utility measures system performance using the facilities provided by
71 .Xr hwpmc 4 .
72 .Pp
73 The
74 .Nm
75 utility can measure both hardware events seen by the system as a
76 whole, and those seen when a specified set of processes are executing
77 on the system's CPUs.
78 If a specific set of processes is being targeted (for example,
79 if the
80 .Fl t Ar process-spec
81 option is specified, or if a command line is specified using
82 .Ar command ) ,
83 then measurement occurs till
84 .Ar command
85 exits, or till all target processes specified by the
86 .Fl t Ar process-spec
87 options exit, or till the
88 .Nm
89 utility is interrupted by the user.
90 If a specific set of processes is not targeted for measurement, then
91 .Nm
92 will perform system-wide measurements till interrupted by the
93 user.
94 .Pp
95 A given invocation of
96 .Nm
97 can mix allocations of system-mode and process-mode PMCs, of both
98 counting and sampling flavors.
99 The values of all counting PMCs are printed in human readable form
100 at regular intervals by
101 .Nm .
102 The output of sampling PMCs may be configured to go to a log file for
103 subsequent offline analysis, or, at the expense of greater
104 overhead, may be configured to be printed in text form on the fly.
105 .Pp
106 Hardware events to measure are specified to
107 .Nm
108 using event specifier strings
109 .Ar event-spec .
110 The syntax of these event specifiers is machine dependent and is
111 documented in
112 .Xr pmc 3 .
113 .Pp
114 A process-mode PMC may be configured to be inheritable by the target
115 process' current and future children.
116 .Sh OPTIONS
117 The following options are available:
118 .Bl -tag -width indent
119 .It Fl C
120 Toggle between showing cumulative or incremental counts for
121 subsequent counting mode PMCs specified on the command line.
122 The default is to show incremental counts.
123 .It Fl D Ar pathname
124 Create files with per-program samples in the directory named
125 by
126 .Ar pathname .
127 The default is to create these files in the current directory.
128 .It Fl E
129 Toggle showing per-process counts at the time a tracked process
130 exits for subsequent process-mode PMCs specified on the command line.
131 This option is useful for mapping the performance characteristics of a
132 complex pipeline of processes when used in conjunction with the
133 .Fl d
134 option.
135 The default is to not to enable per-process tracking.
136 .It Fl F Ar pathname
137 Print calltree (Kcachegrind) information to file
138 .Ar pathname .
139 If argument
140 .Ar pathname
141 is a
142 .Dq Li -
143 this information is sent to the output file specified by the
144 .Fl o
145 option.
146 .It Fl G Ar pathname
147 Print callchain information to file
148 .Ar pathname .
149 If argument
150 .Ar pathname
151 is a
152 .Dq Li -
153 this information is sent to the output file specified by the
154 .Fl o
155 option.
156 .It Fl M Ar mapfilename
157 Write the mapping between executable objects encountered in the event
158 log and the abbreviated pathnames used for
159 .Xr gprof 1
160 profiles to file
161 .Ar mapfilename .
162 If this option is not specified, mapping information is not written.
163 Argument
164 .Ar mapfilename
165 may be a
166 .Dq Li -
167 in which case this mapping information is sent to the output
168 file configured by the
169 .Fl o
170 option.
171 .It Fl N
172 Toggle capturing callchain information for subsequent sampling PMCs.
173 The default is for sampling PMCs to capture callchain information.
174 .It Fl O Ar logfilename
175 Send logging output to file
176 .Ar logfilename .
177 If
178 .Ar logfilename
179 is of the form
180 .Ar hostname Ns : Ns Ar port ,
181 where
182 .Ar hostname
183 does not start with a
184 .Ql \&.
185 or a
186 .Ql / ,
187 then
188 .Nm
189 will open a network socket to host
190 .Ar hostname
191 on port
192 .Ar port .
193 .Pp
194 If the
195 .Fl O
196 option is not specified and one of the logging options is requested,
197 then
198 .Nm
199 will print a textual form of the logged events to the configured
200 output file.
201 .It Fl P Ar event-spec
202 Allocate a process mode sampling PMC measuring hardware events
203 specified in
204 .Ar event-spec .
205 .It Fl R Ar logfilename
206 Perform offline analysis using sampling data in file
207 .Ar logfilename .
208 .It Fl S Ar event-spec
209 Allocate a system mode sampling PMC measuring hardware events
210 specified in
211 .Ar event-spec .
212 .It Fl T
213 Use a top like mode for sampling PMCs. The following hotkeys
214 can be used: 'c+a' switch to accumulative mode, 'c+d' switch
215 to delta mode, 'm' merge PMCs, 'n' change view, 'p' show next
216 PMC, ' ' pause, 'q' quit. calltree only: 'f' cost under threshold
217 is seen as a dot.
218 .It Fl W
219 Toggle logging the incremental counts seen by the threads of a
220 tracked process each time they are scheduled on a CPU.
221 This is an experimental feature intended to help analyse the
222 dynamic behaviour of processes in the system.
223 It may incur substantial overhead if enabled.
224 The default is for this feature to be disabled.
225 .It Fl c Ar cpu-spec
226 Set the cpus for subsequent system mode PMCs specified on the
227 command line to
228 .Ar cpu-spec .
229 Argument
230 .Ar cpu-spec
231 is a comma separated list of CPU numbers, or the literal
232 .Sq *
233 denoting all unhalted CPUs.
234 The default is to allocate system mode PMCs on all unhalted
235 CPUs.
236 .It Fl d
237 Toggle between process mode PMCs measuring events for the target
238 process' current and future children or only measuring events for
239 the target process.
240 The default is to measure events for the target process alone.
241 .It Fl f Ar pluginopt
242 Pass option string to the active plugin.
243 .br
244 threshold=<float> do not display cost under specified value (Top).
245 .br
246 skiplink=0|1 replace node with cost under threshold by a dot (Top).
247 .It Fl g
248 Produce profiles in a format compatible with
249 .Xr gprof 1 .
250 A separate profile file is generated for each executable object
251 encountered.
252 Profile files are placed in sub-directories named by their PMC
253 event name.
254 .It Fl k Ar kerneldir
255 Set the pathname of the kernel directory to argument
256 .Ar kerneldir .
257 This directory specifies where
258 .Nm
259 should look for the kernel and its modules.
260 The default is
261 .Pa /boot/kernel .
262 .It Fl l Ar secs
263 Set system-wide performance measurement duration for
264 .Ar secs
265 seconds.
266 The argument
267 .Ar secs
268 may be a fractional value.
269 .It Fl m Ar pathname
270 Print the sampled PCs with the name, the start and ending addresses
271 of the function within they live.
272 The
273 .Ar pathname
274 argument is mandatory and indicates where informations will be stored.
275 If argument
276 .Ar pathname
277 is a
278 .Dq Li -
279 this information is sent to the output file specified by the
280 .Fl o
281 option.
282 .It Fl n Ar rate
283 Set the default sampling rate for subsequent sampling mode
284 PMCs specified on the command line.
285 The default is to configure PMCs to sample the CPU's instruction
286 pointer every 65536 events.
287 .It Fl o Ar outputfile
288 Send counter readings and textual representations of logged data
289 to file
290 .Ar outputfile .
291 The default is to send output to
292 .Pa stderr
293 when collecting live data and to
294 .Pa stdout
295 when processing a pre-existing logfile.
296 .It Fl p Ar event-spec
297 Allocate a process mode counting PMC measuring hardware events
298 specified in
299 .Ar event-spec .
300 .It Fl q
301 Decrease verbosity.
302 .It Fl r Ar fsroot
303 Set the top of the filesystem hierarchy under which executables
304 are located to argument
305 .Ar fsroot .
306 The default is
307 .Pa / .
308 .It Fl s Ar event-spec
309 Allocate a system mode counting PMC measuring hardware events
310 specified in
311 .Ar event-spec .
312 .It Fl t Ar process-spec
313 Attach process mode PMCs to the processes named by argument
314 .Ar process-spec .
315 Argument
316 .Ar process-spec
317 may be a non-negative integer denoting a specific process id, or a
318 regular expression for selecting processes based on their command names.
319 .It Fl v
320 Increase verbosity.
321 .It Fl w Ar secs
322 Print the values of all counting mode PMCs or sampling mode PMCs
323 for top mode every
324 .Ar secs
325 seconds.
326 The argument
327 .Ar secs
328 may be a fractional value.
329 The default interval is 5 seconds.
330 .It Fl z Ar graphdepth
331 When printing system-wide callgraphs, limit callgraphs to the depth
332 specified by argument
333 .Ar graphdepth .
334 .El
335 .Pp
336 If
337 .Ar command
338 is specified, it is executed using
339 .Xr execvp 3 .
340 .Sh EXAMPLES
341 To perform system-wide statistical sampling on an AMD Athlon CPU with
342 samples taken every 32768 instruction retirals and data being sampled
343 to file
344 .Pa sample.stat ,
345 use:
346 .Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions"
347 .Pp
348 To execute
349 .Nm firefox
350 and measure the number of data cache misses suffered
351 by it and its children every 12 seconds on an AMD Athlon, use:
352 .Dl "pmcstat -d -w 12 -p k7-dc-misses firefox"
353 .Pp
354 To measure instructions retired for all processes named
355 .Dq emacs
356 use:
357 .Dl "pmcstat -t '^emacs$' -p instructions"
358 .Pp
359 To measure instructions retired for processes named
360 .Dq emacs
361 for a period of 10 seconds use:
362 .Dl "pmcstat -t '^emacs$' -p instructions sleep 10"
363 .Pp
364 To count instruction tlb-misses on CPUs 0 and 2 on a Intel
365 Pentium Pro/Pentium III SMP system use:
366 .Dl "pmcstat -c 0,2 -s p6-itlb-miss"
367 .Pp
368 To collect profiling information for a specific process with pid 1234
369 based on instruction cache misses seen by it use:
370 .Dl "pmcstat -P ic-misses -t 1234 -O /tmp/sample.out"
371 .Pp
372 To perform system-wide sampling on all configured processors
373 based on processor instructions retired use:
374 .Dl "pmcstat -S instructions -O /tmp/sample.out"
375 If callgraph capture is not desired use:
376 .Dl "pmcstat -N -S instructions -O /tmp/sample.out"
377 .Pp
378 To send the generated event log to a remote machine use:
379 .Dl "pmcstat -S instructions -O remotehost:port"
380 On the remote machine, the sample log can be collected using
381 .Xr nc 1 :
382 .Dl "nc -l remotehost port > /tmp/sample.out"
383 .Pp
384 To generate
385 .Xr gprof 1
386 compatible profiles from a sample file use:
387 .Dl "pmcstat -R /tmp/sample.out -g"
388 .Pp
389 To print a system-wide profile with callgraphs to file
390 .Pa "foo.graph"
391 use:
392 .Dl "pmcstat -R /tmp/sample.out -G foo.graph"
393 .Sh DIAGNOSTICS
394 If option
395 .Fl v
396 is specified,
397 .Nm
398 may issue the following diagnostic messages:
399 .Bl -diag -width indent
400 .It "#callchain/dubious-frames"
401 The number of callchain records that had an
402 .Dq impossible
403 value for a return address.
404 .It "#exec handling errors"
405 The number of
406 .Xr exec 2
407 events in the log file that named executables that could not be
408 analyzed.
409 .It "#exec/elf"
410 The number of
411 .Xr exec 2
412 events that named ELF executables.
413 .It "#exec/unknown"
414 The number of
415 .Xr exec 2
416 events that named executables with unrecognized formats.
417 .It "#samples/total"
418 The total number of samples in the log file.
419 .It "#samples/unclaimed"
420 The number of samples that could not be correlated to a known
421 executable object (i.e., to an executable, shared library, the
422 kernel or the runtime loader).
423 .It "#samples/unknown-object"
424 The number of samples that were associated with an executable
425 with an unrecognized object format.
426 .El
427 .Pp
428 .Ex -std
429 .Sh COMPATIBILITY
430 Due to the limitations of the
431 .Pa gmon.out
432 file format,
433 .Xr gprof 1
434 compatible profiles generated by the
435 .Fl g
436 option do not contain information about calls that cross executable
437 boundaries.
438 The generated
439 .Pa gmon.out
440 files are also only meaningful for native executables.
441 .Sh SEE ALSO
442 .Xr gprof 1 ,
443 .Xr nc 1 ,
444 .Xr execvp 3 ,
445 .Xr pmc 3 ,
446 .Xr pmclog 3 ,
447 .Xr hwpmc 4 ,
448 .Xr pmccontrol 8 ,
449 .Xr sysctl 8
450 .Sh HISTORY
451 The
452 .Nm
453 utility first appeared in
454 .Fx 6.0 .
455 It is
456 .Ud
457 .Sh AUTHORS
458 .An Joseph Koshy Aq jkoshy@FreeBSD.org
459 .Sh BUGS
460 The
461 .Nm
462 utility cannot yet analyse
463 .Xr hwpmc 4
464 logs generated by non-native architectures.