Skip to content

Commit 68cdf1e

Browse files
sandip4nIngo Molnar
authored andcommitted
perf/x86/amd/core: Define a proper ref-cycles event for Zen 4 and later
Add the "ref-cycles" event for AMD processors based on Zen 4 and later microarchitectures. The backing event is based on PMCx120 which counts cycles not in halt state in P0 frequency (same as MPERF). Signed-off-by: Sandipan Das <sandipan.das@amd.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/089155f19f7c7e65aeb1caa727a882e2ca9b8b04.1711352180.git.sandipan.das@amd.com
1 parent c7b2edd commit 68cdf1e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

arch/x86/events/amd/core.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,23 @@ static const u64 amd_zen2_perfmon_event_map[PERF_COUNT_HW_MAX] =
273273
[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00a9,
274274
};
275275

276+
static const u64 amd_zen4_perfmon_event_map[PERF_COUNT_HW_MAX] =
277+
{
278+
[PERF_COUNT_HW_CPU_CYCLES] = 0x0076,
279+
[PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
280+
[PERF_COUNT_HW_CACHE_REFERENCES] = 0xff60,
281+
[PERF_COUNT_HW_CACHE_MISSES] = 0x0964,
282+
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2,
283+
[PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3,
284+
[PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00a9,
285+
[PERF_COUNT_HW_REF_CPU_CYCLES] = 0x100000120,
286+
};
287+
276288
static u64 amd_pmu_event_map(int hw_event)
277289
{
290+
if (cpu_feature_enabled(X86_FEATURE_ZEN4) || boot_cpu_data.x86 >= 0x1a)
291+
return amd_zen4_perfmon_event_map[hw_event];
292+
278293
if (cpu_feature_enabled(X86_FEATURE_ZEN2) || boot_cpu_data.x86 >= 0x19)
279294
return amd_zen2_perfmon_event_map[hw_event];
280295

0 commit comments

Comments
 (0)