1PERF-TOP(1)                       perf Manual                      PERF-TOP(1)
2
3
4

NAME

6       perf-top - System profiling tool.
7

SYNOPSIS

9       perf top [-e <EVENT> | --event=EVENT] [<options>]
10

DESCRIPTION

12       This command generates and displays a performance counter profile in
13       real time.
14

OPTIONS

16       -a, --all-cpus
17           System-wide collection. (default)
18
19       -c <count>, --count=<count>
20           Event period to sample.
21
22       -C <cpu-list>, --cpu=<cpu>
23           Monitor only on the list of CPUs provided. Multiple CPUs can be
24           provided as a comma-separated list with no space: 0,1. Ranges of
25           CPUs are specified with -: 0-2. Default is to monitor all CPUS.
26
27       -d <seconds>, --delay=<seconds>
28           Number of seconds to delay between refreshes.
29
30       -e <event>, --event=<event>
31           Select the PMU event. Selection can be a symbolic event name (use
32           perf list to list all events) or a raw PMU event (eventsel+umask)
33           in the form of rNNN where NNN is a hexadecimal event descriptor.
34
35       -E <entries>, --entries=<entries>
36           Display this many functions.
37
38       -f <count>, --count-filter=<count>
39           Only display functions with more events than this.
40
41       --group
42           Put the counters into a counter group.
43
44       --group-sort-idx
45           Sort the output by the event at the index n in group. If n is
46           invalid, sort by the first event. It can support multiple groups
47           with different amount of events. WARNING: This should be used on
48           grouped events.
49
50       -F <freq>, --freq=<freq>
51           Profile at this frequency. Use max to use the currently maximum
52           allowed frequency, i.e. the value in the
53           kernel.perf_event_max_sample_rate sysctl.
54
55       -i, --inherit
56           Child tasks do not inherit counters.
57
58       -k <path>, --vmlinux=<path>
59           Path to vmlinux. Required for annotation functionality.
60
61       --ignore-vmlinux
62           Ignore vmlinux files.
63
64       --kallsyms=<file>
65           kallsyms pathname
66
67       -m <pages>, --mmap-pages=<pages>
68           Number of mmap data pages (must be a power of two) or size
69           specification with appended unit character - B/K/M/G. The size is
70           rounded up to have nearest pages power of two value.
71
72       -p <pid>, --pid=<pid>
73           Profile events on existing Process ID (comma separated list).
74
75       -t <tid>, --tid=<tid>
76           Profile events on existing thread ID (comma separated list).
77
78       -u, --uid=
79           Record events in threads owned by uid. Name or number.
80
81       -r <priority>, --realtime=<priority>
82           Collect data with this RT SCHED_FIFO priority.
83
84       --sym-annotate=<symbol>
85           Annotate this symbol.
86
87       -K, --hide_kernel_symbols
88           Hide kernel symbols.
89
90       -U, --hide_user_symbols
91           Hide user symbols.
92
93       --demangle-kernel
94           Demangle kernel symbols.
95
96       -D, --dump-symtab
97           Dump the symbol table used for profiling.
98
99       -v, --verbose
100           Be more verbose (show counter open errors, etc).
101
102       -z, --zero
103           Zero history across display updates.
104
105       -s, --sort
106           Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight,
107           local_weight, abort, in_tx, transaction, overhead, sample, period.
108           Please see description of --sort in the perf-report man page.
109
110       --fields=
111           Specify output field - multiple keys can be specified in CSV
112           format. Following fields are available: overhead, overhead_sys,
113           overhead_us, overhead_children, sample and period. Also it can
114           contain any sort key(s).
115
116               By default, every sort keys not specified in --field will be appended
117               automatically.
118
119       -n, --show-nr-samples
120           Show a column with the number of samples.
121
122       --show-total-period
123           Show a column with the sum of periods.
124
125       --dsos
126           Only consider symbols in these dsos. This option will affect the
127           percentage of the overhead column. See --percentage for more info.
128
129       --comms
130           Only consider symbols in these comms. This option will affect the
131           percentage of the overhead column. See --percentage for more info.
132
133       --symbols
134           Only consider these symbols. This option will affect the percentage
135           of the overhead column. See --percentage for more info.
136
137       -M, --disassembler-style=
138           Set disassembler style for objdump.
139
140       --prefix=PREFIX, --prefix-strip=N
141           Remove first N entries from source file path names in executables
142           and add PREFIX. This allows to display source code compiled on
143           systems with different file system layout.
144
145       --source
146           Interleave source code with assembly code. Enabled by default,
147           disable with --no-source.
148
149       --asm-raw
150           Show raw instruction encoding of assembly instructions.
151
152       -g
153           Enables call-graph (stack chain/backtrace) recording.
154
155       --call-graph [mode,type,min[,limit],order[,key][,branch]]
156           Setup and enable call-graph (stack chain/backtrace) recording,
157           implies -g. See --call-graph section in perf-record and perf-report
158           man pages for details.
159
160       --children
161           Accumulate callchain of children to parent entry so that then can
162           show up in the output. The output will have a new "Children" column
163           and will be sorted on the data. It requires -g/--call-graph option
164           enabled. See the ‘overhead calculation’ section for more details.
165           Enabled by default, disable with --no-children.
166
167       --max-stack
168           Set the stack depth limit when parsing the callchain, anything
169           beyond the specified depth will be ignored. This is a trade-off
170           between information loss and faster processing especially for
171           workloads that can have a very long callchain stack.
172
173               Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
174
175       --ignore-callees=<regex>
176           Ignore callees of the function(s) matching the given regex. This
177           has the effect of collecting the callers of each such function into
178           one place in the call-graph tree.
179
180       --percent-limit
181           Do not show entries which have an overhead under that percent.
182           (Default: 0).
183
184       --percentage
185           Determine how to display the overhead percentage of filtered
186           entries. Filters can be applied by --comms, --dsos and/or --symbols
187           options and Zoom operations on the TUI (thread, dso, etc).
188
189               "relative" means it's relative to filtered entries only so that the
190               sum of shown entries will be always 100%. "absolute" means it retains
191               the original value before and after the filter is applied.
192
193       -w, --column-widths=<width[,width...]>
194           Force each column width to the provided list, for large terminal
195           readability. 0 means no limit (default behavior).
196
197       --proc-map-timeout
198           When processing pre-existing threads /proc/XXX/mmap, it may take a
199           long time, because the file may be huge. A time out is needed in
200           such cases. This option sets the time out limit. The default value
201           is 500 ms.
202
203       -b, --branch-any
204           Enable taken branch stack sampling. Any type of taken branch may be
205           sampled. This is a shortcut for --branch-filter any. See
206           --branch-filter for more infos.
207
208       -j, --branch-filter
209           Enable taken branch stack sampling. Each sample captures a series
210           of consecutive taken branches. The number of branches captured with
211           each sample depends on the underlying hardware, the type of
212           branches of interest, and the executed code. It is possible to
213           select the types of branches captured by enabling filters. For a
214           full list of modifiers please see the perf record manpage.
215
216               The option requires at least one branch type among any, any_call, any_ret, ind_call, cond.
217               The privilege levels may be omitted, in which case, the privilege levels of the associated
218               event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege
219               levels are subject to permissions.  When sampling on multiple events, branch stack sampling
220               is enabled for all the sampling events. The sampled branch type is the same for all events.
221               The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
222               Note that this feature may not be available on all processors.
223
224       --raw-trace
225           When displaying traceevent output, do not use print fmt or plugins.
226
227       --hierarchy
228           Enable hierarchy output.
229
230       --overwrite
231           Enable this to use just the most recent records, which helps in
232           high core count machines such as Knights Landing/Mill, but right
233           now is disabled by default as the pausing used in this technique is
234           leading to loss of metadata events such as PERF_RECORD_MMAP which
235           makes perf top unable to resolve samples, leading to lots of
236           unknown samples appearing on the UI. Enable this if you are in such
237           machines and profiling a workload that doesn’t creates short lived
238           threads and/or doesn’t uses many executable mmap operations. Work
239           is being planed to solve this situation, till then, this will
240           remain disabled by default.
241
242       --force
243           Don’t do ownership validation.
244
245       --num-thread-synthesize
246           The number of threads to run when synthesizing events for existing
247           processes. By default, the number of threads equals to the number
248           of online CPUs.
249
250       --namespaces
251           Record events of type PERF_RECORD_NAMESPACES and display it with
252           the cgroup_id sort key.
253
254       --all-cgroups
255           Record events of type PERF_RECORD_CGROUP and display it with the
256           cgroup sort key.
257
258       --switch-on EVENT_NAME
259           Only consider events after this event is found.
260
261               E.g.:
262
263               Find out where broadcast packets are handled
264
265               perf probe -L icmp_rcv
266
267               Insert a probe there:
268
269               perf probe icmp_rcv:59
270
271               Start perf top and ask it to only consider the cycles events when a
272               broadcast packet arrives This will show a menu with two entries and
273               will start counting when a broadcast packet arrives:
274
275               perf top -e cycles,probe:icmp_rcv --switch-on=probe:icmp_rcv
276
277               Alternatively one can ask for --group and then two overhead columns
278               will appear, the first for cycles and the second for the switch-on event.
279
280               perf top --group -e cycles,probe:icmp_rcv --switch-on=probe:icmp_rcv
281
282               This may be interesting to measure a workload only after some initialization
283               phase is over, i.e. insert a perf probe at that point and use the above
284               examples replacing probe:icmp_rcv with the just-after-init probe.
285
286       --switch-off EVENT_NAME
287           Stop considering events after this event is found.
288
289       --show-on-off-events
290           Show the --switch-on/off events too. This has no effect in perf top
291           now but probably we’ll make the default not to show the
292           switch-on/off events on the --group mode and if there is only one
293           event besides the off/on ones, go straight to the histogram
294           browser, just like perf top with no events explicitely specified
295           does.
296
297       --stitch-lbr
298           Show callgraph with stitched LBRs, which may have more complete
299           callgraph. The option must be used with --call-graph lbr recording.
300           Disabled by default. In common cases with call stack overflows, it
301           can recreate better call stacks than the default lbr call stack
302           output. But this approach is not full proof. There can be cases
303           where it creates incorrect call stacks from incorrect matches. The
304           known limitations include exception handing such as setjmp/longjmp
305           will have calls/returns not match.
306

