Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit c7b2edd

Browse files
sandip4nIngo Molnar
authored andcommitted
perf/x86/amd/core: Update and fix stalled-cycles-* events for Zen 2 and later
AMD processors based on Zen 2 and later microarchitectures do not support PMCx087 (instruction pipe stalls) which is used as the backing event for "stalled-cycles-frontend" and "stalled-cycles-backend". Use PMCx0A9 (cycles where micro-op queue is empty) instead to count frontend stalls and remove the entry for backend stalls since there is no direct replacement. Signed-off-by: Sandipan Das <sandipan.das@amd.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Ian Rogers <irogers@google.com> Fixes: 3fe3331 ("perf/x86/amd: Add event map for AMD Family 17h") Link: https://lore.kernel.org/r/03d7fc8fa2a28f9be732116009025bdec1b3ec97.1711352180.git.sandipan.das@amd.com
1 parent 598c2fa commit c7b2edd

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

arch/x86/events/amd/core.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static const u64 amd_perfmon_event_map[PERF_COUNT_HW_MAX] =
250250
/*
251251
* AMD Performance Monitor Family 17h and later:
252252
*/
253-
static const u64 amd_f17h_perfmon_event_map[PERF_COUNT_HW_MAX] =
253+
static const u64 amd_zen1_perfmon_event_map[PERF_COUNT_HW_MAX] =
254254
{
255255
[PERF_COUNT_HW_CPU_CYCLES] = 0x0076,
256256
[PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
@@ -262,10 +262,24 @@ static const u64 amd_f17h_perfmon_event_map[PERF_COUNT_HW_MAX] =
262262
[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x0187,
263263
};
264264

265+
static const u64 amd_zen2_perfmon_event_map[PERF_COUNT_HW_MAX] =
266+
{
267+
[PERF_COUNT_HW_CPU_CYCLES] = 0x0076,
268+
[PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
269+
[PERF_COUNT_HW_CACHE_REFERENCES] = 0xff60,
270+
[PERF_COUNT_HW_CACHE_MISSES] = 0x0964,
271+
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2,
272+
[PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3,
273+
[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00a9,
274+
};
275+
265276
static u64 amd_pmu_event_map(int hw_event)
266277
{
267-
if (boot_cpu_data.x86 >= 0x17)
268-
return amd_f17h_perfmon_event_map[hw_event];
278+
if (cpu_feature_enabled(X86_FEATURE_ZEN2) || boot_cpu_data.x86 >= 0x19)
279+
return amd_zen2_perfmon_event_map[hw_event];
280+
281+
if (cpu_feature_enabled(X86_FEATURE_ZEN1))
282+
return amd_zen1_perfmon_event_map[hw_event];
269283

270284
return amd_perfmon_event_map[hw_event];
271285
}

0 commit comments

Comments
 (0)