From a7acc9989076cd6a1f173976d8f2749fd2c4c9d0 Mon Sep 17 00:00:00 2001 From: Liao Xuan Date: Tue, 4 Mar 2025 02:03:40 -0500 Subject: [PATCH] anolis: perf/x86/amd/core: Fix performance monitor for Hygon family 18h processor ANBZ: #19176 The commit 69fe5f177ad3 ("perf/x86/amd/core: Update and fix stalled-cycles-* events for Zen 2 and later") changed amd_f17h_perfmon_event_map to amd_zen1_perfmon_event_map which is limited to processors only with X86_FEATURE_ZEN1. This makes some event counters such as cache-misses and cache-references can not be tracked on Hygon family 18h processors. When using perf tool to monitor performance, the result will be listed as follows: 0 cache-miesses # 0.000 % of all cache refs 0 cache-references So add perfmon_event_map support for Hygon family 18h processors to fix the incorrect display. Fixes: 69fe5f177ad3 ("perf/x86/amd/core: Update and fix stalled-cycles-* events for Zen 2 and later") Signed-off-by: Liao Xuan --- arch/x86/events/amd/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c index 4eacac39a501..f5e5906ae36c 100644 --- a/arch/x86/events/amd/core.c +++ b/arch/x86/events/amd/core.c @@ -296,6 +296,9 @@ static u64 amd_pmu_event_map(int hw_event) if (cpu_feature_enabled(X86_FEATURE_ZEN1)) return amd_zen1_perfmon_event_map[hw_event]; + if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) + return amd_zen1_perfmon_event_map[hw_event]; + return amd_perfmon_event_map[hw_event]; } -- Gitee