perf-trace.txt 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. perf-trace(1)
  2. =============
  3. NAME
  4. ----
  5. perf-trace - strace inspired tool
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'perf trace'
  10. 'perf trace record'
  11. DESCRIPTION
  12. -----------
  13. This command will show the events associated with the target, initially
  14. syscalls, but other system events like pagefaults, task lifetime events,
  15. scheduling events, etc.
  16. This is a live mode tool in addition to working with perf.data files like
  17. the other perf tools. Files can be generated using the 'perf record' command
  18. but the session needs to include the raw_syscalls events (-e 'raw_syscalls:*').
  19. Alternatively, 'perf trace record' can be used as a shortcut to
  20. automatically include the raw_syscalls events when writing events to a file.
  21. The following options apply to perf trace; options to perf trace record are
  22. found in the perf record man page.
  23. OPTIONS
  24. -------
  25. -a::
  26. --all-cpus::
  27. System-wide collection from all CPUs.
  28. -e::
  29. --expr::
  30. List of syscalls to show, currently only syscall names.
  31. Prefixing with ! shows all syscalls but the ones specified. You may
  32. need to escape it.
  33. -D msecs::
  34. --delay msecs::
  35. After starting the program, wait msecs before measuring. This is useful to
  36. filter out the startup phase of the program, which is often very different.
  37. -o::
  38. --output=::
  39. Output file name.
  40. -p::
  41. --pid=::
  42. Record events on existing process ID (comma separated list).
  43. -t::
  44. --tid=::
  45. Record events on existing thread ID (comma separated list).
  46. -u::
  47. --uid=::
  48. Record events in threads owned by uid. Name or number.
  49. --filter-pids=::
  50. Filter out events for these pids and for 'trace' itself (comma separated list).
  51. -v::
  52. --verbose=::
  53. Verbosity level.
  54. --no-inherit::
  55. Child tasks do not inherit counters.
  56. -m::
  57. --mmap-pages=::
  58. Number of mmap data pages (must be a power of two) or size
  59. specification with appended unit character - B/K/M/G. The
  60. size is rounded up to have nearest pages power of two value.
  61. -C::
  62. --cpu::
  63. Collect samples only on the list of CPUs provided. Multiple CPUs can be provided as a
  64. comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
  65. In per-thread mode with inheritance mode on (default), Events are captured only when
  66. the thread executes on the designated CPUs. Default is to monitor all CPUs.
  67. --duration:
  68. Show only events that had a duration greater than N.M ms.
  69. --sched:
  70. Accrue thread runtime and provide a summary at the end of the session.
  71. -i
  72. --input
  73. Process events from a given perf data file.
  74. -T
  75. --time
  76. Print full timestamp rather time relative to first sample.
  77. --comm::
  78. Show process COMM right beside its ID, on by default, disable with --no-comm.
  79. -s::
  80. --summary::
  81. Show only a summary of syscalls by thread with min, max, and average times
  82. (in msec) and relative stddev.
  83. -S::
  84. --with-summary::
  85. Show all syscalls followed by a summary by thread with min, max, and
  86. average times (in msec) and relative stddev.
  87. --tool_stats::
  88. Show tool stats such as number of times fd->pathname was discovered thru
  89. hooking the open syscall return + vfs_getname or via reading /proc/pid/fd, etc.
  90. -F=[all|min|maj]::
  91. --pf=[all|min|maj]::
  92. Trace pagefaults. Optionally, you can specify whether you want minor,
  93. major or all pagefaults. Default value is maj.
  94. --syscalls::
  95. Trace system calls. This options is enabled by default.
  96. --call-graph [mode,type,min[,limit],order[,key][,branch]]::
  97. Setup and enable call-graph (stack chain/backtrace) recording.
  98. See `--call-graph` section in perf-record and perf-report
  99. man pages for details. The ones that are most useful in 'perf trace'
  100. are 'dwarf' and 'lbr', where available, try: 'perf trace --call-graph dwarf'.
  101. Using this will, for the root user, bump the value of --mmap-pages to 4
  102. times the maximum for non-root users, based on the kernel.perf_event_mlock_kb
  103. sysctl. This is done only if the user doesn't specify a --mmap-pages value.
  104. --kernel-syscall-graph::
  105. Show the kernel callchains on the syscall exit path.
  106. --event::
  107. Trace other events, see 'perf list' for a complete list.
  108. --max-stack::
  109. Set the stack depth limit when parsing the callchain, anything
  110. beyond the specified depth will be ignored. Note that at this point
  111. this is just about the presentation part, i.e. the kernel is still
  112. not limiting, the overhead of callchains needs to be set via the
  113. knobs in --call-graph dwarf.
  114. Implies '--call-graph dwarf' when --call-graph not present on the
  115. command line, on systems where DWARF unwinding was built in.
  116. Default: /proc/sys/kernel/perf_event_max_stack when present for
  117. live sessions (without --input/-i), 127 otherwise.
  118. --min-stack::
  119. Set the stack depth limit when parsing the callchain, anything
  120. below the specified depth will be ignored. Disabled by default.
  121. Implies '--call-graph dwarf' when --call-graph not present on the
  122. command line, on systems where DWARF unwinding was built in.
  123. --proc-map-timeout::
  124. When processing pre-existing threads /proc/XXX/mmap, it may take a long time,
  125. because the file may be huge. A time out is needed in such cases.
  126. This option sets the time out limit. The default value is 500 ms.
  127. PAGEFAULTS
  128. ----------
  129. When tracing pagefaults, the format of the trace is as follows:
  130. <min|maj>fault [<ip.symbol>+<ip.offset>] => <addr.dso@addr.offset> (<map type><addr level>).
  131. - min/maj indicates whether fault event is minor or major;
  132. - ip.symbol shows symbol for instruction pointer (the code that generated the
  133. fault); if no debug symbols available, perf trace will print raw IP;
  134. - addr.dso shows DSO for the faulted address;
  135. - map type is either 'd' for non-executable maps or 'x' for executable maps;
  136. - addr level is either 'k' for kernel dso or '.' for user dso.
  137. For symbols resolution you may need to install debugging symbols.
  138. Please be aware that duration is currently always 0 and doesn't reflect actual
  139. time it took for fault to be handled!
  140. When --verbose specified, perf trace tries to print all available information
  141. for both IP and fault address in the form of dso@symbol+offset.
  142. EXAMPLES
  143. --------
  144. Trace only major pagefaults:
  145. $ perf trace --no-syscalls -F
  146. Trace syscalls, major and minor pagefaults:
  147. $ perf trace -F all
  148. 1416.547 ( 0.000 ms): python/20235 majfault [CRYPTO_push_info_+0x0] => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0@0x61be0 (x.)
  149. As you can see, there was major pagefault in python process, from
  150. CRYPTO_push_info_ routine which faulted somewhere in libcrypto.so.
  151. SEE ALSO
  152. --------
  153. linkperf:perf-record[1], linkperf:perf-script[1]