perf-record.txt 5.8 KB

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