Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf: Add mem_hops field in perf_mem_data_src structure

Going forward, future generation systems can have more hierarchy
within the node/package level but currently we don't have any data source
encoding field in perf, which can be used to represent this level of data.

Add a new field called 'mem_hops' in the perf_mem_data_src structure
which can be used to represent intra-node/package or inter-node/off-package
details. This field is of size 3 bits where PERF_MEM_HOPS_{NA, 0..6} value
can be used to present different hop levels data.

Also add corresponding macros to define mem_hop field values
and shift value.

Currently we define macro for HOPS_0 which corresponds
to data coming from another core but same node.

For ex: Encodings for mem_hops fields with L2 cache:

L2 - local L2
L2 | REMOTE | HOPS_0 - remote core, same node L2

Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20211006140654.298352-3-kjain@linux.ibm.com

authored by

Kajol Jain and committed by
Peter Zijlstra
fec9cc61 f4c6217f

+9 -2
+9 -2
include/uapi/linux/perf_event.h
··· 1225 1225 mem_remote:1, /* remote */ 1226 1226 mem_snoopx:2, /* snoop mode, ext */ 1227 1227 mem_blk:3, /* access blocked */ 1228 - mem_rsvd:21; 1228 + mem_hops:3, /* hop level */ 1229 + mem_rsvd:18; 1229 1230 }; 1230 1231 }; 1231 1232 #elif defined(__BIG_ENDIAN_BITFIELD) 1232 1233 union perf_mem_data_src { 1233 1234 __u64 val; 1234 1235 struct { 1235 - __u64 mem_rsvd:21, 1236 + __u64 mem_rsvd:18, 1237 + mem_hops:3, /* hop level */ 1236 1238 mem_blk:3, /* access blocked */ 1237 1239 mem_snoopx:2, /* snoop mode, ext */ 1238 1240 mem_remote:1, /* remote */ ··· 1329 1327 #define PERF_MEM_BLK_DATA 0x02 /* data could not be forwarded */ 1330 1328 #define PERF_MEM_BLK_ADDR 0x04 /* address conflict */ 1331 1329 #define PERF_MEM_BLK_SHIFT 40 1330 + 1331 + /* hop level */ 1332 + #define PERF_MEM_HOPS_0 0x01 /* remote core, same node */ 1333 + /* 2-7 available */ 1334 + #define PERF_MEM_HOPS_SHIFT 43 1332 1335 1333 1336 #define PERF_MEM_S(a, s) \ 1334 1337 (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT)