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

NAME

6       perf-script - Read perf.data (created by perf record) and display trace
7       output
8

SYNOPSIS

10       perf script [<options>]
11       perf script [<options>] record <script> [<record-options>] <command>
12       perf script [<options>] report <script> [script-args]
13       perf script [<options>] <script> <required-script-args> [<record-options>] <command>
14       perf script [<options>] <top-script> [script-args]
15

DESCRIPTION

17       This command reads the input file and displays the trace recorded.
18
19       There are several variants of perf script:
20
21           'perf script' to see a detailed trace of the workload that was
22           recorded.
23
24           You can also run a set of pre-canned scripts that aggregate and
25           summarize the raw trace data in various ways (the list of scripts is
26           available via 'perf script -l').  The following variants allow you to
27           record and run those scripts:
28
29           'perf script record <script> <command>' to record the events required
30           for 'perf script report'.  <script> is the name displayed in the
31           output of 'perf script --list' i.e. the actual script name minus any
32           language extension.  If <command> is not specified, the events are
33           recorded using the -a (system-wide) 'perf record' option.
34
35           'perf script report <script> [args]' to run and display the results
36           of <script>.  <script> is the name displayed in the output of 'perf
37           script --list' i.e. the actual script name minus any language
38           extension.  The perf.data output from a previous run of 'perf script
39           record <script>' is used and should be present for this command to
40           succeed.  [args] refers to the (mainly optional) args expected by
41           the script.
42
43           'perf script <script> <required-script-args> <command>' to both
44           record the events required for <script> and to run the <script>
45           using 'live-mode' i.e. without writing anything to disk.  <script>
46           is the name displayed in the output of 'perf script --list' i.e. the
47           actual script name minus any language extension.  If <command> is
48           not specified, the events are recorded using the -a (system-wide)
49           'perf record' option.  If <script> has any required args, they
50           should be specified before <command>.  This mode doesn't allow for
51           optional script args to be specified; if optional script args are
52           desired, they can be specified using separate 'perf script record'
53           and 'perf script report' commands, with the stdout of the record step
54           piped to the stdin of the report script, using the '-o -' and '-i -'
55           options of the corresponding commands.
56
57           'perf script <top-script>' to both record the events required for
58           <top-script> and to run the <top-script> using 'live-mode'
59           i.e. without writing anything to disk.  <top-script> is the name
60           displayed in the output of 'perf script --list' i.e. the actual
61           script name minus any language extension; a <top-script> is defined
62           as any script name ending with the string 'top'.
63
64           [<record-options>] can be passed to the record steps of 'perf script
65           record' and 'live-mode' variants; this isn't possible however for
66           <top-script> 'live-mode' or 'perf script report' variants.
67
68           See the 'SEE ALSO' section for links to language-specific
69           information on how to write and run your own trace scripts.
70

OPTIONS

