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       -G name, --cgroup name
255           monitor only in the container (cgroup) called "name". This option
256           is available only in per-cpu mode. The cgroup filesystem must be
257           mounted. All threads belonging to container "name" are monitored
258           when they run on the monitored CPUs. Multiple cgroups can be
259           provided. Each cgroup is applied to the corresponding event, i.e.,
260           first cgroup to first event, second cgroup to second event and so
261           on. It is possible to provide an empty cgroup (monitor all the
262           time) using, e.g., -G foo,,bar. Cgroups must have corresponding
263           events, i.e., they always refer to events defined earlier on the
264           command line. If the user wants to track multiple events for a
265           specific cgroup, the user can use -e e1 -e e2 -G foo,foo or just
266           use -e e1 -e e2 -G foo.
267
268       --all-cgroups
269           Record events of type PERF_RECORD_CGROUP and display it with the
270           cgroup sort key.
271
272       --switch-on EVENT_NAME
273           Only consider events after this event is found.
274
275               E.g.:
276
277               Find out where broadcast packets are handled
278
279               perf probe -L icmp_rcv
280
281               Insert a probe there:
282
283               perf probe icmp_rcv:59
284
285               Start perf top and ask it to only consider the cycles events when a
286               broadcast packet arrives This will show a menu with two entries and
287               will start counting when a broadcast packet arrives:
288
289               perf top -e cycles,probe:icmp_rcv --switch-on=probe:icmp_rcv
290
291               Alternatively one can ask for --group and then two overhead columns
292               will appear, the first for cycles and the second for the switch-on event.
293
294               perf top --group -e cycles,probe:icmp_rcv --switch-on=probe:icmp_rcv
295
296               This may be interesting to measure a workload only after some initialization
297               phase is over, i.e. insert a perf probe at that point and use the above
298               examples replacing probe:icmp_rcv with the just-after-init probe.
299
300       --switch-off EVENT_NAME
301           Stop considering events after this event is found.
302
303       --show-on-off-events
304           Show the --switch-on/off events too. This has no effect in perf top
305           now but probably we’ll make the default not to show the
306           switch-on/off events on the --group mode and if there is only one
307           event besides the off/on ones, go straight to the histogram
308           browser, just like perf top with no events explicitly specified
309           does.
310
311       --stitch-lbr
312           Show callgraph with stitched LBRs, which may have more complete
313           callgraph. The option must be used with --call-graph lbr recording.
314           Disabled by default. In common cases with call stack overflows, it
315           can recreate better call stacks than the default lbr call stack
316           output. But this approach is not full proof. There can be cases
317           where it creates incorrect call stacks from incorrect matches. The
318           known limitations include exception handing such as setjmp/longjmp
319           will have calls/returns not match.
320

INTERACTIVE PROMPTING KEYS

322       [d]
323           Display refresh delay.
324
325       [e]
326           Number of entries to display.
327
328       [E]
329           Event to display when multiple counters are active.
330
331       [f]
332           Profile display filter (>= hit count).
333
334       [F]
335           Annotation display filter (>= % of total).
336
337       [s]
338           Annotate symbol.
339
340       [S]
341           Stop annotation, return to full profile display.
342
343       [K]
344           Hide kernel symbols.
345
346       [U]
347           Hide user symbols.
348
349       [z]
350           Toggle event count zeroing across display updates.
351
352       [qQ]
353           Quit.
354
355       Pressing any unmapped key displays a menu, and prompts for input.
356

OVERHEAD CALCULATION

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

SEE ALSO

470       perf-stat(1), perf-list(1), perf-report(1)
471
472
473
474perf                              11/22/2021                       PERF-TOP(1)
Impressum