linux/arch
Stephane Eranian 0036fb00a7 perf/x86/rapl: fix AMD event handling
The RAPL events exposed under /sys/devices/power/events should only reflect
what the underlying hardware actually support. This is how it works on Intel
RAPL and Intel core/uncore PMUs in general.
But on AMD, this was not the case. All possible RAPL events were advertised.

This is what it showed on an AMD Fam17h:
$ ls /sys/devices/power/events/
energy-cores        energy-gpu          energy-pkg          energy-psys
energy-ram          energy-cores.scale  energy-gpu.scale    energy-pkg.scale
energy-psys.scale   energy-ram.scale    energy-cores.unit   energy-gpu.unit
energy-pkg.unit     energy-psys.unit    energy-ram.unit

Yet, on AMD Fam17h, only energy-pkg is supported.

This patch fixes the problem. Given the way perf_msr_probe() works, the
amd_rapl_msrs[] table has to have all entries filled out and in particular
the group field, otherwise perf_msr_probe() defaults to making the event
visible.

With the patch applied, the kernel now only shows was is actually supported:

$ ls /sys/devices/power/events/
energy-pkg  energy-pkg.scale  energy-pkg.unit

The patch also uses the RAPL_MSR_MASK because only the 32-bits LSB of the
RAPL counters are relevant when reading power consumption.

Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220105185659.643355-1-eranian@google.com
2022-01-18 12:09:48 +01:00
..
alpha TTY/Serial driver updates for 5.17-rc1 2022-01-12 11:21:52 -08:00
arc
arm LED updates for 5.17. Nothing major is happening here. 2022-01-12 16:59:22 -08:00
arm64 Peter Zijlstra says: 2022-01-12 16:26:58 -08:00
csky Peter Zijlstra says: 2022-01-12 16:26:58 -08:00
h8300
hexagon
ia64
m68k Peter Zijlstra says: 2022-01-11 17:24:45 -08:00
microblaze
mips Rework of the MSI interrupt infrastructure: 2022-01-13 09:05:29 -08:00
nds32 Peter Zijlstra says: 2022-01-12 16:26:58 -08:00
nios2
openrisc
parisc parisc: Default to 16 CPUs on 32-bit kernel 2022-01-11 11:57:38 +01:00
powerpc Rework of the MSI interrupt infrastructure: 2022-01-13 09:05:29 -08:00
riscv Peter Zijlstra says: 2022-01-12 16:26:58 -08:00
s390 Rework of the MSI interrupt infrastructure: 2022-01-13 09:05:29 -08:00
sh driver core changes for 5.17-rc1 2022-01-12 11:11:34 -08:00
sparc Rework of the MSI interrupt infrastructure: 2022-01-13 09:05:29 -08:00
um Peter Zijlstra says: 2022-01-11 17:24:45 -08:00
x86 perf/x86/rapl: fix AMD event handling 2022-01-18 12:09:48 +01:00
xtensa
.gitignore
Kconfig - Add support for handling hw errors in SGX pages: poisoning, recovering 2022-01-10 09:44:09 -08:00