72       <command>...
73           Any command you can specify in a shell.
74
75       -D, --dump-raw-trace=
76           Display verbose dump of the trace data.
77
78       -L, --Latency=
79           Show latency attributes (irqs/preemption disabled, etc).
80
81       -l, --list=
82           Display a list of available trace scripts.
83
84       -s [lang], --script=
85           Process trace data with the given script ([lang]:script[.ext]). If
86           the string lang is specified in place of a script name, a list of
87           supported languages will be displayed instead.
88
89       -g, --gen-script=
90           Generate perf-script.[ext] starter script for given language, using
91           current perf.data.
92
93       -a
94           Force system-wide collection. Scripts run without a <command>
95           normally use -a by default, while scripts run with a <command>
96           normally don’t - this option allows the latter to be run in
97           system-wide mode.
98
99       -i, --input=
100           Input file name. (default: perf.data unless stdin is a fifo)
101
102       -d, --debug-mode
103           Do various checks like samples ordering and lost events.
104
105       -F, --fields
106           Comma separated list of fields to print. Options are: comm, tid,
107           pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline,
108           period, iregs, uregs, brstack, brstacksym, flags, brstackinsn,
109           brstackoff, insn, insnlen, synth, phys_addr. Field list can be
110           prepended with the type, trace, sw or hw, to indicate to which
111           event type the field list applies. e.g., -F sw:comm,tid,time,ip,sym
112           and -F trace:time,cpu,trace
113
114               perf script -F <fields>
115
116               is equivalent to:
117
118               perf script -F trace:<fields> -F sw:<fields> -F hw:<fields>
119
120               i.e., the specified fields apply to all event types if the type string
121               is not given.
122
123               In addition to overriding fields, it is also possible to add or remove
124               fields from the defaults. For example
125
126               -F -cpu,+insn
127
128               removes the cpu field and adds the insn field. Adding/removing fields
129               cannot be mixed with normal overriding.
130
131               The arguments are processed in the order received. A later usage can
132               reset a prior request. e.g.:
133
134               -F trace: -F comm,tid,time,ip,sym
135
136               The first -F suppresses trace events (field list is ""), but then the
137               second invocation sets the fields to comm,tid,time,ip,sym. In this case a
138               warning is given to the user:
139
140               "Overriding previous field request for all events."
141
142               Alternatively, consider the order:
143
144               -F comm,tid,time,ip,sym -F trace:
145
146               The first -F sets the fields for all events and the second -F
147               suppresses trace events. The user is given a warning message about
148               the override, and the result of the above is that only S/W and H/W
149               events are displayed with the given fields.
150
151               For the 'wildcard' option if a user selected field is invalid for an
152               event type, a message is displayed to the user that the option is
153               ignored for that type. For example:
154
155               $ perf script -F comm,tid,trace
156               'trace' not valid for hardware events. Ignoring.
157               'trace' not valid for software events. Ignoring.
158
159               Alternatively, if the type is given an invalid field is specified it
160               is an error. For example:
161
162               perf script -v -F sw:comm,tid,trace
163               'trace' not valid for software events.
164
165               At this point usage is displayed, and perf-script exits.
166
167               The flags field is synthesized and may have a value when Instruction
168               Trace decoding. The flags are "bcrosyiABEx" which stand for branch,
169               call, return, conditional, system, asynchronous, interrupt,
170               transaction abort, trace begin, trace end, and in transaction,
171               respectively. Known combinations of flags are printed more nicely e.g.
172               "call" for "bc", "return" for "br", "jcc" for "bo", "jmp" for "b",
173               "int" for "bci", "iret" for "bri", "syscall" for "bcs", "sysret" for "brs",
174               "async" for "by", "hw int" for "bcyi", "tx abrt" for "bA", "tr strt" for "bB",
175               "tr end" for "bE". However the "x" flag will be display separately in those
176               cases e.g. "jcc     (x)" for a condition branch within a transaction.
177
178               The callindent field is synthesized and may have a value when
179               Instruction Trace decoding. For calls and returns, it will display the
180               name of the symbol indented with spaces to reflect the stack depth.
181
182               When doing instruction trace decoding insn and insnlen give the
183               instruction bytes and the instruction length of the current
184               instruction.
185
186               The synth field is used by synthesized events which may be created when
187               Instruction Trace decoding.
188
189               Finally, a user may not set fields to none for all event types.
190               i.e., -F "" is not allowed.
191
192               The brstack output includes branch related information with raw addresses using the
193               /v/v/v/v/cycles syntax in the following order:
194               FROM: branch source instruction
195               TO  : branch target instruction
196               M/P/-: M=branch target mispredicted or branch direction was mispredicted, P=target predicted or direction predicted, -=not supported
197               X/- : X=branch inside a transactional region, -=not in transaction region or not supported
198               A/- : A=TSX abort entry, -=not aborted region or not supported
199               cycles
200
201               The brstacksym is identical to brstack, except that the FROM and TO addresses are printed in a symbolic form if possible.
202
203               When brstackinsn is specified the full assembler sequences of branch sequences for each sample
204               is printed. This is the full execution path leading to the sample. This is only supported when the
205               sample was recorded with perf record -b or -j any.
206
207               The brstackoff field will print an offset into a specific dso/binary.
208
209       -k, --vmlinux=<file>
210           vmlinux pathname
211
212       --kallsyms=<file>
213           kallsyms pathname
214
215       --symfs=<directory>
216           Look for files with symbols relative to this directory.
217
218       -G, --hide-call-graph
219           When printing symbols do not display call chain.
220
221       --stop-bt
222           Stop display of callgraph at these symbols
223
224       -C, --cpu
225           Only report samples for the list of CPUs provided. Multiple CPUs
226           can be provided as a comma-separated list with no space: 0,1.
227           Ranges of CPUs are specified with -: 0-2. Default is to report
228           samples on all CPUs.
229
230       -c, --comms=
231           Only display events for these comms. CSV that understands
232           file://filename entries.
233
234       --pid=
235           Only show events for given process ID (comma separated list).
236
237       --tid=
238           Only show events for given thread ID (comma separated list).
239
240       -I, --show-info
241           Display extended information about the perf.data file. This adds
242           information which may be very large and thus may clutter the
243           display. It currently includes: cpu and numa topology of the host
244           system. It can only be used with the perf script report mode.
245
246       --show-kernel-path
247           Try to resolve the path of [kernel.kallsyms]
248
249       --show-task-events Display task related events (e.g. FORK, COMM, EXIT).
250
251       --show-mmap-events Display mmap related events (e.g. MMAP, MMAP2).
252
253       --show-switch-events Display context switch events i.e. events of type
254       PERF_RECORD_SWITCH or PERF_RECORD_SWITCH_CPU_WIDE.
255
256       --demangle
257           Demangle symbol names to human readable form. It’s enabled by
258           default, disable with --no-demangle.
259
260       --demangle-kernel
261           Demangle kernel symbol names to human readable form (for C++
262           kernels).
263
264       --header Show perf.data header.
265
266       --header-only Show only perf.data header.
267
268       --itrace
269           Options for decoding instruction tracing data. The options are:
270
271               i       synthesize instructions events
272               b       synthesize branches events
273               c       synthesize branches events (calls only)
274               r       synthesize branches events (returns only)
275               x       synthesize transactions events
276               w       synthesize ptwrite events
277               p       synthesize power events
278               e       synthesize error events
279               d       create a debug log
280               g       synthesize a call chain (use with i or x)
281               l       synthesize last branch entries (use with i or x)
282               s       skip initial number of events
283
284               The default is all events i.e. the same as --itrace=ibxwpe
285
286               In addition, the period (default 100000) for instructions events
287               can be specified in units of:
288
289               i       instructions
290               t       ticks
291               ms      milliseconds
292               us      microseconds
293               ns      nanoseconds (default)
294
295               Also the call chain size (default 16, max. 1024) for instructions or
296               transactions events can be specified.
297
298               Also the number of last branch entries (default 64, max. 1024) for
299               instructions or transactions events can be specified.
300
301               It is also possible to skip events generated (instructions, branches, transactions,
302               ptwrite, power) at the beginning. This is useful to ignore initialization code.
303
304               --itrace=i0nss1000000
305
306               skips the first million instructions.
307
308               To disable decoding entirely, use --no-itrace.
309
310       --full-source-path
311           Show the full path for source files for srcline output.
312
313       --max-stack
314           Set the stack depth limit when parsing the callchain, anything
315           beyond the specified depth will be ignored. This is a trade-off
316           between information loss and faster processing especially for
317           workloads that can have a very long callchain stack. Note that when
318           using the --itrace option the synthesized callchain size will
319           override this value if the synthesized callchain size is bigger.
320
321               Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise.
322
323       --ns
324           Use 9 decimal places when displaying time (i.e. show the
325           nanoseconds)
326
327       -f, --force
328           Don’t do ownership validation.
329
330       --time
331           Only analyze samples within given time window: <start>,<stop>.
332           Times have the format seconds.microseconds. If start is not given
333           (i.e., time string is ,x.y) then analysis starts at the beginning
334           of the file. If stop time is not given (i.e, time string is x.y,)
335           then analysis goes to end of file.
336
337       --max-blocks
338           Set the maximum number of program blocks to print with brstackasm
339           for each sample.
340
341       --per-event-dump
342           Create per event files with a "perf.data.EVENT.dump" name instead
343           of printing to stdout, useful, for instance, for generating
344           flamegraphs.
345
346       --inline
347           If a callgraph address belongs to an inlined function, the inline
348           stack will be printed. Each entry has function name and file/line.
349           Enabled by default, disable with --no-inline.
350

SEE ALSO

352       perf-record(1), perf-script-perl(1), perf-script-python(1)
353
354
355
356perf                              06/18/2019                    PERF-SCRIPT(1)
Impressum