Skip to content

Commit 1f9d89d

Browse files
tlfalconx56Jason
authored andcommitted
perf mem: Fix printing PERF_MEM_LVLNUM_{L2_MHB|MSC}
commit 4f23fc34cc68812c68c3a3dec15e26e87565f430 upstream. With commit 8ec9497 ("tools/include: Sync uapi/linux/perf.h with the kernel sources"), 'perf mem report' gives an incorrect memory access string. ... 0.02% 1 3644 L5 hit [.] 0x0000000000009b0e mlc [.] 0x00007fce43f59480 ... This occurs because, if no entry exists in mem_lvlnum, perf_mem__lvl_scnprintf will default to 'L%d, lvl', which in this case for PERF_MEM_LVLNUM_L2_MHB is 0x05. Add entries for PERF_MEM_LVLNUM_L2_MHB and PERF_MEM_LVLNUM_MSC to mem_lvlnum, so that the correct strings are printed. ... 0.02% 1 3644 L2 MHB hit [.] 0x0000000000009b0e mlc [.] 0x00007fce43f59480 ... Intel-SIG: commit 4f23fc34cc68 perf mem: Fix printing PERF_MEM_LVLNUM_{L2_MHB|MSC} Backport CWF PMU support and dependency Fixes: 8ec9497 ("tools/include: Sync uapi/linux/perf.h with the kernel sources") Suggested-by: Kan Liang <[email protected]> Signed-off-by: Thomas Falcon <[email protected]> Reviewed-by: Leo Yan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Jason Zeng <[email protected]>
1 parent f8f3aca commit 1f9d89d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/perf/util/mem-events.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ static const char * const mem_lvl[] = {
297297
};
298298

299299
static const char * const mem_lvlnum[] = {
300+
[PERF_MEM_LVLNUM_L1] = "L1",
301+
[PERF_MEM_LVLNUM_L2] = "L2",
302+
[PERF_MEM_LVLNUM_L3] = "L3",
303+
[PERF_MEM_LVLNUM_L4] = "L4",
304+
[PERF_MEM_LVLNUM_L2_MHB] = "L2 MHB",
305+
[PERF_MEM_LVLNUM_MSC] = "Memory-side Cache",
300306
[PERF_MEM_LVLNUM_UNC] = "Uncached",
301307
[PERF_MEM_LVLNUM_CXL] = "CXL",
302308
[PERF_MEM_LVLNUM_IO] = "I/O",
@@ -379,7 +385,7 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
379385
if (mem_lvlnum[lvl])
380386
l += scnprintf(out + l, sz - l, mem_lvlnum[lvl]);
381387
else
382-
l += scnprintf(out + l, sz - l, "L%d", lvl);
388+
l += scnprintf(out + l, sz - l, "Unknown level %d", lvl);
383389

384390
l += scnprintf(out + l, sz - l, " %s", hit_miss);
385391
return l;

0 commit comments

Comments
 (0)