mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] perf/arm-cmn: Allow userspace to select the PMU's CPU
@ 2026-09-30 23:11 Haris Okanovic
  2026-09-30 23:11 ` [PATCH v2 1/2] perf/arm-cmn: Don't schedule events on a CPU which no longer owns the PMU Haris Okanovic
  2026-09-30 23:11 ` [PATCH v2 2/2] perf/arm-cmn: Allow userspace to select the PMU's CPU Haris Okanovic
  0 siblings, 2 replies; 3+ messages in thread
From: Haris Okanovic @ 2026-09-30 23:11 UTC (permalink / raw)
  To: robin.murphy, mark.rutland, will
  Cc: linux-arm-kernel, linux-perf-users, linux-kernel, harisokn

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@amazon.com/

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-30 23:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30 23:11 [PATCH v2 0/2] perf/arm-cmn: Allow userspace to select the PMU's CPU Haris Okanovic
2026-09-30 23:11 ` [PATCH v2 1/2] perf/arm-cmn: Don't schedule events on a CPU which no longer owns the PMU Haris Okanovic
2026-09-30 23:11 ` [PATCH v2 2/2] perf/arm-cmn: Allow userspace to select the PMU's CPU Haris Okanovic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®