6a533d52ba
Resolves: bz2088798 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2088798 Signed-off-by: Pingfan Liu <piliu@redhat.com>
146 lines
4.1 KiB
Diff
146 lines
4.1 KiB
Diff
From 7fc232a4df2013089300b0c23490d7d07c9c0165 Mon Sep 17 00:00:00 2001
|
|
From: Sandipan Das <sandipan.das@amd.com>
|
|
Date: Fri, 20 Jan 2023 14:19:29 +0530
|
|
Subject: [PATCH 11/15] x86/zen: Add Zen 4 support
|
|
|
|
Add vendor and family identification as well as the relevant
|
|
events to count per-process memory accesseses and CPU usage
|
|
on AMD Zen 4 family of processors.
|
|
|
|
Key changes include the use of the LsNotHaltedP0Cyc event to
|
|
count cycles at P0 frequency. This improves the accuracy of
|
|
the utilization metrics as, unlike the typical cycles event,
|
|
this is clock frequency invariant.
|
|
|
|
Signed-off-by: Sandipan Das <sandipan.das@amd.com>
|
|
---
|
|
x86/include/types.h | 5 +++--
|
|
x86/include/zen.h | 1 +
|
|
x86/plat.c | 18 ++++++++++++++----
|
|
x86/zen.c | 14 ++++++++++++++
|
|
4 files changed, 32 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/x86/include/types.h b/x86/include/types.h
|
|
index 4aa5fa6..bb965f9 100644
|
|
--- a/x86/include/types.h
|
|
+++ b/x86/include/types.h
|
|
@@ -48,10 +48,11 @@ typedef enum {
|
|
CPU_ICX,
|
|
CPU_SPR,
|
|
CPU_ZEN,
|
|
- CPU_ZEN3
|
|
+ CPU_ZEN3,
|
|
+ CPU_ZEN4
|
|
} cpu_type_t;
|
|
|
|
-#define CPU_TYPE_NUM 14
|
|
+#define CPU_TYPE_NUM 15
|
|
|
|
typedef enum {
|
|
PERF_COUNT_INVALID = -1,
|
|
diff --git a/x86/include/zen.h b/x86/include/zen.h
|
|
index b5c40f5..cbdfcd8 100644
|
|
--- a/x86/include/zen.h
|
|
+++ b/x86/include/zen.h
|
|
@@ -41,6 +41,7 @@ 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 zen4_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 35561dc..fe2bf01 100644
|
|
--- a/x86/plat.c
|
|
+++ b/x86/plat.c
|
|
@@ -53,7 +53,8 @@ s_plat_profiling_config[CPU_TYPE_NUM] = {
|
|
icx_profiling_config,
|
|
spr_profiling_config,
|
|
zen_profiling_config,
|
|
- zen3_profiling_config
|
|
+ zen3_profiling_config,
|
|
+ zen4_profiling_config
|
|
};
|
|
|
|
pfn_plat_ll_config_t
|
|
@@ -71,6 +72,7 @@ s_plat_ll_config[CPU_TYPE_NUM] = {
|
|
icx_ll_config,
|
|
spr_ll_config,
|
|
zen_ll_config,
|
|
+ zen_ll_config,
|
|
zen_ll_config
|
|
};
|
|
|
|
@@ -89,6 +91,7 @@ s_plat_offcore_num[CPU_TYPE_NUM] = {
|
|
icx_offcore_num,
|
|
spr_offcore_num,
|
|
zen_offcore_num,
|
|
+ zen_offcore_num,
|
|
zen_offcore_num
|
|
};
|
|
|
|
@@ -191,10 +194,16 @@ cpu_type_get(void)
|
|
type = CPU_SPR;
|
|
break;
|
|
}
|
|
- } else if (family == 23) {
|
|
+ } else if (family == 23) { /* Family 17h */
|
|
type = CPU_ZEN;
|
|
- } else if (family == 25) {
|
|
- type = CPU_ZEN3;
|
|
+ } else if (family == 25) { /* Family 19h */
|
|
+ if ((model >= 0x00 && model <= 0x0f) ||
|
|
+ (model >= 0x20 && model <= 0x2f) ||
|
|
+ (model >= 0x40 && model <= 0x5f)) {
|
|
+ type = CPU_ZEN3;
|
|
+ } else {
|
|
+ type = CPU_ZEN4;
|
|
+ }
|
|
}
|
|
|
|
return (type);
|
|
@@ -236,6 +245,7 @@ plat_detect(void)
|
|
case CPU_SPR:
|
|
case CPU_ZEN:
|
|
case CPU_ZEN3:
|
|
+ case CPU_ZEN4:
|
|
ret = 0;
|
|
s_cpu_type = cpu_type;
|
|
break;
|
|
diff --git a/x86/zen.c b/x86/zen.c
|
|
index dd37d03..c21eb1a 100644
|
|
--- a/x86/zen.c
|
|
+++ b/x86/zen.c
|
|
@@ -60,6 +60,14 @@ static plat_event_config_t s_zen3_config[PERF_COUNT_NUM] = {
|
|
{ PERF_TYPE_RAW, 0x0000000000000844, 0, 0, 0, 0, "LsAnyFillsFromSys.MemIoLocal" },
|
|
};
|
|
|
|
+static plat_event_config_t s_zen4_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_RAW, 0x0000000100000120, 0, 0, 0, 0, "LsNotHaltedP0Cyc.P0FreqCyc" },
|
|
+ { 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
|
|
@@ -81,6 +89,12 @@ 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);
|
|
}
|
|
|
|
+void
|
|
+zen4_profiling_config(perf_count_id_t perf_count_id, plat_event_config_t *cfg)
|
|
+{
|
|
+ plat_config_get(perf_count_id, cfg, s_zen4_config);
|
|
+}
|
|
+
|
|
static int
|
|
zen_ibs_op_pmu_type(void)
|
|
{
|
|
--
|
|
2.31.1
|
|
|