'\" t .\" Title: perf-c2c .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 .\" Date: 2024-02-08 .\" Manual: perf Manual .\" Source: perf .\" Language: English .\" .TH "PERF\-C2C" "1" "2024-02-08" "perf" "perf Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" perf-c2c \- Shared Data C2C/HITM Analyzer. .SH "SYNOPSIS" .sp .nf \fIperf c2c record\fP [] \fIperf c2c record\fP [] \-\- [] \fIperf c2c report\fP [] .fi .br .SH "DESCRIPTION" .sp C2C stands for Cache To Cache. .sp The perf c2c tool provides means for Shared Data C2C/HITM analysis. It allows you to track down the cacheline contentions. .sp On Intel, the tool is based on load latency and precise store facility events provided by Intel CPUs. On PowerPC, the tool uses random instruction sampling with thresholding feature. On AMD, the tool uses IBS op pmu (due to hardware limitations, perf c2c is not supported on Zen3 cpus). On Arm64 it uses SPE to sample load and store operations, therefore hardware and kernel support is required. See perf\-arm\-spe(1) for a setup guide. Due to the statistical nature of Arm SPE sampling, not every memory operation will be sampled. .sp These events provide: \- memory address of the access \- type of the access (load and store details) \- latency (in cycles) of the load access .sp The c2c tool provide means to record this data and report back access details for cachelines with highest contention \- highest number of HITM accesses. .sp The basic workflow with this tool follows the standard record/report phase. User uses the record command to record events data and report command to display it. .SH "RECORD OPTIONS" .sp \-e, \-\-event= .RS 4 Select the PMU event. Use \fIperf c2c record \-e list\fP to list available events. .RE .sp \-v, \-\-verbose .RS 4 Be more verbose (show counter open errors, etc). .RE .sp \-l, \-\-ldlat .RS 4 Configure mem\-loads latency. Supported on Intel and Arm64 processors only. Ignored on other archs. .RE .sp \-k, \-\-all\-kernel .RS 4 Configure all used events to run in kernel space. .RE .sp \-u, \-\-all\-user .RS 4 Configure all used events to run in user space. .RE .SH "REPORT OPTIONS" .sp \-k, \-\-vmlinux= .RS 4 vmlinux pathname .RE .sp \-v, \-\-verbose .RS 4 Be more verbose (show counter open errors, etc). .RE .sp \-i, \-\-input .RS 4 Specify the input file to process. .RE .sp \-N, \-\-node\-info .RS 4 Show extra node info in report (see NODE INFO section) .RE .sp \-c, \-\-coalesce .RS 4 Specify sorting fields for single cacheline display. Following fields are available: tid,pid,iaddr,dso (see COALESCE) .RE .sp \-g, \-\-call\-graph .RS 4 Setup callchains parameters. Please refer to perf\-report man page for details. .RE .sp \-\-stdio .RS 4 Force the stdio output (see STDIO OUTPUT) .RE .sp \-\-stats .RS 4 Display only statistic tables and force stdio mode. .RE .sp \-\-full\-symbols .RS 4 Display full length of symbols. .RE .sp \-\-no\-source .RS 4 Do not display Source:Line column. .RE .sp \-\-show\-all .RS 4 Show all captured HITM lines, with no regard to HITM % 0.0005 limit. .RE .sp \-f, \-\-force .RS 4 Don\(cqt do ownership validation. .RE .sp \-d, \-\-display .RS 4 Switch to HITM type (rmt, lcl) or peer snooping type (peer) to display and sort on. Total HITMs (tot) as default, except Arm64 uses peer mode as default. .RE .sp \-\-stitch\-lbr .RS 4 Show callgraph with stitched LBRs, which may have more complete callgraph. The perf.data file must have been obtained using perf c2c record \-\-call\-graph lbr. Disabled by default. In common cases with call stack overflows, it can recreate better call stacks than the default lbr call stack output. But this approach is not foolproof. There can be cases where it creates incorrect call stacks from incorrect matches. The known limitations include exception handing such as setjmp/longjmp will have calls/returns not match. .RE .sp \-\-double\-cl .RS 4 Group the detection of shared cacheline events into double cacheline granularity. Some architectures have an Adjacent Cacheline Prefetch feature, which causes cacheline sharing to behave like the cacheline size is doubled. .RE .SH "C2C RECORD" .sp The perf c2c record command setup options related to HITM cacheline analysis and calls standard perf record command. .sp Following perf record options are configured by default: (check perf record man page for details) .sp .if n .RS 4 .nf .fam C \-W,\-d,\-\-phys\-data,\-\-sample\-cpu .fam .fi .if n .RE .sp Unless specified otherwise with \fI\-e\fP option, following events are monitored by default on Intel: .sp .if n .RS 4 .nf .fam C cpu/mem\-loads,ldlat=30/P cpu/mem\-stores/P .fam .fi .if n .RE .sp following on AMD: .sp .if n .RS 4 .nf .fam C ibs_op// .fam .fi .if n .RE .sp and following on PowerPC: .sp .if n .RS 4 .nf .fam C cpu/mem\-loads/ cpu/mem\-stores/ .fam .fi .if n .RE .sp User can pass any \fIperf record\fP option behind \fI\-\-\fP mark, like (to enable callchains and system wide monitoring): .sp .if n .RS 4 .nf .fam C $ perf c2c record \-\- \-g \-a .fam .fi .if n .RE .sp Please check RECORD OPTIONS section for specific c2c record options. .SH "C2C REPORT" .sp The perf c2c report command displays shared data analysis. It comes in two display modes: stdio and tui (default). .sp The report command workflow is following: \- sort all the data based on the cacheline address \- store access details for each cacheline \- sort all cachelines based on user settings \- display data .sp In general perf report output consist of 2 basic views: 1) most expensive cachelines list 2) offsets details for each cacheline .sp For each cacheline in the 1) list we display following data: (Both stdio and TUI modes follow the same fields output) .sp .if n .RS 4 .nf .fam C Index \- zero based index to identify the cacheline .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Cacheline \- cacheline address (hex number) .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Rmt/Lcl Hitm (Display with HITM types) \- cacheline percentage of all Remote/Local HITM accesses .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Peer Snoop (Display with peer type) \- cacheline percentage of all peer accesses .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C LLC Load Hitm \- Total, LclHitm, RmtHitm (For display with HITM types) \- count of Total/Local/Remote load HITMs .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Load Peer \- Total, Local, Remote (For display with peer type) \- count of Total/Local/Remote load from peer cache or DRAM .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Total records \- sum of all cachelines accesses .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Total loads \- sum of all load accesses .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Total stores \- sum of all store accesses .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Store Reference \- L1Hit, L1Miss, N/A L1Hit \- store accesses that hit L1 L1Miss \- store accesses that missed L1 N/A \- store accesses with memory level is not available .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Core Load Hit \- FB, L1, L2 \- count of load hits in FB (Fill Buffer), L1 and L2 cache .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C LLC Load Hit \- LlcHit, LclHitm \- count of LLC load accesses, includes LLC hits and LLC HITMs .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C RMT Load Hit \- RmtHit, RmtHitm \- count of remote load accesses, includes remote hits and remote HITMs; on Arm neoverse cores, RmtHit is used to account remote accesses, includes remote DRAM or any upward cache level in remote node .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Load Dram \- Lcl, Rmt \- count of local and remote DRAM accesses .fam .fi .if n .RE .sp For each offset in the 2) list we display following data: .sp .if n .RS 4 .nf .fam C HITM \- Rmt, Lcl (Display with HITM types) \- % of Remote/Local HITM accesses for given offset within cacheline .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Peer Snoop \- Rmt, Lcl (Display with peer type) \- % of Remote/Local peer accesses for given offset within cacheline .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Store Refs \- L1 Hit, L1 Miss, N/A \- % of store accesses that hit L1, missed L1 and N/A (no available) memory level for given offset within cacheline .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Data address \- Offset \- offset address .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Pid \- pid of the process responsible for the accesses .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Tid \- tid of the process responsible for the accesses .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Code address \- code address responsible for the accesses .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C cycles \- rmt hitm, lcl hitm, load (Display with HITM types) \- sum of cycles for given accesses \- Remote/Local HITM and generic load .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C cycles \- rmt peer, lcl peer, load (Display with peer type) \- sum of cycles for given accesses \- Remote/Local peer load and generic load .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C cpu cnt \- number of cpus that participated on the access .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Symbol \- code symbol related to the \*(AqCode address\*(Aq value .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Shared Object \- shared object name related to the \*(AqCode address\*(Aq value .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Source:Line \- source information related to the \*(AqCode address\*(Aq value .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Node \- nodes participating on the access (see NODE INFO section) .fam .fi .if n .RE .SH "NODE INFO" .sp The \fINode\fP field displays nodes that accesses given cacheline offset. Its output comes in 3 flavors: \- node IDs separated by \fI,\fP \- node IDs with stats for each ID, in following format: Node{cpus %hitms %stores} (Display with HITM types) Node{cpus %peers %stores} (Display with peer type) \- node IDs with list of affected CPUs in following format: Node{cpu list} .sp User can switch between above flavors with \-N option or use \fIn\fP key to interactively switch in TUI mode. .SH "COALESCE" .sp User can specify how to sort offsets for cacheline. .sp Following fields are available and governs the final output fields set for cacheline offsets output: .sp .if n .RS 4 .nf .fam C tid \- coalesced by process TIDs pid \- coalesced by process PIDs iaddr \- coalesced by code address, following fields are displayed: Code address, Code symbol, Shared Object, Source line dso \- coalesced by shared object .fam .fi .if n .RE .sp By default the coalescing is setup with \fIpid,iaddr\fP. .SH "STDIO OUTPUT" .sp The stdio output displays data on standard output. .sp Following tables are displayed: Trace Event Information \- overall statistics of memory accesses .sp .if n .RS 4 .nf .fam C Global Shared Cache Line Event Information \- overall statistics on shared cachelines .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Shared Data Cache Line Table \- list of most expensive cachelines .fam .fi .if n .RE .sp .if n .RS 4 .nf .fam C Shared Cache Line Distribution Pareto \- list of all accessed offsets for each cacheline .fam .fi .if n .RE .SH "TUI OUTPUT" .sp The TUI output provides interactive interface to navigate through cachelines list and to display offset details. .sp For details please refer to the help window by pressing \fI?\fP key. .SH "CREDITS" .sp Although Don Zickus, Dick Fowles and Joe Mario worked together to get this implemented, we got lots of early help from Arnaldo Carvalho de Melo, Stephane Eranian, Jiri Olsa and Andi Kleen. .SH "C2C BLOG" .sp Check Joe\(cqs blog on c2c tool for detailed use case explanation: .URL "https://joemario.github.io/blog/2016/09/01/c2c\-blog/" "" "" .SH "SEE ALSO" .sp perf\-record(1), perf\-mem(1), perf\-arm\-spe(1)