perf-record.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. --call-graph::
  73. Do call-graph (stack chain/backtrace) recording.
  74. -q::
  75. --quiet::
  76. Don't print any message, useful for scripting.
  77. -v::
  78. --verbose::
  79. Be more verbose (show counter open errors, etc).
  80. -s::
  81. --stat::
  82. Per thread counts.
  83. -d::
  84. --data::
  85. Sample addresses.
  86. -T::
  87. --timestamp::
  88. Sample timestamps. Use it with 'perf report -D' to see the timestamps,
  89. for instance.
  90. -n::
  91. --no-samples::
  92. Don't sample.
  93. -R::
  94. --raw-samples::
  95. Collect raw sample records from all opened counters (default for tracepoint counters).
  96. -C::
  97. --cpu::
  98. Collect samples only on the list of CPUs provided. Multiple CPUs can be provided as a
  99. comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
  100. In per-thread mode with inheritance mode on (default), samples are captured only when
  101. the thread executes on the designated CPUs. Default is to monitor all CPUs.
  102. -N::
  103. --no-buildid-cache::
  104. Do not update the builid cache. This saves some overhead in situations
  105. where the information in the perf.data file (which includes buildids)
  106. is sufficient.
  107. -G name,...::
  108. --cgroup name,...::
  109. monitor only in the container (cgroup) called "name". This option is available only
  110. in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to
  111. container "name" are monitored when they run on the monitored CPUs. Multiple cgroups
  112. can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup
  113. to first event, second cgroup to second event and so on. It is possible to provide
  114. an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have
  115. corresponding events, i.e., they always refer to events defined earlier on the command
  116. line.
  117. -b::
  118. --branch-any::
  119. Enable taken branch stack sampling. Any type of taken branch may be sampled.
  120. This is a shortcut for --branch-filter any. See --branch-filter for more infos.
  121. -j::
  122. --branch-filter::
  123. Enable taken branch stack sampling. Each sample captures a series of consecutive
  124. taken branches. The number of branches captured with each sample depends on the
  125. underlying hardware, the type of branches of interest, and the executed code.
  126. It is possible to select the types of branches captured by enabling filters. The
  127. following filters are defined:
  128. - any: any type of branches
  129. - any_call: any function call or system call
  130. - any_ret: any function return or system call return
  131. - ind_call: any indirect branch
  132. - u: only when the branch target is at the user level
  133. - k: only when the branch target is in the kernel
  134. - hv: only when the target is at the hypervisor level
  135. - in_tx: only when the target is in a hardware transaction
  136. - no_tx: only when the target is not in a hardware transaction
  137. - abort_tx: only when the target is a hardware transaction abort
  138. +
  139. The option requires at least one branch type among any, any_call, any_ret, ind_call.
  140. The privilege levels may be omitted, in which case, the privilege levels of the associated
  141. event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege
  142. levels are subject to permissions. When sampling on multiple events, branch stack sampling
  143. is enabled for all the sampling events. The sampled branch type is the same for all events.
  144. The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
  145. Note that this feature may not be available on all processors.
  146. --weight::
  147. Enable weightened sampling. An additional weight is recorded per sample and can be
  148. displayed with the weight and local_weight sort keys. This currently works for TSX
  149. abort events and some memory events in precise mode on modern Intel CPUs.
  150. --transaction::
  151. Record transaction flags for transaction related events.
  152. SEE ALSO
  153. --------
  154. linkperf:perf-stat[1], linkperf:perf-list[1]