perf-script.txt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. perf-script(1)
  2. =============
  3. NAME
  4. ----
  5. perf-script - Read perf.data (created by perf record) and display trace output
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'perf script' [<options>]
  10. 'perf script' [<options>] record <script> [<record-options>] <command>
  11. 'perf script' [<options>] report <script> [script-args]
  12. 'perf script' [<options>] <script> <required-script-args> [<record-options>] <command>
  13. 'perf script' [<options>] <top-script> [script-args]
  14. DESCRIPTION
  15. -----------
  16. This command reads the input file and displays the trace recorded.
  17. There are several variants of perf script:
  18. 'perf script' to see a detailed trace of the workload that was
  19. recorded.
  20. You can also run a set of pre-canned scripts that aggregate and
  21. summarize the raw trace data in various ways (the list of scripts is
  22. available via 'perf script -l'). The following variants allow you to
  23. record and run those scripts:
  24. 'perf script record <script> <command>' to record the events required
  25. for 'perf script report'. <script> is the name displayed in the
  26. output of 'perf script --list' i.e. the actual script name minus any
  27. language extension. If <command> is not specified, the events are
  28. recorded using the -a (system-wide) 'perf record' option.
  29. 'perf script report <script> [args]' to run and display the results
  30. of <script>. <script> is the name displayed in the output of 'perf
  31. trace --list' i.e. the actual script name minus any language
  32. extension. The perf.data output from a previous run of 'perf script
  33. record <script>' is used and should be present for this command to
  34. succeed. [args] refers to the (mainly optional) args expected by
  35. the script.
  36. 'perf script <script> <required-script-args> <command>' to both
  37. record the events required for <script> and to run the <script>
  38. using 'live-mode' i.e. without writing anything to disk. <script>
  39. is the name displayed in the output of 'perf script --list' i.e. the
  40. actual script name minus any language extension. If <command> is
  41. not specified, the events are recorded using the -a (system-wide)
  42. 'perf record' option. If <script> has any required args, they
  43. should be specified before <command>. This mode doesn't allow for
  44. optional script args to be specified; if optional script args are
  45. desired, they can be specified using separate 'perf script record'
  46. and 'perf script report' commands, with the stdout of the record step
  47. piped to the stdin of the report script, using the '-o -' and '-i -'
  48. options of the corresponding commands.
  49. 'perf script <top-script>' to both record the events required for
  50. <top-script> and to run the <top-script> using 'live-mode'
  51. i.e. without writing anything to disk. <top-script> is the name
  52. displayed in the output of 'perf script --list' i.e. the actual
  53. script name minus any language extension; a <top-script> is defined
  54. as any script name ending with the string 'top'.
  55. [<record-options>] can be passed to the record steps of 'perf script
  56. record' and 'live-mode' variants; this isn't possible however for
  57. <top-script> 'live-mode' or 'perf script report' variants.
  58. See the 'SEE ALSO' section for links to language-specific
  59. information on how to write and run your own trace scripts.
  60. OPTIONS
  61. -------
  62. <command>...::
  63. Any command you can specify in a shell.
  64. -D::
  65. --dump-raw-script=::
  66. Display verbose dump of the trace data.
  67. -L::
  68. --Latency=::
  69. Show latency attributes (irqs/preemption disabled, etc).
  70. -l::
  71. --list=::
  72. Display a list of available trace scripts.
  73. -s ['lang']::
  74. --script=::
  75. Process trace data with the given script ([lang]:script[.ext]).
  76. If the string 'lang' is specified in place of a script name, a
  77. list of supported languages will be displayed instead.
  78. -g::
  79. --gen-script=::
  80. Generate perf-script.[ext] starter script for given language,
  81. using current perf.data.
  82. -a::
  83. Force system-wide collection. Scripts run without a <command>
  84. normally use -a by default, while scripts run with a <command>
  85. normally don't - this option allows the latter to be run in
  86. system-wide mode.
  87. -i::
  88. --input=::
  89. Input file name. (default: perf.data unless stdin is a fifo)
  90. -d::
  91. --debug-mode::
  92. Do various checks like samples ordering and lost events.
  93. -F::
  94. --fields::
  95. Comma separated list of fields to print. Options are:
  96. comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
  97. srcline, period, iregs, brstack, brstacksym, flags, bpf-output,
  98. callindent. Field list can be prepended with the type, trace, sw or hw,
  99. to indicate to which event type the field list applies.
  100. e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace
  101. perf script -F <fields>
  102. is equivalent to:
  103. perf script -F trace:<fields> -F sw:<fields> -F hw:<fields>
  104. i.e., the specified fields apply to all event types if the type string
  105. is not given.
  106. The arguments are processed in the order received. A later usage can
  107. reset a prior request. e.g.:
  108. -F trace: -F comm,tid,time,ip,sym
  109. The first -F suppresses trace events (field list is ""), but then the
  110. second invocation sets the fields to comm,tid,time,ip,sym. In this case a
  111. warning is given to the user:
  112. "Overriding previous field request for all events."
  113. Alternatively, consider the order:
  114. -F comm,tid,time,ip,sym -F trace:
  115. The first -F sets the fields for all events and the second -F
  116. suppresses trace events. The user is given a warning message about
  117. the override, and the result of the above is that only S/W and H/W
  118. events are displayed with the given fields.
  119. For the 'wildcard' option if a user selected field is invalid for an
  120. event type, a message is displayed to the user that the option is
  121. ignored for that type. For example:
  122. $ perf script -F comm,tid,trace
  123. 'trace' not valid for hardware events. Ignoring.
  124. 'trace' not valid for software events. Ignoring.
  125. Alternatively, if the type is given an invalid field is specified it
  126. is an error. For example:
  127. perf script -v -F sw:comm,tid,trace
  128. 'trace' not valid for software events.
  129. At this point usage is displayed, and perf-script exits.
  130. The flags field is synthesized and may have a value when Instruction
  131. Trace decoding. The flags are "bcrosyiABEx" which stand for branch,
  132. call, return, conditional, system, asynchronous, interrupt,
  133. transaction abort, trace begin, trace end, and in transaction,
  134. respectively. Known combinations of flags are printed more nicely e.g.
  135. "call" for "bc", "return" for "br", "jcc" for "bo", "jmp" for "b",
  136. "int" for "bci", "iret" for "bri", "syscall" for "bcs", "sysret" for "brs",
  137. "async" for "by", "hw int" for "bcyi", "tx abrt" for "bA", "tr strt" for "bB",
  138. "tr end" for "bE". However the "x" flag will be display separately in those
  139. cases e.g. "jcc (x)" for a condition branch within a transaction.
  140. The callindent field is synthesized and may have a value when
  141. Instruction Trace decoding. For calls and returns, it will display the
  142. name of the symbol indented with spaces to reflect the stack depth.
  143. Finally, a user may not set fields to none for all event types.
  144. i.e., -F "" is not allowed.
  145. The brstack output includes branch related information with raw addresses using the
  146. /v/v/v/v/ syntax in the following order:
  147. FROM: branch source instruction
  148. TO : branch target instruction
  149. M/P/-: M=branch target mispredicted or branch direction was mispredicted, P=target predicted or direction predicted, -=not supported
  150. X/- : X=branch inside a transactional region, -=not in transaction region or not supported
  151. A/- : A=TSX abort entry, -=not aborted region or not supported
  152. The brstacksym is identical to brstack, except that the FROM and TO addresses are printed in a symbolic form if possible.
  153. -k::
  154. --vmlinux=<file>::
  155. vmlinux pathname
  156. --kallsyms=<file>::
  157. kallsyms pathname
  158. --symfs=<directory>::
  159. Look for files with symbols relative to this directory.
  160. -G::
  161. --hide-call-graph::
  162. When printing symbols do not display call chain.
  163. -C::
  164. --cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can
  165. be provided as a comma-separated list with no space: 0,1. Ranges of
  166. CPUs are specified with -: 0-2. Default is to report samples on all
  167. CPUs.
  168. -c::
  169. --comms=::
  170. Only display events for these comms. CSV that understands
  171. file://filename entries.
  172. --pid=::
  173. Only show events for given process ID (comma separated list).
  174. --tid=::
  175. Only show events for given thread ID (comma separated list).
  176. -I::
  177. --show-info::
  178. Display extended information about the perf.data file. This adds
  179. information which may be very large and thus may clutter the display.
  180. It currently includes: cpu and numa topology of the host system.
  181. It can only be used with the perf script report mode.
  182. --show-kernel-path::
  183. Try to resolve the path of [kernel.kallsyms]
  184. --show-task-events
  185. Display task related events (e.g. FORK, COMM, EXIT).
  186. --show-mmap-events
  187. Display mmap related events (e.g. MMAP, MMAP2).
  188. --show-switch-events
  189. Display context switch events i.e. events of type PERF_RECORD_SWITCH or
  190. PERF_RECORD_SWITCH_CPU_WIDE.
  191. --demangle::
  192. Demangle symbol names to human readable form. It's enabled by default,
  193. disable with --no-demangle.
  194. --demangle-kernel::
  195. Demangle kernel symbol names to human readable form (for C++ kernels).
  196. --header
  197. Show perf.data header.
  198. --header-only
  199. Show only perf.data header.
  200. --itrace::
  201. Options for decoding instruction tracing data. The options are:
  202. include::itrace.txt[]
  203. To disable decoding entirely, use --no-itrace.
  204. --full-source-path::
  205. Show the full path for source files for srcline output.
  206. --max-stack::
  207. Set the stack depth limit when parsing the callchain, anything
  208. beyond the specified depth will be ignored. This is a trade-off
  209. between information loss and faster processing especially for
  210. workloads that can have a very long callchain stack.
  211. Note that when using the --itrace option the synthesized callchain size
  212. will override this value if the synthesized callchain size is bigger.
  213. Default: 127
  214. --ns::
  215. Use 9 decimal places when displaying time (i.e. show the nanoseconds)
  216. -f::
  217. --force::
  218. Don't do ownership validation.
  219. SEE ALSO
  220. --------
  221. linkperf:perf-record[1], linkperf:perf-script-perl[1],
  222. linkperf:perf-script-python[1]