From e9bd7eaa767c987fcb8d6879e7c7509a24bcb17c Mon Sep 17 00:00:00 2001 From: Sandipan Das Date: Fri, 20 Jan 2023 13:56:37 +0530 Subject: [PATCH 10/15] x86/zen: Add Zen 3 support Add vendor and family identification as well as the relevant events to count per-process memory accesseses and CPU usage on AMD Zen 3 family of processors. Key changes include the use of the LsAnyFillsFromSys event instead of LsDmndFillsFromSys for counting local and remote memory accesses. While LsDmndFillsFromSys covers only demand cache fills, LsAnyFillsFromSys covers all cache fills including prefetches. Signed-off-by: Sandipan Das --- x86/include/types.h | 5 +++-- x86/include/zen.h | 1 + x86/plat.c | 8 +++++++- x86/zen.c | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/x86/include/types.h b/x86/include/types.h index 0843bd1..4aa5fa6 100644 --- a/x86/include/types.h +++ b/x86/include/types.h @@ -47,10 +47,11 @@ typedef enum { CPU_SKX, CPU_ICX, CPU_SPR, - CPU_ZEN + CPU_ZEN, + CPU_ZEN3 } cpu_type_t; -#define CPU_TYPE_NUM 13 +#define CPU_TYPE_NUM 14 typedef enum { PERF_COUNT_INVALID = -1, diff --git a/x86/include/zen.h b/x86/include/zen.h index be61324..b5c40f5 100644 --- a/x86/include/zen.h +++ b/x86/include/zen.h @@ -40,6 +40,7 @@ extern "C" { struct _plat_event_config; extern void zen_profiling_config(perf_count_id_t, struct _plat_event_config *); +extern void zen3_profiling_config(perf_count_id_t, struct _plat_event_config *); extern void zen_ll_config(struct _plat_event_config *); extern int zen_offcore_num(void); diff --git a/x86/plat.c b/x86/plat.c index f79837a..35561dc 100644 --- a/x86/plat.c +++ b/x86/plat.c @@ -52,7 +52,8 @@ s_plat_profiling_config[CPU_TYPE_NUM] = { skl_profiling_config, icx_profiling_config, spr_profiling_config, - zen_profiling_config + zen_profiling_config, + zen3_profiling_config }; pfn_plat_ll_config_t @@ -69,6 +70,7 @@ s_plat_ll_config[CPU_TYPE_NUM] = { skl_ll_config, icx_ll_config, spr_ll_config, + zen_ll_config, zen_ll_config }; @@ -86,6 +88,7 @@ s_plat_offcore_num[CPU_TYPE_NUM] = { skl_offcore_num, icx_offcore_num, spr_offcore_num, + zen_offcore_num, zen_offcore_num }; @@ -190,6 +193,8 @@ cpu_type_get(void) } } else if (family == 23) { type = CPU_ZEN; + } else if (family == 25) { + type = CPU_ZEN3; } return (type); @@ -230,6 +235,7 @@ plat_detect(void) case CPU_ICX: case CPU_SPR: case CPU_ZEN: + case CPU_ZEN3: ret = 0; s_cpu_type = cpu_type; break; diff --git a/x86/zen.c b/x86/zen.c index 67a425b..dd37d03 100644 --- a/x86/zen.c +++ b/x86/zen.c @@ -52,6 +52,14 @@ static plat_event_config_t s_zen_config[PERF_COUNT_NUM] = { { PERF_TYPE_RAW, 0x0000000000000843, 0, 0, 0, 0, "LsDmndFillsFromSys.DRAM_IO_Near" }, }; +static plat_event_config_t s_zen3_config[PERF_COUNT_NUM] = { + { PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, 0, 0, 0, 0, "LsNotHaltedCyc" }, + { PERF_TYPE_RAW, 0x0000000000004044, 0, 0, 0, 0, "LsAnyFillsFromSys.MemIoRemote" }, + { PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, 0, 0, 0, 0, "LsNotHaltedCyc" }, + { PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, 0x53, 0, 0, 0, "ExRetOps" }, + { PERF_TYPE_RAW, 0x0000000000000844, 0, 0, 0, 0, "LsAnyFillsFromSys.MemIoLocal" }, +}; + /* * Owing to the nature of IBS uop tagging, a higher sampling period is * required to capture meaningful samples. All samples may not originate @@ -67,6 +75,12 @@ zen_profiling_config(perf_count_id_t perf_count_id, plat_event_config_t *cfg) plat_config_get(perf_count_id, cfg, s_zen_config); } +void +zen3_profiling_config(perf_count_id_t perf_count_id, plat_event_config_t *cfg) +{ + plat_config_get(perf_count_id, cfg, s_zen3_config); +} + static int zen_ibs_op_pmu_type(void) { -- 2.31.1