]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf arm: Workaround ARM PMUs cpu maps having offline cpus
authorIan Rogers <irogers@google.com>
Fri, 7 Jun 2024 06:53:43 +0000 (23:53 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 21 Jun 2024 22:50:29 +0000 (15:50 -0700)
When PMUs have a cpu map in the 'cpus' or 'cpumask' file, perf will
try to open events on those CPUs. ARM doesn't remove offline CPUs
meaning taking a CPU offline will cause perf commands to fail unless a
CPU map is passed on the command line.

More context in:
https://lore.kernel.org/lkml/20240603092812.46616-1-yangyicong@huawei.com/

Reported-by: Yicong Yang <yangyicong@huawei.com>
Closes: https://lore.kernel.org/lkml/20240603092812.46616-2-yangyicong@huawei.com/
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Yicong Yang <yangyicong@hisilicon.com>
Tested-by: Leo Yan <leo.yan@arm.com>
Cc: James Clark <james.clark@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: linux-arm-kernel@lists.infradead.org
Cc: coresight@lists.linaro.org
Cc: John Garry <john.g.garry@oracle.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240607065343.695369-1-irogers@google.com
tools/perf/arch/arm/util/pmu.c

index 8b7cb68ba1a8a24ec86593570756304aa3fdfc43..6b544edbd3f630a1d952dbb9691f5e9265459fd7 100644 (file)
 
 #include "arm-spe.h"
 #include "hisi-ptt.h"
+#include "../../../util/cpumap.h"
 #include "../../../util/pmu.h"
 #include "../../../util/cs-etm.h"
 #include "../../arm64/util/mem-events.h"
 
-void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
+void perf_pmu__arch_init(struct perf_pmu *pmu)
 {
+       struct perf_cpu_map *intersect;
+
 #ifdef HAVE_AUXTRACE_SUPPORT
        if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) {
                /* add ETM default config here */
@@ -33,6 +36,9 @@ void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
                pmu->selectable = true;
 #endif
        }
-
 #endif
+       /* Workaround some ARM PMU's failing to correctly set CPU maps for online processors. */
+       intersect = perf_cpu_map__intersect(cpu_map__online(), pmu->cpus);
+       perf_cpu_map__put(pmu->cpus);
+       pmu->cpus = intersect;
 }