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, bpf-output,
109           brstackinsn, brstackoff, callindent, insn, insnlen, synth,
110           phys_addr, metric, misc, srccode, ipc, data_page_size,
111           code_page_size. Field list can be prepended with the type, trace,
112           sw or hw, to indicate to which event type the field list applies.
113           e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace
114
115               perf script -F <fields>
116
117               is equivalent to:
118
119               perf script -F trace:<fields> -F sw:<fields> -F hw:<fields>
120
121               i.e., the specified fields apply to all event types if the type string
122               is not given.
123
124               In addition to overriding fields, it is also possible to add or remove
125               fields from the defaults. For example
126
127               -F -cpu,+insn
128
129               removes the cpu field and adds the insn field. Adding/removing fields
130               cannot be mixed with normal overriding.
131
132               The arguments are processed in the order received. A later usage can
133               reset a prior request. e.g.:
134
135               -F trace: -F comm,tid,time,ip,sym
136
137               The first -F suppresses trace events (field list is ""), but then the
138               second invocation sets the fields to comm,tid,time,ip,sym. In this case a
139               warning is given to the user:
140
141               "Overriding previous field request for all events."
142
143               Alternatively, consider the order:
144
145               -F comm,tid,time,ip,sym -F trace:
146
147               The first -F sets the fields for all events and the second -F
148               suppresses trace events. The user is given a warning message about
149               the override, and the result of the above is that only S/W and H/W
150               events are displayed with the given fields.
151
152               It's possible tp add/remove fields only for specific event type:
153
154               -Fsw:-cpu,-period
155
156               removes cpu and period from software events.
157
158               For the 'wildcard' option if a user selected field is invalid for an
159               event type, a message is displayed to the user that the option is
160               ignored for that type. For example:
161
162               $ perf script -F comm,tid,trace
163               'trace' not valid for hardware events. Ignoring.
164               'trace' not valid for software events. Ignoring.
165
166               Alternatively, if the type is given an invalid field is specified it
167               is an error. For example:
168
169               perf script -v -F sw:comm,tid,trace
170               'trace' not valid for software events.
171
172               At this point usage is displayed, and perf-script exits.
173
174               The flags field is synthesized and may have a value when Instruction
175               Trace decoding. The flags are "bcrosyiABEx" which stand for branch,
176               call, return, conditional, system, asynchronous, interrupt,
177               transaction abort, trace begin, trace end, and in transaction,
178               respectively. Known combinations of flags are printed more nicely e.g.
179               "call" for "bc", "return" for "br", "jcc" for "bo", "jmp" for "b",
180               "int" for "bci", "iret" for "bri", "syscall" for "bcs", "sysret" for "brs",
181               "async" for "by", "hw int" for "bcyi", "tx abrt" for "bA", "tr strt" for "bB",
182               "tr end" for "bE". However the "x" flag will be display separately in those
183               cases e.g. "jcc     (x)" for a condition branch within a transaction.
184
185               The callindent field is synthesized and may have a value when
186               Instruction Trace decoding. For calls and returns, it will display the
187               name of the symbol indented with spaces to reflect the stack depth.
188
189               When doing instruction trace decoding insn and insnlen give the
190               instruction bytes and the instruction length of the current
191               instruction.
192
193               The synth field is used by synthesized events which may be created when
194               Instruction Trace decoding.
195
196               The ipc (instructions per cycle) field is synthesized and may have a value when
197               Instruction Trace decoding.
198
199               Finally, a user may not set fields to none for all event types.
200               i.e., -F "" is not allowed.
201
202               The brstack output includes branch related information with raw addresses using the
203               /v/v/v/v/cycles syntax in the following order:
204               FROM: branch source instruction
205               TO  : branch target instruction
206               M/P/-: M=branch target mispredicted or branch direction was mispredicted, P=target predicted or direction predicted, -=not supported
207               X/- : X=branch inside a transactional region, -=not in transaction region or not supported
208               A/- : A=TSX abort entry, -=not aborted region or not supported
209               cycles
210
211               The brstacksym is identical to brstack, except that the FROM and TO addresses are printed in a symbolic form if possible.
212
213               When brstackinsn is specified the full assembler sequences of branch sequences for each sample
214               is printed. This is the full execution path leading to the sample. This is only supported when the
215               sample was recorded with perf record -b or -j any.
216
217               The brstackoff field will print an offset into a specific dso/binary.
218
219               With the metric option perf script can compute metrics for
220               sampling periods, similar to perf stat. This requires
221               specifying a group with multiple events defining metrics with the :S option
222               for perf record. perf will sample on the first event, and
223               print computed metrics for all the events in the group. Please note
224               that the metric computed is averaged over the whole sampling
225               period (since the last sample), not just for the sample point.
226
227               For sample events it's possible to display misc field with -F +misc option,
228               following letters are displayed for each bit:
229
230               PERF_RECORD_MISC_KERNEL               K
231               PERF_RECORD_MISC_USER                 U
232               PERF_RECORD_MISC_HYPERVISOR           H
233               PERF_RECORD_MISC_GUEST_KERNEL         G
234               PERF_RECORD_MISC_GUEST_USER           g
235               PERF_RECORD_MISC_MMAP_DATA*           M
236               PERF_RECORD_MISC_COMM_EXEC            E
237               PERF_RECORD_MISC_SWITCH_OUT           S
238               PERF_RECORD_MISC_SWITCH_OUT_PREEMPT   Sp
239
240               $ perf script -F +misc ...
241                sched-messaging  1414 K     28690.636582:       4590 cycles ...
242                sched-messaging  1407 U     28690.636600:     325620 cycles ...
243                sched-messaging  1414 K     28690.636608:      19473 cycles ...
244               misc field ___________/
245
246       -k, --vmlinux=<file>
247           vmlinux pathname
248
249       --kallsyms=<file>
250           kallsyms pathname
251
252       --symfs=<directory>
253           Look for files with symbols relative to this directory.
254
255       -G, --hide-call-graph
256           When printing symbols do not display call chain.
257
258       --stop-bt
259           Stop display of callgraph at these symbols
260
261       -C, --cpu
262           Only report samples for the list of CPUs provided. Multiple CPUs
263           can be provided as a comma-separated list with no space: 0,1.
264           Ranges of CPUs are specified with -: 0-2. Default is to report
265           samples on all CPUs.
266
267       -c, --comms=
268           Only display events for these comms. CSV that understands
269           file://filename entries.
270
271       --pid=
272           Only show events for given process ID (comma separated list).
273
274       --tid=
275           Only show events for given thread ID (comma separated list).
276
277       -I, --show-info
278           Display extended information about the perf.data file. This adds
279           information which may be very large and thus may clutter the
280           display. It currently includes: cpu and numa topology of the host
281           system. It can only be used with the perf script report mode.
282
283       --show-kernel-path
284           Try to resolve the path of [kernel.kallsyms]
285
286       --show-task-events Display task related events (e.g. FORK, COMM, EXIT).
287
288       --show-mmap-events Display mmap related events (e.g. MMAP, MMAP2).
289
290       --show-namespace-events Display namespace events i.e. events of type
291       PERF_RECORD_NAMESPACES.
292
293       --show-switch-events Display context switch events i.e. events of type
294       PERF_RECORD_SWITCH or PERF_RECORD_SWITCH_CPU_WIDE.
295
296       --show-lost-events Display lost events i.e. events of type
297       PERF_RECORD_LOST.
298
299       --show-round-events Display finished round events i.e. events of type
300       PERF_RECORD_FINISHED_ROUND.
301
302       --show-bpf-events Display bpf events i.e. events of type
303       PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT.
304
305       --show-cgroup-events Display cgroup events i.e. events of type
306       PERF_RECORD_CGROUP.
307
308       --show-text-poke-events Display text poke events i.e. events of type
309       PERF_RECORD_TEXT_POKE and PERF_RECORD_KSYMBOL.
310
311       --demangle
312           Demangle symbol names to human readable form. It’s enabled by
313           default, disable with --no-demangle.
314
315       --demangle-kernel
316           Demangle kernel symbol names to human readable form (for C++
317           kernels).
318
319       --header Show perf.data header.
320
321       --header-only Show only perf.data header.
322
323       --itrace
324           Options for decoding instruction tracing data. The options are:
325
326               i       synthesize instructions events
327               b       synthesize branches events (branch misses for Arm SPE)
328               c       synthesize branches events (calls only)
329               r       synthesize branches events (returns only)
330               x       synthesize transactions events
331               w       synthesize ptwrite events
332               p       synthesize power events (incl. PSB events for Intel PT)
333               o       synthesize other events recorded due to the use
334                       of aux-output (refer to perf record)
335               e       synthesize error events
336               d       create a debug log
337               f       synthesize first level cache events
338               m       synthesize last level cache events
339               M       synthesize memory events
340               t       synthesize TLB events
341               a       synthesize remote access events
342               g       synthesize a call chain (use with i or x)
343               G       synthesize a call chain on existing event records
344               l       synthesize last branch entries (use with i or x)
345               L       synthesize last branch entries on existing event records
346               s       skip initial number of events
347               q       quicker (less detailed) decoding
348
349               The default is all events i.e. the same as --itrace=ibxwpe,
350               except for perf script where it is --itrace=ce
351
352               In addition, the period (default 100000, except for perf script where it is 1)
353               for instructions events can be specified in units of:
354
355               i       instructions
356               t       ticks
357               ms      milliseconds
358               us      microseconds
359               ns      nanoseconds (default)
360
361               Also the call chain size (default 16, max. 1024) for instructions or
362               transactions events can be specified.
363
364               Also the number of last branch entries (default 64, max. 1024) for
365               instructions or transactions events can be specified.
366
367               Similar to options g and l, size may also be specified for options G and L.
368               On x86, note that G and L work poorly when data has been recorded with
369               large PEBS. Refer linkperf:perf-intel-pt[1] man page for details.
370
371               It is also possible to skip events generated (instructions, branches, transactions,
372               ptwrite, power) at the beginning. This is useful to ignore initialization code.
373
374               --itrace=i0nss1000000
375
376               skips the first million instructions.
377
378               The 'e' option may be followed by flags which affect what errors will or
379               will not be reported. Each flag must be preceded by either '+' or '-'.
380               The flags are:
381                       o       overflow
382                       l       trace data lost
383
384               If supported, the 'd' option may be followed by flags which affect what
385               debug messages will or will not be logged. Each flag must be preceded
386               by either '+' or '-'. The flags are:
387                       a       all perf events
388
389               If supported, the 'q' option may be repeated to increase the effect.
390
391               To disable decoding entirely, use --no-itrace.
392
393       --full-source-path
394           Show the full path for source files for srcline output.
395
396       --max-stack
397           Set the stack depth limit when parsing the callchain, anything
398           beyond the specified depth will be ignored. This is a trade-off
399           between information loss and faster processing especially for
400           workloads that can have a very long callchain stack. Note that when
401           using the --itrace option the synthesized callchain size will
402           override this value if the synthesized callchain size is bigger.
403
404               Default: 127
405
406       --ns
407           Use 9 decimal places when displaying time (i.e. show the
408           nanoseconds)
409
410       -f, --force
411           Don’t do ownership validation.
412
413       --time
414           Only analyze samples within given time window: <start>,<stop>.
415           Times have the format seconds.nanoseconds. If start is not given
416           (i.e. time string is ,x.y) then analysis starts at the beginning of
417           the file. If stop time is not given (i.e. time string is x.y,) then
418           analysis goes to end of file. Multiple ranges can be separated by
419           spaces, which requires the argument to be quoted e.g. --time
420           "1234.567,1234.789 1235,"
421
422               Also support time percent with multiple time ranges. Time string is
423               'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'.
424
425               For example:
426               Select the second 10% time slice:
427               perf script --time 10%/2
428
429               Select from 0% to 10% time slice:
430               perf script --time 0%-10%
431
432               Select the first and second 10% time slices:
433               perf script --time 10%/1,10%/2
434
435               Select from 0% to 10% and 30% to 40% slices:
436               perf script --time 0%-10%,30%-40%
437
438       --max-blocks
439           Set the maximum number of program blocks to print with brstackinsn
440           for each sample.
441
442       --reltime
443           Print time stamps relative to trace start.
444
445       --deltatime
446           Print time stamps relative to previous event.
447
448       --per-event-dump
449           Create per event files with a "perf.data.EVENT.dump" name instead
450           of printing to stdout, useful, for instance, for generating
451           flamegraphs.
452
453       --inline
454           If a callgraph address belongs to an inlined function, the inline
455           stack will be printed. Each entry has function name and file/line.
456           Enabled by default, disable with --no-inline.
457
458       --insn-trace
459           Show instruction stream for intel_pt traces. Combine with --xed to
460           show disassembly.
461
462       --xed
463           Run xed disassembler on output. Requires installing the xed
464           disassembler.
465
466       -S, --symbols=symbol[,symbol...]
467           Only consider the listed symbols. Symbols are typically a name but
468           they may also be hexadecimal address.
469
470               The hexadecimal address may be the start address of a symbol or
471               any other address to filter the trace records
472
473               For example, to select the symbol noploop or the address 0x4007a0:
474               perf script --symbols=noploop,0x4007a0
475
476               Support filtering trace records by symbol name, start address of
477               symbol, any hexadecimal address and address range.
478
479               The comparison order is:
480
481            1. symbol name comparison
482
483            2. symbol start address comparison.
484
485            3. any hexadecimal address comparison.
486
487            4. address range comparison (see --addr-range).
488
489       --addr-range
490           Use with -S or --symbols to list traced records within address
491           range.
492
493               For example, to list the traced records within the address range
494               [0x4007a0, 0x0x4007a9]:
495               perf script -S 0x4007a0 --addr-range 10
496
497       --dsos=
498           Only consider symbols in these DSOs.
499
500       --call-trace
501           Show call stream for intel_pt traces. The CPUs are interleaved, but
502           can be filtered with -C.
503
504       --call-ret-trace
505           Show call and return stream for intel_pt traces.
506
507       --graph-function
508           For itrace only show specified functions and their callees for
509           itrace. Multiple functions can be separated by comma.
510
511       --switch-on EVENT_NAME
512           Only consider events after this event is found.
513
514       --switch-off EVENT_NAME
515           Stop considering events after this event is found.
516
517       --show-on-off-events
518           Show the --switch-on/off events too.
519
520       --stitch-lbr
521           Show callgraph with stitched LBRs, which may have more complete
522           callgraph. The perf.data file must have been obtained using perf
523           record --call-graph lbr. Disabled by default. In common cases with
524           call stack overflows, it can recreate better call stacks than the
525           default lbr call stack output. But this approach is not full proof.
526           There can be cases where it creates incorrect call stacks from
527           incorrect matches. The known limitations include exception handing
528           such as setjmp/longjmp will have calls/returns not match.
529

SEE ALSO

531       perf-record(1), perf-script-perl(1), perf-script-python(1), perf-intel-
532       pt(1)
533
534
535
536perf                              06/03/2021                    PERF-SCRIPT(1)
Impressum