Patch "perf/x86/rapl: fix AMD event handling" has been added to the 5.16-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf/x86/rapl: fix AMD event handling

to the 5.16-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-x86-rapl-fix-amd-event-handling.patch
and it can be found in the queue-5.16 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 87fa827fbea004bccc9f101d468fb9ec11f4db07
Author: Stephane Eranian <eranian@xxxxxxxxxx>
Date:   Wed Jan 5 10:56:59 2022 -0800

    perf/x86/rapl: fix AMD event handling
    
    [ Upstream commit 0036fb00a756a2f6e360d44e2e3d2200a8afbc9b ]
    
    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@xxxxxxxxxx>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
    Link: https://lkml.kernel.org/r/20220105185659.643355-1-eranian@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
index 85feafacc445d..77e3a47af5ad5 100644
--- a/arch/x86/events/rapl.c
+++ b/arch/x86/events/rapl.c
@@ -536,11 +536,14 @@ static struct perf_msr intel_rapl_spr_msrs[] = {
  * - perf_msr_probe(PERF_RAPL_MAX)
  * - want to use same event codes across both architectures
  */
-static struct perf_msr amd_rapl_msrs[PERF_RAPL_MAX] = {
-	[PERF_RAPL_PKG]  = { MSR_AMD_PKG_ENERGY_STATUS,  &rapl_events_pkg_group,   test_msr },
+static struct perf_msr amd_rapl_msrs[] = {
+	[PERF_RAPL_PP0]  = { 0, &rapl_events_cores_group, 0, false, 0 },
+	[PERF_RAPL_PKG]  = { MSR_AMD_PKG_ENERGY_STATUS,  &rapl_events_pkg_group,   test_msr, false, RAPL_MSR_MASK },
+	[PERF_RAPL_RAM]  = { 0, &rapl_events_ram_group,   0, false, 0 },
+	[PERF_RAPL_PP1]  = { 0, &rapl_events_gpu_group,   0, false, 0 },
+	[PERF_RAPL_PSYS] = { 0, &rapl_events_psys_group,  0, false, 0 },
 };
 
-
 static int rapl_cpu_offline(unsigned int cpu)
 {
 	struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux