[PATCH v2 0/2] perf/arm-cmn: Allow userspace to select the PMU's CPU

From: Haris Okanovic

Date: Wed Sep 30 2026 - 20:35:04 EST


arm_cmn_probe() picks the CPU that owns the PMU and nothing but the CPU
hotplug callbacks ever revisits it, so in practice all of the PMU's
recurring work stays on the first CPU local to the interconnect's NUMA
node. Patch 2 makes the existing 'cpumask' attribute writable so it can
be moved, which helps on systems that confine background kernel work to
a chosen set of housekeeping CPUs.

I made the existing 'cpumask' attribute writable rather than
adding a new one. Every other implementation of that file is read-only,
so I am happy to switch to a separate attribute if you would prefer to
keep 'cpumask' uniformly read-only across PMUs.

Patch 1 is new in v2. Robin pointed out that perf_event_open() can latch
cmn->cpu and then install the event after a migration has already moved
the PMU, leaving it on a CPU which no longer owns the PMU's shared state.
The window already exists via arm_cmn_pmu_online_cpu(), so patch 1 stands
on its own; a writable cpumask just makes it reachable on demand.

Changes since v1:
- Added patch 1 to close the perf_event_open() race.
- No change to patch 2 (the v1 patch) other than being rebased.

v1: https://lore.kernel.org/linux-arm-kernel/20260929223244.2411400-1-harisokn@xxxxxxxxxx/

Tested on two platforms with CONFIG_PROVE_LOCKING=y:

AWS m9g.metal-48xl CMN S3, one mesh, 192 CPUs
AWS m8g.metal-48xl CMN-700, two meshes, 192 CPUs

- Multiplexing occurs on the configured CPU.
- Offlining the owning CPU migrates the PMU and updates the attribute.
- Writes racing CPU offline/online produced no lockdep reports.
- Hammer perf_event_open() while flipping the cpumask between two CPUs.

Haris Okanovic (2):
perf/arm-cmn: Don't schedule events on a CPU which no longer owns the
PMU
perf/arm-cmn: Allow userspace to select the PMU's CPU

Documentation/admin-guide/perf/arm-cmn.rst | 18 ++++++++
drivers/perf/arm-cmn.c | 49 ++++++++++++++++++++--
2 files changed, 63 insertions(+), 4 deletions(-)

--
Haris Okanovic
AWS Graviton