perf-lock.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. perf-lock(1)
  2. ============
  3. NAME
  4. ----
  5. perf-lock - Analyze lock events
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'perf lock' {record|report|script|info|contention}
  10. DESCRIPTION
  11. -----------
  12. You can analyze various lock behaviours
  13. and statistics with this 'perf lock' command.
  14. 'perf lock record <command>' records lock events
  15. between start and end <command>. And this command
  16. produces the file "perf.data" which contains tracing
  17. results of lock events.
  18. 'perf lock report' reports statistical data.
  19. 'perf lock script' shows raw lock events.
  20. 'perf lock info' shows metadata like threads or addresses
  21. of lock instances.
  22. 'perf lock contention' shows contention statistics.
  23. COMMON OPTIONS
  24. --------------
  25. -i::
  26. --input=<file>::
  27. Input file name. (default: perf.data unless stdin is a fifo)
  28. --output=<file>::
  29. Output file name for perf lock contention and report.
  30. -v::
  31. --verbose::
  32. Be more verbose (show symbol address, etc).
  33. -q::
  34. --quiet::
  35. Do not show any warnings or messages. (Suppress -v)
  36. -D::
  37. --dump-raw-trace::
  38. Dump raw trace in ASCII.
  39. -f::
  40. --force::
  41. Don't complain, do it.
  42. --vmlinux=<file>::
  43. vmlinux pathname
  44. --kallsyms=<file>::
  45. kallsyms pathname
  46. REPORT OPTIONS
  47. --------------
  48. -k::
  49. --key=<value>::
  50. Sorting key. Possible values: acquired (default), contended,
  51. avg_wait, wait_total, wait_max, wait_min.
  52. -F::
  53. --field=<value>::
  54. Output fields. By default it shows all the fields but users can
  55. customize that using this. Possible values: acquired, contended,
  56. avg_wait, wait_total, wait_max, wait_min.
  57. -c::
  58. --combine-locks::
  59. Merge lock instances in the same class (based on name).
  60. -t::
  61. --threads::
  62. The -t option is to show per-thread lock stat like below:
  63. $ perf lock report -t -F acquired,contended,avg_wait
  64. Name acquired contended avg wait (ns)
  65. perf 240569 9 5784
  66. swapper 106610 19 543
  67. :15789 17370 2 14538
  68. ContainerMgr 8981 6 874
  69. sleep 5275 1 11281
  70. ContainerThread 4416 4 944
  71. RootPressureThr 3215 5 1215
  72. rcu_preempt 2954 0 0
  73. ContainerMgr 2560 0 0
  74. unnamed 1873 0 0
  75. EventManager_De 1845 1 636
  76. futex-default-S 1609 0 0
  77. -E::
  78. --entries=<value>::
  79. Display this many entries.
  80. INFO OPTIONS
  81. ------------
  82. -t::
  83. --threads::
  84. dump only the thread list in perf.data
  85. -m::
  86. --map::
  87. dump only the map of lock instances (address:name table)
  88. CONTENTION OPTIONS
  89. ------------------
  90. -k::
  91. --key=<value>::
  92. Sorting key. Possible values: contended, wait_total (default),
  93. wait_max, wait_min, avg_wait.
  94. -F::
  95. --field=<value>::
  96. Output fields. By default it shows all but the wait_min fields
  97. and users can customize that using this. Possible values:
  98. contended, wait_total, wait_max, wait_min, avg_wait.
  99. -t::
  100. --threads::
  101. Show per-thread lock contention stat
  102. -b::
  103. --use-bpf::
  104. Use BPF program to collect lock contention stats instead of
  105. using the input data.
  106. -a::
  107. --all-cpus::
  108. System-wide collection from all CPUs.
  109. -C::
  110. --cpu=<value>::
  111. Collect samples only on the list of CPUs provided. Multiple CPUs can be
  112. provided as a comma-separated list with no space: 0,1. Ranges of CPUs
  113. are specified with -: 0-2. Default is to monitor all CPUs.
  114. -p::
  115. --pid=<value>::
  116. Record events on existing process ID (comma separated list).
  117. --tid=<value>::
  118. Record events on existing thread ID (comma separated list).
  119. -M::
  120. --map-nr-entries=<value>::
  121. Maximum number of BPF map entries (default: 16384).
  122. This will be aligned to a power of 2.
  123. --max-stack=<value>::
  124. Maximum stack depth when collecting lock contention (default: 8).
  125. --stack-skip=<value>::
  126. Number of stack depth to skip when finding a lock caller (default: 3).
  127. -E::
  128. --entries=<value>::
  129. Display this many entries.
  130. -l::
  131. --lock-addr::
  132. Show lock contention stat by address
  133. -o::
  134. --lock-owner::
  135. Show lock contention stat by owners. This option can be combined with -t,
  136. which shows owner's per thread lock stats, or -v, which shows owner's
  137. stacktrace. Requires --use-bpf.
  138. -Y::
  139. --type-filter=<value>::
  140. Show lock contention only for given lock types (comma separated list).
  141. Available values are:
  142. semaphore, spinlock, rwlock, rwlock:R, rwlock:W, rwsem, rwsem:R, rwsem:W,
  143. rtmutex, rwlock-rt, rwlock-rt:R, rwlock-rt:W, percpu-rwmem, pcpu-sem,
  144. pcpu-sem:R, pcpu-sem:W, mutex
  145. Note that RW-variant of locks have :R and :W suffix. Names without the
  146. suffix are shortcuts for the both variants. Ex) rwsem = rwsem:R + rwsem:W.
  147. -L::
  148. --lock-filter=<value>::
  149. Show lock contention only for given lock addresses or names (comma separated list).
  150. -S::
  151. --callstack-filter=<value>::
  152. Show lock contention only if the callstack contains the given string.
  153. Note that it matches the substring so 'rq' would match both 'raw_spin_rq_lock'
  154. and 'irq_enter_rcu'.
  155. -x::
  156. --field-separator=<SEP>::
  157. Show results using a CSV-style output to make it easy to import directly
  158. into spreadsheets. Columns are separated by the string specified in SEP.
  159. --lock-cgroup::
  160. Show lock contention stat by cgroup. Requires --use-bpf.
  161. -G::
  162. --cgroup-filter=<value>::
  163. Show lock contention only in the given cgroups (comma separated list).
  164. -J::
  165. --inject-delay=<time@function>::
  166. Add delays to the given lock. It's added to the contention-end part so
  167. that the (new) owner of the lock will be delayed. But by slowing down
  168. the owner, the waiters will also be delayed as well. This is working
  169. only with -b/--use-bpf.
  170. The 'time' is specified in nsec but it can have a unit suffix. Available
  171. units are "ms", "us" and "ns". Currently it accepts up to 10ms of delays
  172. for safety reasons.
  173. Note that it will busy-wait after it gets the lock. Delaying locks can
  174. have significant consequences including potential kernel crashes. Please
  175. use it at your own risk.
  176. SEE ALSO
  177. --------
  178. linkperf:perf[1]