Skip to content

Commit 080fe0b

Browse files
mflemingIngo Molnar
authored andcommitted
perf/x86/amd: Make HW_CACHE_REFERENCES and HW_CACHE_MISSES measure L2
While the Intel PMU monitors the LLC when perf enables the HW_CACHE_REFERENCES and HW_CACHE_MISSES events, these events monitor L1 instruction cache fetches (0x0080) and instruction cache misses (0x0081) on the AMD PMU. This is extremely confusing when monitoring the same workload across Intel and AMD machines, since parameters like, $ perf stat -e cache-references,cache-misses measure completely different things. Instead, make the AMD PMU measure instruction/data cache and TLB fill requests to the L2 and instruction/data cache and TLB misses in the L2 when HW_CACHE_REFERENCES and HW_CACHE_MISSES are enabled, respectively. That way the events measure unified caches on both platforms. Signed-off-by: Matt Fleming <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Cc: <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 1155baf commit 080fe0b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

arch/x86/events/amd/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ static const u64 amd_perfmon_event_map[PERF_COUNT_HW_MAX] =
119119
{
120120
[PERF_COUNT_HW_CPU_CYCLES] = 0x0076,
121121
[PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
122-
[PERF_COUNT_HW_CACHE_REFERENCES] = 0x0080,
123-
[PERF_COUNT_HW_CACHE_MISSES] = 0x0081,
122+
[PERF_COUNT_HW_CACHE_REFERENCES] = 0x077d,
123+
[PERF_COUNT_HW_CACHE_MISSES] = 0x077e,
124124
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2,
125125
[PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3,
126126
[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00d0, /* "Decoder empty" event */

arch/x86/kvm/pmu_amd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
static struct kvm_event_hw_type_mapping amd_event_mapping[] = {
2424
[0] = { 0x76, 0x00, PERF_COUNT_HW_CPU_CYCLES },
2525
[1] = { 0xc0, 0x00, PERF_COUNT_HW_INSTRUCTIONS },
26-
[2] = { 0x80, 0x00, PERF_COUNT_HW_CACHE_REFERENCES },
27-
[3] = { 0x81, 0x00, PERF_COUNT_HW_CACHE_MISSES },
26+
[2] = { 0x7d, 0x07, PERF_COUNT_HW_CACHE_REFERENCES },
27+
[3] = { 0x7e, 0x07, PERF_COUNT_HW_CACHE_MISSES },
2828
[4] = { 0xc2, 0x00, PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
2929
[5] = { 0xc3, 0x00, PERF_COUNT_HW_BRANCH_MISSES },
3030
[6] = { 0xd0, 0x00, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND },

0 commit comments

Comments
 (0)