perf-trace.txt 6.3 KB

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