perf-c2c.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. perf-c2c(1)
  2. ===========
  3. NAME
  4. ----
  5. perf-c2c - Shared Data C2C/HITM Analyzer.
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'perf c2c record' [<options>] <command>
  10. 'perf c2c record' [<options>] \-- [<record command options>] <command>
  11. 'perf c2c report' [<options>]
  12. DESCRIPTION
  13. -----------
  14. C2C stands for Cache To Cache.
  15. The perf c2c tool provides means for Shared Data C2C/HITM analysis. It allows
  16. you to track down the cacheline contentions.
  17. On Intel, the tool is based on load latency and precise store facility events
  18. provided by Intel CPUs. On PowerPC, the tool uses random instruction sampling
  19. with thresholding feature. On AMD, the tool uses IBS op pmu (due to hardware
  20. limitations, perf c2c is not supported on Zen3 cpus). On Arm64 it uses SPE to
  21. sample load and store operations, therefore hardware and kernel support is
  22. required. See linkperf:perf-arm-spe[1] for a setup guide. Due to the
  23. statistical nature of Arm SPE sampling, not every memory operation will be
  24. sampled.
  25. These events provide:
  26. - memory address of the access
  27. - type of the access (load and store details)
  28. - latency (in cycles) of the load access
  29. The c2c tool provide means to record this data and report back access details
  30. for cachelines with highest contention - highest number of HITM accesses.
  31. The basic workflow with this tool follows the standard record/report phase.
  32. User uses the record command to record events data and report command to
  33. display it.
  34. RECORD OPTIONS
  35. --------------
  36. -e::
  37. --event=::
  38. Select the PMU event. Use 'perf c2c record -e list'
  39. to list available events.
  40. -v::
  41. --verbose::
  42. Be more verbose (show counter open errors, etc).
  43. -l::
  44. --ldlat::
  45. Configure mem-loads latency. Supported on Intel, Arm64 and some AMD
  46. processors. Ignored on other archs.
  47. On supported AMD processors:
  48. - /sys/bus/event_source/devices/ibs_op/caps/ldlat file contains '1'.
  49. - Supported latency values are 128 to 2048 (both inclusive).
  50. - Latency value which is a multiple of 128 incurs a little less profiling
  51. overhead compared to other values.
  52. - Load latency filtering is disabled by default.
  53. -k::
  54. --all-kernel::
  55. Configure all used events to run in kernel space.
  56. -u::
  57. --all-user::
  58. Configure all used events to run in user space.
  59. REPORT OPTIONS
  60. --------------
  61. -k::
  62. --vmlinux=<file>::
  63. vmlinux pathname
  64. -v::
  65. --verbose::
  66. Be more verbose (show counter open errors, etc).
  67. -i::
  68. --input::
  69. Specify the input file to process.
  70. -N::
  71. --node-info::
  72. Show extra node info in report (see NODE INFO section)
  73. -c::
  74. --coalesce::
  75. Specify sorting fields for single cacheline display.
  76. Following fields are available: tid,pid,iaddr,dso
  77. (see COALESCE)
  78. -g::
  79. --call-graph::
  80. Setup callchains parameters.
  81. Please refer to perf-report man page for details.
  82. --stdio::
  83. Force the stdio output (see STDIO OUTPUT)
  84. --stats::
  85. Display only statistic tables and force stdio mode.
  86. --full-symbols::
  87. Display full length of symbols.
  88. --no-source::
  89. Do not display Source:Line column.
  90. --show-all::
  91. Show all captured HITM lines, with no regard to HITM % 0.0005 limit.
  92. -f::
  93. --force::
  94. Don't do ownership validation.
  95. -d::
  96. --display::
  97. Switch to HITM type (rmt, lcl) or peer snooping type (peer) to display
  98. and sort on. Total HITMs (tot) as default, except Arm64 uses peer mode
  99. as default.
  100. --stitch-lbr::
  101. Show callgraph with stitched LBRs, which may have more complete
  102. callgraph. The perf.data file must have been obtained using
  103. perf c2c record --call-graph lbr.
  104. Disabled by default. In common cases with call stack overflows,
  105. it can recreate better call stacks than the default lbr call stack
  106. output. But this approach is not foolproof. There can be cases
  107. where it creates incorrect call stacks from incorrect matches.
  108. The known limitations include exception handing such as
  109. setjmp/longjmp will have calls/returns not match.
  110. --double-cl::
  111. Group the detection of shared cacheline events into double cacheline
  112. granularity. Some architectures have an Adjacent Cacheline Prefetch
  113. feature, which causes cacheline sharing to behave like the cacheline
  114. size is doubled.
  115. -M::
  116. --disassembler-style=::
  117. Set disassembler style for objdump.
  118. --objdump=<path>::
  119. Path to objdump binary.
  120. C2C RECORD
  121. ----------
  122. The perf c2c record command setup options related to HITM cacheline analysis
  123. and calls standard perf record command.
  124. Following perf record options are configured by default:
  125. (check perf record man page for details)
  126. -W,-d,--phys-data,--sample-cpu
  127. The following table lists the events monitored on different architectures.
  128. Unless specified otherwise with the -e option, the tool will select the
  129. default events.
  130. +--------+---------------+-----------------+--------------------------------------------------------------------------------+
  131. | Arch | Configuration | Options | Events |
  132. +--------+---------------+-----------------+--------------------------------------------------------------------------------+
  133. | Intel | Default | -e ldlat-loads | cpu/mem-loads,ldlat=30/P |
  134. | | | -e ldlat-stores | cpu/mem-stores/P |
  135. | |---------------+-----------------+--------------------------------------------------------------------------------+
  136. | | Load only | -e ldlat-loads | cpu/mem-loads,ldlat=30/P |
  137. | |---------------+-----------------+--------------------------------------------------------------------------------+
  138. | | Store only | -e ldlat-stores | cpu/mem-stores/P |
  139. +--------+---------------+-----------------+--------------------------------------------------------------------------------+
  140. | Intel | Default | -e ldlat-loads | {cpu/mem-loads-aux/,cpu/mem-loads,ldlat=30/}:P |
  141. | with | | -e ldlat-stores | cpu/mem-stores/P |
  142. | AUX |--------------+------------------+--------------------------------------------------------------------------------+
  143. | | Load only | -e ldlat-loads | {cpu/mem-loads-aux/,cpu/mem-loads,ldlat=30/}:P |
  144. | |---------------+-----------------+--------------------------------------------------------------------------------+
  145. | | Store only | -e ldlat-stores | cpu/mem-stores/P |
  146. +--------+---------------+-----------------+--------------------------------------------------------------------------------+
  147. | AMD | Default | -e mem-ldst | ibs_op// (without latency support) |
  148. | | | | ibs_op/ldlat=30/ (with latency support) |
  149. +--------+---------------+-----------------+--------------------------------------------------------------------------------+
  150. | PowerPC| Default | -e ldlat-loads | cpu/mem-loads/ |
  151. | | | -e ldlat-stores | cpu/mem-stores/ |
  152. | |---------------+-----------------+--------------------------------------------------------------------------------+
  153. | | Load only | -e ldlat-loads | cpu/mem-loads/ |
  154. | |---------------+-----------------+--------------------------------------------------------------------------------+
  155. | | Store only | -e ldlat-stores | cpu/mem-stores/ |
  156. +--------+---------------+-----------------+--------------------------------------------------------------------------------+
  157. | Arm | Default | -e spe-ldst | arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=30/ |
  158. | SPE |---------------+-----------------+--------------------------------------------------------------------------------+
  159. | | Load only | -e spe-load | arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,min_latency=30/ |
  160. | |---------------+-----------------+--------------------------------------------------------------------------------+
  161. | | Store only | -e spe-store | arm_spe_0/ts_enable=1,pa_enable=1,store_filter=1/ |
  162. +--------+---------------+-----------------+--------------------------------------------------------------------------------+
  163. User can pass any 'perf record' option behind '--' mark, like (to enable
  164. callchains and system wide monitoring):
  165. $ perf c2c record -- -g -a
  166. Please check RECORD OPTIONS section for specific c2c record options.
  167. C2C REPORT
  168. ----------
  169. The perf c2c report command displays shared data analysis. It comes in two
  170. display modes: stdio and tui (default).
  171. The report command workflow is following:
  172. - sort all the data based on the cacheline address
  173. - store access details for each cacheline
  174. - sort all cachelines based on user settings
  175. - display data
  176. In general perf report output consist of 2 basic views:
  177. 1) most expensive cachelines list
  178. 2) offsets details for each cacheline
  179. For each cacheline in the 1) list we display following data:
  180. (Both stdio and TUI modes follow the same fields output)
  181. Index
  182. - zero based index to identify the cacheline
  183. Cacheline
  184. - cacheline address (hex number)
  185. Rmt/Lcl Hitm (Display with HITM types)
  186. - cacheline percentage of all Remote/Local HITM accesses
  187. Peer Snoop (Display with peer type)
  188. - cacheline percentage of all peer accesses
  189. LLC Load Hitm - Total, LclHitm, RmtHitm (For display with HITM types)
  190. - count of Total/Local/Remote load HITMs
  191. Load Peer - Total, Local, Remote (For display with peer type)
  192. - count of Total/Local/Remote load from peer cache or DRAM
  193. Total records
  194. - sum of all cachelines accesses
  195. Total loads
  196. - sum of all load accesses
  197. Total stores
  198. - sum of all store accesses
  199. Store Reference - L1Hit, L1Miss, N/A
  200. L1Hit - store accesses that hit L1
  201. L1Miss - store accesses that missed L1
  202. N/A - store accesses with memory level is not available
  203. Core Load Hit - FB, L1, L2
  204. - count of load hits in FB (Fill Buffer), L1 and L2 cache
  205. LLC Load Hit - LlcHit, LclHitm
  206. - count of LLC load accesses, includes LLC hits and LLC HITMs
  207. RMT Load Hit - RmtHit, RmtHitm
  208. - count of remote load accesses, includes remote hits and remote HITMs;
  209. on Arm neoverse cores, RmtHit is used to account remote accesses,
  210. includes remote DRAM or any upward cache level in remote node
  211. Load Dram - Lcl, Rmt
  212. - count of local and remote DRAM accesses
  213. For each offset in the 2) list we display following data:
  214. HITM - Rmt, Lcl (Display with HITM types)
  215. - % of Remote/Local HITM accesses for given offset within cacheline
  216. Peer Snoop - Rmt, Lcl (Display with peer type)
  217. - % of Remote/Local peer accesses for given offset within cacheline
  218. Store Refs - L1 Hit, L1 Miss, N/A
  219. - % of store accesses that hit L1, missed L1 and N/A (no available) memory
  220. level for given offset within cacheline
  221. Data address - Offset
  222. - offset address
  223. Pid
  224. - pid of the process responsible for the accesses
  225. Tid
  226. - tid of the process responsible for the accesses
  227. Code address
  228. - code address responsible for the accesses
  229. cycles - rmt hitm, lcl hitm, load (Display with HITM types)
  230. - sum of cycles for given accesses - Remote/Local HITM and generic load
  231. cycles - rmt peer, lcl peer, load (Display with peer type)
  232. - sum of cycles for given accesses - Remote/Local peer load and generic load
  233. cpu cnt
  234. - number of cpus that participated on the access
  235. Symbol
  236. - code symbol related to the 'Code address' value
  237. Shared Object
  238. - shared object name related to the 'Code address' value
  239. Source:Line
  240. - source information related to the 'Code address' value
  241. Node
  242. - nodes participating on the access (see NODE INFO section)
  243. NODE INFO
  244. ---------
  245. The 'Node' field displays nodes that accesses given cacheline
  246. offset. Its output comes in 3 flavors:
  247. - node IDs separated by ','
  248. - node IDs with stats for each ID, in following format:
  249. Node{cpus %hitms %stores} (Display with HITM types)
  250. Node{cpus %peers %stores} (Display with peer type)
  251. - node IDs with list of affected CPUs in following format:
  252. Node{cpu list}
  253. User can switch between above flavors with -N option or
  254. use 'n' key to interactively switch in TUI mode.
  255. COALESCE
  256. --------
  257. User can specify how to sort offsets for cacheline.
  258. Following fields are available and governs the final
  259. output fields set for cacheline offsets output:
  260. tid - coalesced by process TIDs
  261. pid - coalesced by process PIDs
  262. iaddr - coalesced by code address, following fields are displayed:
  263. Code address, Code symbol, Shared Object, Source line
  264. dso - coalesced by shared object
  265. By default the coalescing is setup with 'pid,iaddr'.
  266. STDIO OUTPUT
  267. ------------
  268. The stdio output displays data on standard output.
  269. Following tables are displayed:
  270. Trace Event Information
  271. - overall statistics of memory accesses
  272. Global Shared Cache Line Event Information
  273. - overall statistics on shared cachelines
  274. Shared Data Cache Line Table
  275. - list of most expensive cachelines
  276. Shared Cache Line Distribution Pareto
  277. - list of all accessed offsets for each cacheline
  278. TUI OUTPUT
  279. ----------
  280. The TUI output provides interactive interface to navigate
  281. through cachelines list and to display offset details.
  282. For details please refer to the help window by pressing '?' key.
  283. CREDITS
  284. -------
  285. Although Don Zickus, Dick Fowles and Joe Mario worked together
  286. to get this implemented, we got lots of early help from Arnaldo
  287. Carvalho de Melo, Stephane Eranian, Jiri Olsa and Andi Kleen.
  288. C2C BLOG
  289. --------
  290. Check Joe's blog on c2c tool for detailed use case explanation:
  291. https://joemario.github.io/blog/2016/09/01/c2c-blog/
  292. SEE ALSO
  293. --------
  294. linkperf:perf-record[1], linkperf:perf-mem[1], linkperf:perf-arm-spe[1]