[PATCH 20/25] perf mem: Print extended fields
Leo Yan
leo.yan at arm.com
Mon Sep 29 09:37:56 PDT 2025
Print the extended operation types and affiliate info.
Signed-off-by: Leo Yan <leo.yan at arm.com>
---
tools/include/uapi/linux/perf_event.h | 28 +++++++++++++++--
tools/perf/util/mem-events.c | 58 +++++++++++++++++++++++++++++++++--
2 files changed, 82 insertions(+), 4 deletions(-)
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index 78a362b8002776e5ce83a0d7816601638c61ecc6..51ab37d44ac31fcdc4bc919c14d5f97e560d9339 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -1309,14 +1309,18 @@ union perf_mem_data_src {
mem_snoopx : 2, /* Snoop mode, ext */
mem_blk : 3, /* Access blocked */
mem_hops : 3, /* Hop level */
- mem_rsvd : 18;
+ mem_op_ext : 6, /* Extended type of opcode */
+ mem_aff : 8, /* Affiliate info */
+ mem_rsvd : 4;
};
};
#elif defined(__BIG_ENDIAN_BITFIELD)
union perf_mem_data_src {
__u64 val;
struct {
- __u64 mem_rsvd : 18,
+ __u64 mem_rsvd : 4,
+ mem_aff : 8, /* Affiliate info */
+ mem_op_ext : 6, /* Extended type of opcode */
mem_hops : 3, /* Hop level */
mem_blk : 3, /* Access blocked */
mem_snoopx : 2, /* Snoop mode, ext */
@@ -1426,6 +1430,26 @@ union perf_mem_data_src {
/* 5-7 available */
#define PERF_MEM_HOPS_SHIFT 43
+/* Extended type of memory opcode: */
+#define PERF_MEM_EXT_OP_MTE_TAG 0x0001 /* MTE tag */
+#define PERF_MEM_EXT_OP_NESTED_VIRT 0x0002 /* Nested virtualization */
+#define PERF_MEM_EXT_OP_MEMCPY 0x0004 /* Memory copy */
+#define PERF_MEM_EXT_OP_MEMSET 0x0008 /* Memory set */
+#define PERF_MEM_EXT_OP_SIMD 0x0010 /* SIMD */
+#define PERF_MEM_EXT_OP_GCS 0x0020 /* Guarded Control Stack */
+#define PERF_MEM_EXT_OP_SHIFT 46
+
+/* Affiliate info */
+#define PERF_MEM_AFF_DP 0x0001 /* Data processing */
+#define PERF_MEM_AFF_FP 0x0002 /* Floating-point */
+#define PERF_MEM_AFF_PRED 0x0004 /* Predicated */
+#define PERF_MEM_AFF_ATOMIC 0x0008 /* Atomic */
+#define PERF_MEM_AFF_EXCLUSIVE 0x0010 /* Exclusive */
+#define PERF_MEM_AFF_AR 0x0020 /* Acquire/release */
+#define PERF_MEM_AFF_SG 0x0040 /* Gather/Scatter */
+#define PERF_MEM_AFF_CONDITIONAL 0x0080 /* Conditional */
+#define PERF_MEM_AFF_SHIFT 52
+
#define PERF_MEM_S(a, s) \
(((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT)
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 80b3069427bc4bb5ffc3ab0856c01c76d9ba3ba6..2d052abfa39d841f75b4b16143641841d8577d0c 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -413,11 +413,13 @@ static const char * const mem_hops[] = {
static int perf_mem__op_scnprintf(char *out, size_t sz, const struct mem_info *mem_info)
{
- u64 op = PERF_MEM_LOCK_NA;
+ u64 op = PERF_MEM_OP_NA, ext_op = 0;
int l;
- if (mem_info)
+ if (mem_info) {
op = mem_info__const_data_src(mem_info)->mem_op;
+ ext_op = mem_info__const_data_src(mem_info)->mem_op_ext;
+ }
if (op & PERF_MEM_OP_NA)
l = scnprintf(out, sz, "N/A");
@@ -432,6 +434,19 @@ static int perf_mem__op_scnprintf(char *out, size_t sz, const struct mem_info *m
else
l = scnprintf(out, sz, "No");
+ if (ext_op & PERF_MEM_EXT_OP_MTE_TAG)
+ l += scnprintf(out + l, sz - l, " MTE");
+ else if (ext_op & PERF_MEM_EXT_OP_NESTED_VIRT)
+ l += scnprintf(out + l, sz - l, " NV");
+ else if (ext_op & PERF_MEM_EXT_OP_MEMCPY)
+ l += scnprintf(out + l, sz - l, " MEMCPY");
+ else if (ext_op & PERF_MEM_EXT_OP_MEMSET)
+ l += scnprintf(out + l, sz - l, " MEMSET");
+ else if (ext_op & PERF_MEM_EXT_OP_SIMD)
+ l += scnprintf(out + l, sz - l, " SIMD");
+ else if (ext_op & PERF_MEM_EXT_OP_GCS)
+ l += scnprintf(out + l, sz - l, " GCS");
+
return l;
}
@@ -600,6 +615,43 @@ int perf_mem__blk_scnprintf(char *out, size_t sz, const struct mem_info *mem_inf
return l;
}
+static int perf_mem__aff_scnprintf(char *out, size_t sz,
+ const struct mem_info *mem_info)
+{
+ size_t l = 0;
+ u64 mask = 0;
+
+ sz -= 1; /* -1 for null termination */
+ out[0] = '\0';
+
+ if (mem_info)
+ mask = mem_info__const_data_src(mem_info)->mem_aff;
+
+ if (!mask) {
+ l += scnprintf(out + l, sz - l, " N/A");
+ return l;
+ }
+
+ if (mask & PERF_MEM_AFF_DP)
+ l += scnprintf(out + l, sz - l, " DP");
+ if (mask & PERF_MEM_AFF_FP)
+ l += scnprintf(out + l, sz - l, " FP");
+ if (mask & PERF_MEM_AFF_PRED)
+ l += scnprintf(out + l, sz - l, " PRED");
+ if (mask & PERF_MEM_AFF_ATOMIC)
+ l += scnprintf(out + l, sz - l, " ATOMIC");
+ if (mask & PERF_MEM_AFF_EXCLUSIVE)
+ l += scnprintf(out + l, sz - l, " EX");
+ if (mask & PERF_MEM_AFF_AR)
+ l += scnprintf(out + l, sz - l, " AR");
+ if (mask & PERF_MEM_AFF_SG)
+ l += scnprintf(out + l, sz - l, " SG");
+ if (mask & PERF_MEM_AFF_CONDITIONAL)
+ l += scnprintf(out + l, sz - l, " COND");
+
+ return l;
+}
+
int perf_script__meminfo_scnprintf(char *out, size_t sz, const struct mem_info *mem_info)
{
int i = 0;
@@ -616,6 +668,8 @@ int perf_script__meminfo_scnprintf(char *out, size_t sz, const struct mem_info *
i += perf_mem__lck_scnprintf(out + i, sz - i, mem_info);
i += scnprintf(out + i, sz - i, "|BLK ");
i += perf_mem__blk_scnprintf(out + i, sz - i, mem_info);
+ i += scnprintf(out + i, sz - i, "|AFF ");
+ i += perf_mem__aff_scnprintf(out + i, sz - i, mem_info);
return i;
}
--
2.34.1
More information about the linux-arm-kernel
mailing list