INTERACTIVE PROMPTING KEYS

308       [d]
309           Display refresh delay.
310
311       [e]
312           Number of entries to display.
313
314       [E]
315           Event to display when multiple counters are active.
316
317       [f]
318           Profile display filter (>= hit count).
319
320       [F]
321           Annotation display filter (>= % of total).
322
323       [s]
324           Annotate symbol.
325
326       [S]
327           Stop annotation, return to full profile display.
328
329       [K]
330           Hide kernel symbols.
331
332       [U]
333           Hide user symbols.
334
335       [z]
336           Toggle event count zeroing across display updates.
337
338       [qQ]
339           Quit.
340
341       Pressing any unmapped key displays a menu, and prompts for input.
342

OVERHEAD CALCULATION

344       The overhead can be shown in two columns as Children and Self when perf
345       collects callchains. The self overhead is simply calculated by adding
346       all period values of the entry - usually a function (symbol). This is
347       the value that perf shows traditionally and sum of all the self
348       overhead values should be 100%.
349
350       The children overhead is calculated by adding all period values of the
351       child functions so that it can show the total overhead of the higher
352       level functions even if they don’t directly execute much. Children here
353       means functions that are called from another (parent) function.
354
355       It might be confusing that the sum of all the children overhead values
356       exceeds 100% since each of them is already an accumulation of self
357       overhead of its child functions. But with this enabled, users can find
358       which function has the most overhead even if samples are spread over
359       the children.
360
361       Consider the following example; there are three functions like below.
362
363
364           .ft C
365           void foo(void) {
366               /* do something */
367           }
368
369           void bar(void) {
370               /* do something */
371               foo();
372           }
373
374           int main(void) {
375               bar()
376               return 0;
377           }
378           .ft
379
380
381       In this case foo is a child of bar, and bar is an immediate child of
382       main so foo also is a child of main. In other words, main is a parent
383       of foo and bar, and bar is a parent of foo.
384
385       Suppose all samples are recorded in foo and bar only. When it’s
386       recorded with callchains the output will show something like below in
387       the usual (self-overhead-only) output of perf report:
388
389
390           .ft C
391           Overhead  Symbol
392           ........  .....................
393             60.00%  foo
394                     |
395                     --- foo
396                         bar
397                         main
398                         __libc_start_main
399
400             40.00%  bar
401                     |
402                     --- bar
403                         main
404                         __libc_start_main
405           .ft
406
407
408       When the --children option is enabled, the self overhead values of
409       child functions (i.e. foo and bar) are added to the parents to
410       calculate the children overhead. In this case the report could be
411       displayed as:
412
413
414           .ft C
415           Children      Self  Symbol
416           ........  ........  ....................
417            100.00%     0.00%  __libc_start_main
418                     |
419                     --- __libc_start_main
420
421            100.00%     0.00%  main
422                     |
423                     --- main
424                         __libc_start_main
425
426            100.00%    40.00%  bar
427                     |
428                     --- bar
429                         main
430                         __libc_start_main
431
432             60.00%    60.00%  foo
433                     |
434                     --- foo
435                         bar
436                         main
437                         __libc_start_main
438           .ft
439
440
441       In the above output, the self overhead of foo (60%) was add to the
442       children overhead of bar, main and __libc_start_main. Likewise, the
443       self overhead of bar (40%) was added to the children overhead of main
444       and \_\_libc_start_main.
445
446       So \_\_libc_start_main and main are shown first since they have same
447       (100%) children overhead (even though they have zero self overhead) and
448       they are the parents of foo and bar.
449
450       Since v3.16 the children overhead is shown by default and the output is
451       sorted by its values. The children overhead is disabled by specifying
452       --no-children option on the command line or by adding report.children =
453       false or top.children = false in the perf config file.
454

SEE ALSO

456       perf-stat(1), perf-list(1), perf-report(1)
457
458
459
460perf                              06/03/2021                       PERF-TOP(1)
Impressum