From 6af2ed53f0402c09b36d2b38698e18a25ca732a7 Mon Sep 17 00:00:00 2001 From: Janakarajan Natarajan Date: Tue, 5 Nov 2019 17:16:55 +0000 Subject: cpupower: mperf_monitor: Update cpupower to use the RDPRU instruction AMD Zen 2 introduces the RDPRU instruction which can be used to access some processor registers which are typically only accessible in privilege level 0. ECX specifies the register to read and EDX:EAX will contain the value read. ECX: 0 - Register MPERF 1 - Register APERF This has the added advantage of not having to use the msr module, since the userspace to kernel transitions which occur during each read_msr() might cause APERF and MPERF to go out of sync. Signed-off-by: Janakarajan Natarajan Acked-by: Thomas Renninger Signed-off-by: Shuah Khan --- tools/power/cpupower/utils/helpers/cpuid.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools/power/cpupower/utils/helpers/cpuid.c') diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c index 5cc39d4e23ed..73bfafc60e9b 100644 --- a/tools/power/cpupower/utils/helpers/cpuid.c +++ b/tools/power/cpupower/utils/helpers/cpuid.c @@ -131,6 +131,10 @@ out: if (ext_cpuid_level >= 0x80000007 && (cpuid_edx(0x80000007) & (1 << 9))) cpu_info->caps |= CPUPOWER_CAP_AMD_CBP; + + if (ext_cpuid_level >= 0x80000008 && + cpuid_ebx(0x80000008) & (1 << 4)) + cpu_info->caps |= CPUPOWER_CAP_AMD_RDPRU; } if (cpu_info->vendor == X86_VENDOR_INTEL) { -- cgit v1.2.3