Skip to contentSkip to conversation

x86: amd: pmu: test performance counter on AMD

PATCH New SU Hang 1 participant 1 message Jul 27, 2022 KVM

lore
Share & tools
lore

SU Hang

author
#0 lore raw

PATCH v2 1/1 x86: amd: pmu: test performance counter on AMD

This test adds performance counter test for AMD CPU, it tests old performance legacy 4 counters [1] since Family 6(that is AMD K7 CPU), and new 6 counters [2] since Family 21 (15H).

And because AMD doesn't have some MSRs(e.g. MSR_CORE_PERF_GLOBAL_STATUS) and fixed counters as Intel, simply disable corresponding statements or cases.

Another thing worth mentioning is, AMD perf counter doesn't support select 'reference cycle', disable it too.

Quoted 2 lines

refs[1]: MSRC001_000[4...7] [Performance Event Counter [3:0]] (Core::X86::Msr::PERF_LEGACY_CTR) refs[2]: MSRC001_020[1...B] [Performance Event Counter [5:0]] (Core::X86::Msr::PERF_CTR)

---
 lib/x86/msr.h |  23 +++++
 x86/pmu.c     | 251 ++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 223 insertions(+), 51 deletions(-)
lib/x86/msr.h +23 -0
index fa1c0c8..a8aa907 100644
@@ -129,6 +129,29 @@
 #define MSR_AMD64_IBSDCPHYSAD		0xc0011039
 #define MSR_AMD64_IBSCTL		0xc001103a
 
+/* Fam 15h MSRs */
+#define MSR_F15H_PERF_CTL		0xc0010200
+#define MSR_F15H_PERF_CTL0		MSR_F15H_PERF_CTL
+#define MSR_F15H_PERF_CTL1		(MSR_F15H_PERF_CTL + 2)
+#define MSR_F15H_PERF_CTL2		(MSR_F15H_PERF_CTL + 4)
+#define MSR_F15H_PERF_CTL3		(MSR_F15H_PERF_CTL + 6)
+#define MSR_F15H_PERF_CTL4		(MSR_F15H_PERF_CTL + 8)
+#define MSR_F15H_PERF_CTL5		(MSR_F15H_PERF_CTL + 10)
+
+#define MSR_F15H_PERF_CTR		0xc0010201
+#define MSR_F15H_PERF_CTR0		MSR_F15H_PERF_CTR
+#define MSR_F15H_PERF_CTR1		(MSR_F15H_PERF_CTR + 2)
+#define MSR_F15H_PERF_CTR2		(MSR_F15H_PERF_CTR + 4)
+#define MSR_F15H_PERF_CTR3		(MSR_F15H_PERF_CTR + 6)
+#define MSR_F15H_PERF_CTR4		(MSR_F15H_PERF_CTR + 8)
+#define MSR_F15H_PERF_CTR5		(MSR_F15H_PERF_CTR + 10)
+
+#define MSR_F15H_NB_PERF_CTL		0xc0010240
+#define MSR_F15H_NB_PERF_CTR		0xc0010241
+#define MSR_F15H_PTSC			0xc0010280
+#define MSR_F15H_IC_CFG			0xc0011021
+#define MSR_F15H_EX_CFG			0xc001102c
+
 /* Fam 10h MSRs */
 #define MSR_FAM10H_MMIO_CONF_BASE	0xc0010058
 #define FAM10H_MMIO_CONF_ENABLE		(1<<0)
x86/pmu.c +200 -51

406 lines not on this page · raw message

Signature · 1 line
2.32.1 (Apple Git-133)