perf-record.txt 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. perf-record(1)
  2. ==============
  3. NAME
  4. ----
  5. perf-record - Run a command and record its profile into perf.data
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'perf record' [-e <EVENT> | --event=EVENT] [-l] [-a] <command>
  10. 'perf record' [-e <EVENT> | --event=EVENT] [-l] [-a] -- <command> [<options>]
  11. DESCRIPTION
  12. -----------
  13. This command runs a command and gathers a performance counter profile
  14. from it, into perf.data - without displaying anything.
  15. This file can then be inspected later on, using 'perf report'.
  16. OPTIONS
  17. -------
  18. <command>...::
  19. Any command you can specify in a shell.
  20. -e::
  21. --event=::
  22. Select the PMU event. Selection can be:
  23. - a symbolic event name (use 'perf list' to list all events)
  24. - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
  25. hexadecimal event descriptor.
  26. - a hardware breakpoint event in the form of '\mem:addr[:access]'
  27. where addr is the address in memory you want to break in.
  28. Access is the memory access type (read, write, execute) it can
  29. be passed as follows: '\mem:addr[:[r][w][x]]'.
  30. If you want to profile read-write accesses in 0x1000, just set
  31. 'mem:0x1000:rw'.
  32. --filter=<filter>::
  33. Event filter.
  34. -a::
  35. --all-cpus::
  36. System-wide collection from all CPUs.
  37. -l::
  38. Scale counter values.
  39. -p::
  40. --pid=::
  41. Record events on existing process ID (comma separated list).
  42. -t::
  43. --tid=::
  44. Record events on existing thread ID (comma separated list).
  45. -u::
  46. --uid=::
  47. Record events in threads owned by uid. Name or number.
  48. -r::
  49. --realtime=::
  50. Collect data with this RT SCHED_FIFO priority.
  51. -D::
  52. --no-delay::
  53. Collect data without buffering.
  54. -c::
  55. --count=::
  56. Event period to sample.
  57. -o::
  58. --output=::
  59. Output file name.
  60. -i::
  61. --no-inherit::
  62. Child tasks do not inherit counters.
  63. -F::
  64. --freq=::
  65. Profile at this frequency.
  66. -m::
  67. --mmap-pages=::
  68. Number of mmap data pages (must be a power of two) or size
  69. specification with appended unit character - B/K/M/G. The
  70. size is rounded up to have nearest pages power of two value.
  71. -g::
  72. Enables call-graph (stack chain/backtrace) recording.
  73. --call-graph::
  74. Setup and enable call-graph (stack chain/backtrace) recording,
  75. implies -g.
  76. Allows specifying "fp" (frame pointer) or "dwarf"
  77. (DWARF's CFI - Call Frame Information) as the method to collect
  78. the information used to show the call graphs.
  79. In some systems, where binaries are build with gcc
  80. --fomit-frame-pointer, using the "fp" method will produce bogus
  81. call graphs, using "dwarf", if available (perf tools linked to
  82. the libunwind library) should be used instead.
  83. -q::
  84. --quiet::
  85. Don't print any message, useful for scripting.
  86. -v::
  87. --verbose::
  88. Be more verbose (show counter open errors, etc).
  89. -s::
  90. --stat::
  91. Per thread counts.
  92. -d::
  93. --data::
  94. Sample addresses.
  95. -T::
  96. --timestamp::
  97. Sample timestamps. Use it with 'perf report -D' to see the timestamps,
  98. for instance.
  99. -n::
  100. --no-samples::
  101. Don't sample.
  102. -R::
  103. --raw-samples::
  104. Collect raw sample records from all opened counters (default for tracepoint counters).
  105. -C::
  106. --cpu::
  107. Collect samples only on the list of CPUs provided. Multiple CPUs can be provided as a
  108. comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
  109. In per-thread mode with inheritance mode on (default), samples are captured only when
  110. the thread executes on the designated CPUs. Default is to monitor all CPUs.
  111. -N::
  112. --no-buildid-cache::
  113. Do not update the builid cache. This saves some overhead in situations
  114. where the information in the perf.data file (which includes buildids)
  115. is sufficient.
  116. -G name,...::
  117. --cgroup name,...::
  118. monitor only in the container (cgroup) called "name". This option is available only
  119. in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to
  120. container "name" are monitored when they run on the monitored CPUs. Multiple cgroups
  121. can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup
  122. to first event, second cgroup to second event and so on. It is possible to provide
  123. an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have
  124. corresponding events, i.e., they always refer to events defined earlier on the command
  125. line.
  126. -b::
  127. --branch-any::
  128. Enable taken branch stack sampling. Any type of taken branch may be sampled.
  129. This is a shortcut for --branch-filter any. See --branch-filter for more infos.
  130. -j::
  131. --branch-filter::
  132. Enable taken branch stack sampling. Each sample captures a series of consecutive
  133. taken branches. The number of branches captured with each sample depends on the
  134. underlying hardware, the type of branches of interest, and the executed code.
  135. It is possible to select the types of branches captured by enabling filters. The
  136. following filters are defined:
  137. - any: any type of branches
  138. - any_call: any function call or system call
  139. - any_ret: any function return or system call return
  140. - ind_call: any indirect branch
  141. - u: only when the branch target is at the user level
  142. - k: only when the branch target is in the kernel
  143. - hv: only when the target is at the hypervisor level
  144. - in_tx: only when the target is in a hardware transaction
  145. - no_tx: only when the target is not in a hardware transaction
  146. - abort_tx: only when the target is a hardware transaction abort
  147. +
  148. The option requires at least one branch type among any, any_call, any_ret, ind_call.
  149. The privilege levels may be omitted, in which case, the privilege levels of the associated
  150. event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege
  151. levels are subject to permissions. When sampling on multiple events, branch stack sampling
  152. is enabled for all the sampling events. The sampled branch type is the same for all events.
  153. The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
  154. Note that this feature may not be available on all processors.
  155. --weight::
  156. Enable weightened sampling. An additional weight is recorded per sample and can be
  157. displayed with the weight and local_weight sort keys. This currently works for TSX
  158. abort events and some memory events in precise mode on modern Intel CPUs.
  159. --transaction::
  160. Record transaction flags for transaction related events.
  161. --force-per-cpu::
  162. Force the use of per-cpu mmaps. By default, when tasks are specified (i.e. -p,
  163. -t or -u options) per-thread mmaps are created. This option overrides that and
  164. forces per-cpu mmaps. A side-effect of that is that inheritance is
  165. automatically enabled. Add the -i option also to disable inheritance.
  166. SEE ALSO
  167. --------
  168. linkperf:perf-stat[1], linkperf:perf-list[1]