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

NAME

6       perf-trace - strace inspired tool
7

SYNOPSIS

9       perf trace
10       perf trace record
11

DESCRIPTION

13       This command will show the events associated with the target, initially
14       syscalls, but other system events like pagefaults, task lifetime
15       events, scheduling events, etc.
16
17       This is a live mode tool in addition to working with perf.data files
18       like the other perf tools. Files can be generated using the perf record
19       command but the session needs to include the raw_syscalls events (-e
20       raw_syscalls:*). Alternatively, perf trace record can be used as a
21       shortcut to automatically include the raw_syscalls events when writing
22       events to a file.
23
24       The following options apply to perf trace; options to perf trace record
25       are found in the perf record man page.
26

OPTIONS

28       -a, --all-cpus
29           System-wide collection from all CPUs.
30
31       -e, --expr, --event
32           List of syscalls and other perf events (tracepoints, HW cache
33           events, etc) to show. Globbing is supported, e.g.: "epoll_*",
34           "msg", etc. See perf list for a complete list of events. Prefixing
35           with ! shows all syscalls but the ones specified. You may need to
36           escape it.
37
38       -D msecs, --delay msecs
39           After starting the program, wait msecs before measuring. This is
40           useful to filter out the startup phase of the program, which is
41           often very different.
42
43       -o, --output=
44           Output file name.
45
46       -p, --pid=
47           Record events on existing process ID (comma separated list).
48
49       -t, --tid=
50           Record events on existing thread ID (comma separated list).
51
52       -u, --uid=
53           Record events in threads owned by uid. Name or number.
54
55       -G, --cgroup
56           Record events in threads in a cgroup.
57
58               Look for cgroups to set at the /sys/fs/cgroup/perf_event directory, then
59               remove the /sys/fs/cgroup/perf_event/ part and try:
60
61               perf trace -G A -e sched:*switch
62
63               Will set all raw_syscalls:sys_{enter,exit}, pgfault, vfs_getname, etc
64               _and_ sched:sched_switch to the 'A' cgroup, while:
65
66               perf trace -e sched:*switch -G A
67
68               will only set the sched:sched_switch event to the 'A' cgroup, all the
69               other events (raw_syscalls:sys_{enter,exit}, etc are left "without"
70               a cgroup (on the root cgroup, sys wide, etc).
71
72               Multiple cgroups:
73
74               perf trace -G A -e sched:*switch -G B
75
76               the syscall ones go to the 'A' cgroup, the sched:sched_switch goes
77               to the 'B' cgroup.
78
79       --filter-pids=
80           Filter out events for these pids and for trace itself (comma
81           separated list).
82
83       -v, --verbose=
84           Verbosity level.
85
86       --no-inherit
87           Child tasks do not inherit counters.
88
89       -m, --mmap-pages=
90           Number of mmap data pages (must be a power of two) or size
91           specification with appended unit character - B/K/M/G. The size is
92           rounded up to have nearest pages power of two value.
93
94       -C, --cpu
95           Collect samples only on the list of CPUs provided. Multiple CPUs
96           can be provided as a comma-separated list with no space: 0,1.
97           Ranges of CPUs are specified with -: 0-2. In per-thread mode with
98           inheritance mode on (default), Events are captured only when the
99           thread executes on the designated CPUs. Default is to monitor all
100           CPUs.
101
102       --duration
103           Show only events that had a duration greater than N.M ms.
104
105       --sched
106           Accrue thread runtime and provide a summary at the end of the
107           session.
108
109       --failure
110           Show only syscalls that failed, i.e. that returned < 0.
111
112       -i, --input
113           Process events from a given perf data file.
114
115       -T, --time
116           Print full timestamp rather time relative to first sample.
117
118       --comm
119           Show process COMM right beside its ID, on by default, disable with
120           --no-comm.
121
122       -s, --summary
123           Show only a summary of syscalls by thread with min, max, and
124           average times (in msec) and relative stddev.
125
126       -S, --with-summary
127           Show all syscalls followed by a summary by thread with min, max,
128           and average times (in msec) and relative stddev.
129
130       --tool_stats
131           Show tool stats such as number of times fd→pathname was discovered
132           thru hooking the open syscall return + vfs_getname or via reading
133           /proc/pid/fd, etc.
134
135       -f, --force
136           Don’t complain, do it.
137
138       -F=[all|min|maj], --pf=[all|min|maj]
139           Trace pagefaults. Optionally, you can specify whether you want
140           minor, major or all pagefaults. Default value is maj.
141
142       --syscalls
143           Trace system calls. This options is enabled by default, disable
144           with --no-syscalls.
145
146       --call-graph [mode,type,min[,limit],order[,key][,branch]]
147           Setup and enable call-graph (stack chain/backtrace) recording. See
148           --call-graph section in perf-record and perf-report man pages for
149           details. The ones that are most useful in perf trace are dwarf and
150           lbr, where available, try: perf trace --call-graph dwarf.
151
152               Using this will, for the root user, bump the value of --mmap-pages to 4
153               times the maximum for non-root users, based on the kernel.perf_event_mlock_kb
154               sysctl. This is done only if the user doesn't specify a --mmap-pages value.
155
156       --kernel-syscall-graph
157           Show the kernel callchains on the syscall exit path.
158
159       --max-events=N
160           Stop after processing N events. Note that strace-like events are
161           considered only at exit time or when a syscall is interrupted, i.e.
162           in those cases this option is equivalent to the number of lines
163           printed.
164
165       --max-stack
166           Set the stack depth limit when parsing the callchain, anything
167           beyond the specified depth will be ignored. Note that at this point
168           this is just about the presentation part, i.e. the kernel is still
169           not limiting, the overhead of callchains needs to be set via the
170           knobs in --call-graph dwarf.
171
172               Implies '--call-graph dwarf' when --call-graph not present on the
173               command line, on systems where DWARF unwinding was built in.
174
175               Default: /proc/sys/kernel/perf_event_max_stack when present for
176                        live sessions (without --input/-i), 127 otherwise.
177
178       --min-stack
179           Set the stack depth limit when parsing the callchain, anything
180           below the specified depth will be ignored. Disabled by default.
181
182               Implies '--call-graph dwarf' when --call-graph not present on the
183               command line, on systems where DWARF unwinding was built in.
184
185       --print-sample
186           Print the PERF_RECORD_SAMPLE PERF_SAMPLE_ info for the
187           raw_syscalls:sys_{enter,exit} tracepoints, for debugging.
188
189       --proc-map-timeout
190           When processing pre-existing threads /proc/XXX/mmap, it may take a
191           long time, because the file may be huge. A time out is needed in
192           such cases. This option sets the time out limit. The default value
193           is 500 ms.
194
195       --sort-events
196           Do sorting on batches of events, use when noticing out of order
197           events that may happen, for instance, when a thread gets migrated
198           to a different CPU while processing a syscall.
199
200       --map-dump
201           Dump BPF maps setup by events passed via -e, for instance the
202           augmented_raw_syscalls living in
203           tools/perf/examples/bpf/augmented_raw_syscalls.c. For now this
204           dumps just boolean map values and integer keys, in time this will
205           print in hex by default and use BTF when available, as well as use
206           functions to do pretty printing using the existing perf trace
207           syscall arg beautifiers to map integer arguments to strings (pid to
208           comm, syscall id to syscall name, etc).
209

PAGEFAULTS

211       When tracing pagefaults, the format of the trace is as follows:
212
213       <min|maj>fault [<ip.symbol>+<ip.offset>] ⇒ <addr.dso@addr.offset[1]>
214       (<map type><addr level>).
215
216       ·   min/maj indicates whether fault event is minor or major;
217
218       ·   ip.symbol shows symbol for instruction pointer (the code that
219           generated the fault); if no debug symbols available, perf trace
220           will print raw IP;
221
222       ·   addr.dso shows DSO for the faulted address;
223
224       ·   map type is either d for non-executable maps or x for executable
225           maps;
226
227       ·   addr level is either k for kernel dso or .  for user dso.
228
229       For symbols resolution you may need to install debugging symbols.
230
231       Please be aware that duration is currently always 0 and doesn’t reflect
232       actual time it took for fault to be handled!
233
234       When --verbose specified, perf trace tries to print all available
235       information for both IP and fault address in the form of
236       dso@symbol[2]+offset.
237

EXAMPLES

239       Trace only major pagefaults:
240
241           $ perf trace --no-syscalls -F
242
243       Trace syscalls, major and minor pagefaults:
244
245           $ perf trace -F all
246
247           1416.547 ( 0.000 ms): python/20235 majfault [CRYPTO_push_info_+0x0] => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0@0x61be0 (x.)
248
249           As you can see, there was major pagefault in python process, from
250           CRYPTO_push_info_ routine which faulted somewhere in libcrypto.so.
251
252       Trace the first 4 open, openat or open_by_handle_at syscalls (in the
253       future more syscalls may match here):
254
255           $ perf trace -e open* --max-events 4
256           [root@jouet perf]# trace -e open* --max-events 4
257           2272.992 ( 0.037 ms): gnome-shell/1370 openat(dfd: CWD, filename: /proc/self/stat) = 31
258           2277.481 ( 0.139 ms): gnome-shell/3039 openat(dfd: CWD, filename: /proc/self/stat) = 65
259           3026.398 ( 0.076 ms): gnome-shell/3039 openat(dfd: CWD, filename: /proc/self/stat) = 65
260           4294.665 ( 0.015 ms): sed/15879 openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC) = 3
261           $
262
263       Trace the first minor page fault when running a workload:
264
265           # perf trace -F min --max-stack=7 --max-events 1 sleep 1
266              0.000 ( 0.000 ms): sleep/18006 minfault [__clear_user+0x1a] => 0x5626efa56080 (?k)
267                                                __clear_user ([kernel.kallsyms])
268                                                load_elf_binary ([kernel.kallsyms])
269                                                search_binary_handler ([kernel.kallsyms])
270                                                __do_execve_file.isra.33 ([kernel.kallsyms])
271                                                __x64_sys_execve ([kernel.kallsyms])
272                                                do_syscall_64 ([kernel.kallsyms])
273                                                entry_SYSCALL_64 ([kernel.kallsyms])
274           #
275
276       Trace the next min page page fault to take place on the first CPU:
277
278           # perf trace -F min --call-graph=dwarf --max-events 1 --cpu 0
279              0.000 ( 0.000 ms): Web Content/17136 minfault [js::gc::Chunk::fetchNextDecommittedArena+0x4b] => 0x7fbe6181b000 (?.)
280                                                js::gc::FreeSpan::initAsEmpty (inlined)
281                                                js::gc::Arena::setAsNotAllocated (inlined)
282                                                js::gc::Chunk::fetchNextDecommittedArena (/usr/lib64/firefox/libxul.so)
283                                                js::gc::Chunk::allocateArena (/usr/lib64/firefox/libxul.so)
284                                                js::gc::GCRuntime::allocateArena (/usr/lib64/firefox/libxul.so)
285                                                js::gc::ArenaLists::allocateFromArena (/usr/lib64/firefox/libxul.so)
286                                                js::gc::GCRuntime::tryNewTenuredThing<JSString, (js::AllowGC)1> (inlined)
287                                                js::AllocateString<JSString, (js::AllowGC)1> (/usr/lib64/firefox/libxul.so)
288                                                js::Allocate<JSThinInlineString, (js::AllowGC)1> (inlined)
289                                                JSThinInlineString::new_<(js::AllowGC)1> (inlined)
290                                                AllocateInlineString<(js::AllowGC)1, unsigned char> (inlined)
291                                                js::ConcatStrings<(js::AllowGC)1> (/usr/lib64/firefox/libxul.so)
292                                                [0x18b26e6bc2bd] (/tmp/perf-17136.map)
293           #
294
295       Trace the next two sched:sched_switch events, four block:*_plug events,
296       the next block:*_unplug and the next three net:*dev_queue events, this
297       last one with a backtrace of at most 16 entries, system wide:
298
299           # perf trace -e sched:*switch/nr=2/,block:*_plug/nr=4/,block:*_unplug/nr=1/,net:*dev_queue/nr=3,max-stack=16/
300              0.000 :0/0 sched:sched_switch:swapper/2:0 [120] S ==> rcu_sched:10 [120]
301              0.015 rcu_sched/10 sched:sched_switch:rcu_sched:10 [120] R ==> swapper/2:0 [120]
302            254.198 irq/50-iwlwifi/680 net:net_dev_queue:dev=wlp3s0 skbaddr=0xffff93498051f600 len=66
303                                                __dev_queue_xmit ([kernel.kallsyms])
304            273.977 :0/0 net:net_dev_queue:dev=wlp3s0 skbaddr=0xffff93498051f600 len=78
305                                                __dev_queue_xmit ([kernel.kallsyms])
306            274.007 :0/0 net:net_dev_queue:dev=wlp3s0 skbaddr=0xffff93498051ff00 len=78
307                                                __dev_queue_xmit ([kernel.kallsyms])
308           2930.140 kworker/u16:58/2722 block:block_plug:[kworker/u16:58]
309           2930.162 kworker/u16:58/2722 block:block_unplug:[kworker/u16:58] 1
310           4466.094 jbd2/dm-2-8/748 block:block_plug:[jbd2/dm-2-8]
311           8050.123 kworker/u16:30/2694 block:block_plug:[kworker/u16:30]
312           8050.271 kworker/u16:30/2694 block:block_plug:[kworker/u16:30]
313           #
314

SEE ALSO

316       perf-record(1), perf-script(1)
317

NOTES

319        1. addr.dso@addr.offset
320           mailto:addr.dso@addr.offset
321
322        2. dso@symbol
323           mailto:dso@symbol
324
325
326
327perf                              11/12/2019                     PERF-TRACE(1)
Impressum