Commit cea1c281 authored by Ian Rogers's avatar Ian Rogers Committed by zhangyuyang
Browse files

perf arm: Workaround ARM PMUs cpu maps having offline cpus

mainline inclusion
from mainline-v6.11-rc1
commit 5518063fcb2e022411c1112b1b9b069e68380bbb
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAQG1H
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5518063fcb2e022411c1112b1b9b069e68380bbb

----------------------------------------------------------------------

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: default avatarYicong Yang <yangyicong@huawei.com>
Closes: https://lore.kernel.org/lkml/20240603092812.46616-2-yangyicong@huawei.com/


Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarYicong Yang <yangyicong@hisilicon.com>
Tested-by: default avatarLeo 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: default avatarNamhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarQizhi Zhang <zhangqizhi3@h-partners.com>
Link: https://lore.kernel.org/r/20240607065343.695369-1-irogers@google.com
parent 5672a2cb
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -11,12 +11,15 @@

#include "arm-spe.h"
#include "hisi-ptt.h"
#include "../../../util/cpumap.h"
#include "../../../util/pmu.h"
#include "../../../util/cs-etm.h"

struct perf_event_attr
*perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
*perf_pmu__get_default_config(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 */
@@ -31,5 +34,10 @@ struct perf_event_attr
	}

#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;

	return NULL;
}