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

SEE ALSO

545       perf-record(1), perf-script-perl(1), perf-script-python(1), perf-intel-
546       pt(1), perf-dlfilter(1)
547
548
549
550perf                              11/22/2021                    PERF-SCRIPT(1)
Impressum