xref: /linux/tools/perf/Documentation/perf-trace.txt (revision 9d9cad763ca79dd3697e9f2d1df648e37496582b)
1514f1c67SArnaldo Carvalho de Meloperf-trace(1)
2514f1c67SArnaldo Carvalho de Melo=============
3514f1c67SArnaldo Carvalho de Melo
4514f1c67SArnaldo Carvalho de MeloNAME
5514f1c67SArnaldo Carvalho de Melo----
6514f1c67SArnaldo Carvalho de Meloperf-trace - strace inspired tool
7514f1c67SArnaldo Carvalho de Melo
8514f1c67SArnaldo Carvalho de MeloSYNOPSIS
9514f1c67SArnaldo Carvalho de Melo--------
10514f1c67SArnaldo Carvalho de Melo[verse]
11514f1c67SArnaldo Carvalho de Melo'perf trace'
125e2485b1SDavid Ahern'perf trace record'
13514f1c67SArnaldo Carvalho de Melo
14514f1c67SArnaldo Carvalho de MeloDESCRIPTION
15514f1c67SArnaldo Carvalho de Melo-----------
16514f1c67SArnaldo Carvalho de MeloThis command will show the events associated with the target, initially
17514f1c67SArnaldo Carvalho de Melosyscalls, but other system events like pagefaults, task lifetime events,
18514f1c67SArnaldo Carvalho de Meloscheduling events, etc.
19514f1c67SArnaldo Carvalho de Melo
205e2485b1SDavid AhernThis is a live mode tool in addition to working with perf.data files like
215e2485b1SDavid Ahernthe other perf tools. Files can be generated using the 'perf record' command
225e2485b1SDavid Ahernbut the session needs to include the raw_syscalls events (-e 'raw_syscalls:*').
2396355f2cSMasanari IidaAlternatively, 'perf trace record' can be used as a shortcut to
245e2485b1SDavid Ahernautomatically include the raw_syscalls events when writing events to a file.
255e2485b1SDavid Ahern
265e2485b1SDavid AhernThe following options apply to perf trace; options to perf trace record are
275e2485b1SDavid Ahernfound in the perf record man page.
28514f1c67SArnaldo Carvalho de Melo
29514f1c67SArnaldo Carvalho de MeloOPTIONS
30514f1c67SArnaldo Carvalho de Melo-------
31514f1c67SArnaldo Carvalho de Melo
32ac9be8eeSDavid Ahern-a::
33514f1c67SArnaldo Carvalho de Melo--all-cpus::
34514f1c67SArnaldo Carvalho de Melo        System-wide collection from all CPUs.
35514f1c67SArnaldo Carvalho de Melo
362ae3a312SArnaldo Carvalho de Melo-e::
372ae3a312SArnaldo Carvalho de Melo--expr::
38d303e85aSArnaldo Carvalho de Melo	List of syscalls to show, currently only syscall names.
39b059efdfSArnaldo Carvalho de Melo	Prefixing with ! shows all syscalls but the ones specified.  You may
40b059efdfSArnaldo Carvalho de Melo	need to escape it.
412ae3a312SArnaldo Carvalho de Melo
42c24ff998SArnaldo Carvalho de Melo-o::
43c24ff998SArnaldo Carvalho de Melo--output=::
44c24ff998SArnaldo Carvalho de Melo	Output file name.
45c24ff998SArnaldo Carvalho de Melo
46514f1c67SArnaldo Carvalho de Melo-p::
47514f1c67SArnaldo Carvalho de Melo--pid=::
48514f1c67SArnaldo Carvalho de Melo	Record events on existing process ID (comma separated list).
49514f1c67SArnaldo Carvalho de Melo
50ac9be8eeSDavid Ahern-t::
51514f1c67SArnaldo Carvalho de Melo--tid=::
52514f1c67SArnaldo Carvalho de Melo        Record events on existing thread ID (comma separated list).
53514f1c67SArnaldo Carvalho de Melo
54ac9be8eeSDavid Ahern-u::
55514f1c67SArnaldo Carvalho de Melo--uid=::
56514f1c67SArnaldo Carvalho de Melo        Record events in threads owned by uid. Name or number.
57514f1c67SArnaldo Carvalho de Melo
58f078c385SArnaldo Carvalho de Melo--filter-pids=::
59f078c385SArnaldo Carvalho de Melo	Filter out events for these pids and for 'trace' itself (comma separated list).
60f078c385SArnaldo Carvalho de Melo
617c304ee0SArnaldo Carvalho de Melo-v::
627c304ee0SArnaldo Carvalho de Melo--verbose=::
637c304ee0SArnaldo Carvalho de Melo        Verbosity level.
647c304ee0SArnaldo Carvalho de Melo
65ac9be8eeSDavid Ahern-i::
66514f1c67SArnaldo Carvalho de Melo--no-inherit::
67514f1c67SArnaldo Carvalho de Melo	Child tasks do not inherit counters.
68514f1c67SArnaldo Carvalho de Melo
69ac9be8eeSDavid Ahern-m::
70514f1c67SArnaldo Carvalho de Melo--mmap-pages=::
7127050f53SJiri Olsa	Number of mmap data pages (must be a power of two) or size
7227050f53SJiri Olsa	specification with appended unit character - B/K/M/G. The
7327050f53SJiri Olsa	size is rounded up to have nearest pages power of two value.
74514f1c67SArnaldo Carvalho de Melo
75ac9be8eeSDavid Ahern-C::
76514f1c67SArnaldo Carvalho de Melo--cpu::
77514f1c67SArnaldo Carvalho de MeloCollect samples only on the list of CPUs provided. Multiple CPUs can be provided as a
78514f1c67SArnaldo Carvalho de Melocomma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
79514f1c67SArnaldo Carvalho de MeloIn per-thread mode with inheritance mode on (default), Events are captured only when
80514f1c67SArnaldo Carvalho de Melothe thread executes on the designated CPUs. Default is to monitor all CPUs.
81514f1c67SArnaldo Carvalho de Melo
82ae9ed035SArnaldo Carvalho de Melo--duration:
83ae9ed035SArnaldo Carvalho de Melo	Show only events that had a duration greater than N.M ms.
84ae9ed035SArnaldo Carvalho de Melo
851302d88eSArnaldo Carvalho de Melo--sched:
861302d88eSArnaldo Carvalho de Melo	Accrue thread runtime and provide a summary at the end of the session.
871302d88eSArnaldo Carvalho de Melo
886810fc91SDavid Ahern-i
896810fc91SDavid Ahern--input
906810fc91SDavid Ahern	Process events from a given perf data file.
916810fc91SDavid Ahern
924bb09192SDavid Ahern-T
934bb09192SDavid Ahern--time
944bb09192SDavid Ahern	Print full timestamp rather time relative to first sample.
954bb09192SDavid Ahern
9650c95cbdSArnaldo Carvalho de Melo--comm::
9750c95cbdSArnaldo Carvalho de Melo        Show process COMM right beside its ID, on by default, disable with --no-comm.
9850c95cbdSArnaldo Carvalho de Melo
99fd2eabafSDavid Ahern-s::
100bf2575c1SDavid Ahern--summary::
101fd2eabafSDavid Ahern	Show only a summary of syscalls by thread with min, max, and average times
102fd2eabafSDavid Ahern    (in msec) and relative stddev.
103fd2eabafSDavid Ahern
104fd2eabafSDavid Ahern-S::
105fd2eabafSDavid Ahern--with-summary::
106fd2eabafSDavid Ahern	Show all syscalls followed by a summary by thread with min, max, and
107fd2eabafSDavid Ahern    average times (in msec) and relative stddev.
108bf2575c1SDavid Ahern
109c522739dSArnaldo Carvalho de Melo--tool_stats::
110c522739dSArnaldo Carvalho de Melo	Show tool stats such as number of times fd->pathname was discovered thru
111c522739dSArnaldo Carvalho de Melo	hooking the open syscall return + vfs_getname or via reading /proc/pid/fd, etc.
112c522739dSArnaldo Carvalho de Melo
113598d02c5SStanislav Fomichev-F=[all|min|maj]::
114598d02c5SStanislav Fomichev--pf=[all|min|maj]::
115598d02c5SStanislav Fomichev	Trace pagefaults. Optionally, you can specify whether you want minor,
116598d02c5SStanislav Fomichev	major or all pagefaults. Default value is maj.
117598d02c5SStanislav Fomichev
118e281a960SStanislav Fomichev--syscalls::
119e281a960SStanislav Fomichev	Trace system calls. This options is enabled by default.
120e281a960SStanislav Fomichev
12177c92582SArnaldo Carvalho de Melo--event::
12277c92582SArnaldo Carvalho de Melo	Trace other events, see 'perf list' for a complete list.
12377c92582SArnaldo Carvalho de Melo
124*9d9cad76SKan Liang--proc-map-timeout::
125*9d9cad76SKan Liang	When processing pre-existing threads /proc/XXX/mmap, it may take a long time,
126*9d9cad76SKan Liang	because the file may be huge. A time out is needed in such cases.
127*9d9cad76SKan Liang	This option sets the time out limit. The default value is 500 ms.
128*9d9cad76SKan Liang
129598d02c5SStanislav FomichevPAGEFAULTS
130598d02c5SStanislav Fomichev----------
131598d02c5SStanislav Fomichev
132598d02c5SStanislav FomichevWhen tracing pagefaults, the format of the trace is as follows:
133598d02c5SStanislav Fomichev
134598d02c5SStanislav Fomichev<min|maj>fault [<ip.symbol>+<ip.offset>] => <addr.dso@addr.offset> (<map type><addr level>).
135598d02c5SStanislav Fomichev
136598d02c5SStanislav Fomichev- min/maj indicates whether fault event is minor or major;
137598d02c5SStanislav Fomichev- ip.symbol shows symbol for instruction pointer (the code that generated the
138598d02c5SStanislav Fomichev  fault); if no debug symbols available, perf trace will print raw IP;
139598d02c5SStanislav Fomichev- addr.dso shows DSO for the faulted address;
140598d02c5SStanislav Fomichev- map type is either 'd' for non-executable maps or 'x' for executable maps;
141598d02c5SStanislav Fomichev- addr level is either 'k' for kernel dso or '.' for user dso.
142598d02c5SStanislav Fomichev
143598d02c5SStanislav FomichevFor symbols resolution you may need to install debugging symbols.
144598d02c5SStanislav Fomichev
145598d02c5SStanislav FomichevPlease be aware that duration is currently always 0 and doesn't reflect actual
146598d02c5SStanislav Fomichevtime it took for fault to be handled!
147598d02c5SStanislav Fomichev
148598d02c5SStanislav FomichevWhen --verbose specified, perf trace tries to print all available information
149598d02c5SStanislav Fomichevfor both IP and fault address in the form of dso@symbol+offset.
150598d02c5SStanislav Fomichev
151598d02c5SStanislav FomichevEXAMPLES
152598d02c5SStanislav Fomichev--------
153598d02c5SStanislav Fomichev
154e281a960SStanislav FomichevTrace only major pagefaults:
155e281a960SStanislav Fomichev
156e281a960SStanislav Fomichev $ perf trace --no-syscalls -F
157e281a960SStanislav Fomichev
158598d02c5SStanislav FomichevTrace syscalls, major and minor pagefaults:
159598d02c5SStanislav Fomichev
160598d02c5SStanislav Fomichev $ perf trace -F all
161598d02c5SStanislav Fomichev
162598d02c5SStanislav Fomichev  1416.547 ( 0.000 ms): python/20235 majfault [CRYPTO_push_info_+0x0] => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0@0x61be0 (x.)
163598d02c5SStanislav Fomichev
164598d02c5SStanislav Fomichev  As you can see, there was major pagefault in python process, from
165598d02c5SStanislav Fomichev  CRYPTO_push_info_ routine which faulted somewhere in libcrypto.so.
166598d02c5SStanislav Fomichev
167514f1c67SArnaldo Carvalho de MeloSEE ALSO
168514f1c67SArnaldo Carvalho de Melo--------
169514f1c67SArnaldo Carvalho de Melolinkperf:perf-record[1], linkperf:perf-script[1]
170