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

PAGEFAULTS

233       When tracing pagefaults, the format of the trace is as follows:
234
235       <min|maj>fault [<ip.symbol>+<ip.offset>] ⇒ <addr.dso@addr.offset[1]>
236       (<map type><addr level>).
237
238       •   min/maj indicates whether fault event is minor or major;
239
240       •   ip.symbol shows symbol for instruction pointer (the code that
241           generated the fault); if no debug symbols available, perf trace
242           will print raw IP;
243
244       •   addr.dso shows DSO for the faulted address;
245
246       •   map type is either d for non-executable maps or x for executable
247           maps;
248
249       •   addr level is either k for kernel dso or .  for user dso.
250
251       For symbols resolution you may need to install debugging symbols.
252
253       Please be aware that duration is currently always 0 and doesn’t reflect
254       actual time it took for fault to be handled!
255
256       When --verbose specified, perf trace tries to print all available
257       information for both IP and fault address in the form of
258       dso@symbol[2]+offset.
259

EXAMPLES

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

SEE ALSO

338       perf-record(1), perf-script(1)
339

NOTES

341        1. addr.dso@addr.offset
342           mailto:addr.dso@addr.offset
343
344        2. dso@symbol
345           mailto:dso@symbol
346
347
348
349perf                              06/03/2021                     PERF-TRACE(1)
Impressum