'\" t .\" Title: perf-top .\" Author: [see the "AUTHORS" section] .\" Generator: Asciidoctor 1.5.4 .\" Date: 2019-06-19 .\" Manual: perf Manual .\" Source: perf .\" Language: English .\" .TH "PERF_4.19\-TOP" "1" "2019-06-19" "perf" "perf Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \\$2 \(laURL: \\$1 \(ra\\$3 .. .if \n[.g] .mso www.tmac .LINKSTYLE blue R < > .SH "NAME" perf\-top \- System profiling tool. .SH "SYNOPSIS" .sp .nf \fIperf top\fP [\-e | \-\-event=EVENT] [] .fi .br .SH "DESCRIPTION" .sp This command generates and displays a performance counter profile in real time. .SH "OPTIONS" .sp \-a, \-\-all\-cpus .RS 4 System\-wide collection. (default) .RE .sp \-c , \-\-count= .RS 4 Event period to sample. .RE .sp \-C , \-\-cpu= .RS 4 Monitor only on the list of CPUs provided. Multiple CPUs can be provided as a comma\-separated list with no space: 0,1. Ranges of CPUs are specified with \-: 0\-2. Default is to monitor all CPUS. .RE .sp \-d , \-\-delay= .RS 4 Number of seconds to delay between refreshes. .RE .sp \-e , \-\-event= .RS 4 Select the PMU event. Selection can be a symbolic event name (use \fIperf list\fP to list all events) or a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a hexadecimal event descriptor. .RE .sp \-E , \-\-entries= .RS 4 Display this many functions. .RE .sp \-f , \-\-count\-filter= .RS 4 Only display functions with more events than this. .RE .sp \-\-group .RS 4 Put the counters into a counter group. .RE .sp \-F , \-\-freq= .RS 4 Profile at this frequency. Use \fImax\fP to use the currently maximum allowed frequency, i.e. the value in the kernel.perf_event_max_sample_rate sysctl. .RE .sp \-i, \-\-inherit .RS 4 Child tasks do not inherit counters. .RE .sp \-k , \-\-vmlinux= .RS 4 Path to vmlinux. Required for annotation functionality. .RE .sp \-\-ignore\-vmlinux .RS 4 Ignore vmlinux files. .RE .sp \-m , \-\-mmap\-pages= .RS 4 Number of mmap data pages (must be a power of two) or size specification with appended unit character \- B/K/M/G. The size is rounded up to have nearest pages power of two value. .RE .sp \-p , \-\-pid= .RS 4 Profile events on existing Process ID (comma separated list). .RE .sp \-t , \-\-tid= .RS 4 Profile events on existing thread ID (comma separated list). .RE .sp \-u, \-\-uid= .RS 4 Record events in threads owned by uid. Name or number. .RE .sp \-r , \-\-realtime= .RS 4 Collect data with this RT SCHED_FIFO priority. .RE .sp \-\-sym\-annotate= .RS 4 Annotate this symbol. .RE .sp \-K, \-\-hide_kernel_symbols .RS 4 Hide kernel symbols. .RE .sp \-U, \-\-hide_user_symbols .RS 4 Hide user symbols. .RE .sp \-\-demangle\-kernel .RS 4 Demangle kernel symbols. .RE .sp \-D, \-\-dump\-symtab .RS 4 Dump the symbol table used for profiling. .RE .sp \-v, \-\-verbose .RS 4 Be more verbose (show counter open errors, etc). .RE .sp \-z, \-\-zero .RS 4 Zero history across display updates. .RE .sp \-s, \-\-sort .RS 4 Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight, local_weight, abort, in_tx, transaction, overhead, sample, period. Please see description of \-\-sort in the perf\-report man page. .RE .sp \-\-fields= .RS 4 Specify output field \- multiple keys can be specified in CSV format. Following fields are available: overhead, overhead_sys, overhead_us, overhead_children, sample and period. Also it can contain any sort key(s). .sp .if n \{\ .RS 4 .\} .nf By default, every sort keys not specified in \-\-field will be appended automatically. .fi .if n \{\ .RE .\} .RE .sp \-n, \-\-show\-nr\-samples .RS 4 Show a column with the number of samples. .RE .sp \-\-show\-total\-period .RS 4 Show a column with the sum of periods. .RE .sp \-\-dsos .RS 4 Only consider symbols in these dsos. This option will affect the percentage of the overhead column. See \-\-percentage for more info. .RE .sp \-\-comms .RS 4 Only consider symbols in these comms. This option will affect the percentage of the overhead column. See \-\-percentage for more info. .RE .sp \-\-symbols .RS 4 Only consider these symbols. This option will affect the percentage of the overhead column. See \-\-percentage for more info. .RE .sp \-M, \-\-disassembler\-style= .RS 4 Set disassembler style for objdump. .RE .sp \-\-source .RS 4 Interleave source code with assembly code. Enabled by default, disable with \-\-no\-source. .RE .sp \-\-asm\-raw .RS 4 Show raw instruction encoding of assembly instructions. .RE .sp \-g .RS 4 Enables call\-graph (stack chain/backtrace) recording. .RE .sp \-\-call\-graph [mode,type,min[,limit],order[,key][,branch]] .RS 4 Setup and enable call\-graph (stack chain/backtrace) recording, implies \-g. See \f[CR]\-\-call\-graph\fP section in perf\-record and perf\-report man pages for details. .RE .sp \-\-children .RS 4 Accumulate callchain of children to parent entry so that then can show up in the output. The output will have a new "Children" column and will be sorted on the data. It requires \-g/\-\-call\-graph option enabled. See the \(oqoverhead calculation\(cq section for more details. Enabled by default, disable with \-\-no\-children. .RE .sp \-\-max\-stack .RS 4 Set the stack depth limit when parsing the callchain, anything beyond the specified depth will be ignored. This is a trade\-off between information loss and faster processing especially for workloads that can have a very long callchain stack. .sp .if n \{\ .RS 4 .\} .nf Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise. .fi .if n \{\ .RE .\} .RE .sp \-\-ignore\-callees= .RS 4 Ignore callees of the function(s) matching the given regex. This has the effect of collecting the callers of each such function into one place in the call\-graph tree. .RE .sp \-\-percent\-limit .RS 4 Do not show entries which have an overhead under that percent. (Default: 0). .RE .sp \-\-percentage .RS 4 Determine how to display the overhead percentage of filtered entries. Filters can be applied by \-\-comms, \-\-dsos and/or \-\-symbols options and Zoom operations on the TUI (thread, dso, etc). .sp .if n \{\ .RS 4 .\} .nf "relative" means it\(aqs relative to filtered entries only so that the sum of shown entries will be always 100%. "absolute" means it retains the original value before and after the filter is applied. .fi .if n \{\ .RE .\} .RE .sp \-w, \-\-column\-widths= .RS 4 Force each column width to the provided list, for large terminal readability. 0 means no limit (default behavior). .RE .sp \-\-proc\-map\-timeout .RS 4 When processing pre\-existing threads /proc/XXX/mmap, it may take a long time, because the file may be huge. A time out is needed in such cases. This option sets the time out limit. The default value is 500 ms. .RE .sp \-b, \-\-branch\-any .RS 4 Enable taken branch stack sampling. Any type of taken branch may be sampled. This is a shortcut for \-\-branch\-filter any. See \-\-branch\-filter for more infos. .RE .sp \-j, \-\-branch\-filter .RS 4 Enable taken branch stack sampling. Each sample captures a series of consecutive taken branches. The number of branches captured with each sample depends on the underlying hardware, the type of branches of interest, and the executed code. It is possible to select the types of branches captured by enabling filters. For a full list of modifiers please see the perf record manpage. .sp .if n \{\ .RS 4 .\} .nf The option requires at least one branch type among any, any_call, any_ret, ind_call, cond. The privilege levels may be omitted, in which case, the privilege levels of the associated event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege levels are subject to permissions. When sampling on multiple events, branch stack sampling is enabled for all the sampling events. The sampled branch type is the same for all events. The various filters must be specified as a comma separated list: \-\-branch\-filter any_ret,u,k Note that this feature may not be available on all processors. .fi .if n \{\ .RE .\} .RE .sp \-\-raw\-trace .RS 4 When displaying traceevent output, do not use print fmt or plugins. .RE .sp \-\-hierarchy .RS 4 Enable hierarchy output. .RE .sp \-\-force .RS 4 Don\(cqt do ownership validation. .RE .sp \-\-num\-thread\-synthesize .RS 4 The number of threads to run when synthesizing events for existing processes. By default, the number of threads equals to the number of online CPUs. .RE .SH "INTERACTIVE PROMPTING KEYS" .sp [d] .RS 4 Display refresh delay. .RE .sp [e] .RS 4 Number of entries to display. .RE .sp [E] .RS 4 Event to display when multiple counters are active. .RE .sp [f] .RS 4 Profile display filter (>= hit count). .RE .sp [F] .RS 4 Annotation display filter (>= % of total). .RE .sp [s] .RS 4 Annotate symbol. .RE .sp [S] .RS 4 Stop annotation, return to full profile display. .RE .sp [K] .RS 4 Hide kernel symbols. .RE .sp [U] .RS 4 Hide user symbols. .RE .sp [z] .RS 4 Toggle event count zeroing across display updates. .RE .sp [qQ] .RS 4 Quit. .RE .sp Pressing any unmapped key displays a menu, and prompts for input. .SH "OVERHEAD CALCULATION" .sp The overhead can be shown in two columns as \fIChildren\fP and \fISelf\fP when perf collects callchains. The \fIself\fP overhead is simply calculated by adding all period values of the entry \- usually a function (symbol). This is the value that perf shows traditionally and sum of all the \fIself\fP overhead values should be 100%. .sp The \fIchildren\fP overhead is calculated by adding all period values of the child functions so that it can show the total overhead of the higher level functions even if they don\(cqt directly execute much. \fIChildren\fP here means functions that are called from another (parent) function. .sp It might be confusing that the sum of all the \fIchildren\fP overhead values exceeds 100% since each of them is already an accumulation of \fIself\fP overhead of its child functions. But with this enabled, users can find which function has the most overhead even if samples are spread over the children. .sp Consider the following example; there are three functions like below. .sp .if n \{\ .RS 4 .\} .nf void foo(void) { /* do something */ } void bar(void) { /* do something */ foo(); } int main(void) { bar() return 0; } .fi .if n \{\ .RE .\} .sp In this case \fIfoo\fP is a child of \fIbar\fP, and \fIbar\fP is an immediate child of \fImain\fP so \fIfoo\fP also is a child of \fImain\fP. In other words, \fImain\fP is a parent of \fIfoo\fP and \fIbar\fP, and \fIbar\fP is a parent of \fIfoo\fP. .sp Suppose all samples are recorded in \fIfoo\fP and \fIbar\fP only. When it\(cqs recorded with callchains the output will show something like below in the usual (self\-overhead\-only) output of perf report: .sp .if n \{\ .RS 4 .\} .nf Overhead Symbol \&........ ..................... 60.00% foo | \-\-\- foo bar main __libc_start_main 40.00% bar | \-\-\- bar main __libc_start_main .fi .if n \{\ .RE .\} .sp When the \-\-children option is enabled, the \fIself\fP overhead values of child functions (i.e. \fIfoo\fP and \fIbar\fP) are added to the parents to calculate the \fIchildren\fP overhead. In this case the report could be displayed as: .sp .if n \{\ .RS 4 .\} .nf Children Self Symbol \&........ ........ .................... 100.00% 0.00% __libc_start_main | \-\-\- __libc_start_main 100.00% 0.00% main | \-\-\- main __libc_start_main 100.00% 40.00% bar | \-\-\- bar main __libc_start_main 60.00% 60.00% foo | \-\-\- foo bar main __libc_start_main .fi .if n \{\ .RE .\} .sp In the above output, the \fIself\fP overhead of \fIfoo\fP (60%) was add to the \fIchildren\fP overhead of \fIbar\fP, \fImain\fP and \fI_\(rs_libc_start_main\fP. Likewise, the \fIself\fP overhead of \fIbar\fP (40%) was added to the \fIchildren\fP overhead of \fImain\fP and \fI\(rs_\(rs_libc_start_main\fP. .sp So \fI\(rs_\(rs_libc_start_main\fP and \fImain\fP are shown first since they have same (100%) \fIchildren\fP overhead (even though they have zero \fIself\fP overhead) and they are the parents of \fIfoo\fP and \fIbar\fP. .sp Since v3.16 the \fIchildren\fP overhead is shown by default and the output is sorted by its values. The \fIchildren\fP overhead is disabled by specifying \-\-no\-children option on the command line or by adding \fIreport.children = false\fP or \fItop.children = false\fP in the perf config file. .SH "SEE ALSO" .sp perf\-stat(1), perf\-list(1), perf\-report(1)