Skip to content

perf/arm-cmn: Allow userspace to select the PMU's CPU

Haris Okanovic linux-arm-kernel linux-perf-users lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v11 patch 4 repliesSuperseded

Changes in v2 from the cover letter

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

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2perf/arm-cmn: Don't schedule events on a CPU which no longer owns the PMUdrivers/perf/arm-cmn.c+6 -30 replies
2/2perf/arm-cmn: Allow userspace to select the PMU's CPUDocumentation/admin-guide/perf/arm-cmn.rst drivers/perf/arm-cmn.c+57 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

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

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/[email protected]/

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(-)
Signature · 2 lines
Haris Okanovic
AWS Graviton