From: Peter Zijlstra <peterz@infradead.org>
To: Haris Okanovic <harisokn@amazon.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] perf/core: Add PERF_PMU_SCOPE_DEVICE
Date: Wed, 14 Oct 2026 12:27:00 +0200 [thread overview]
Message-ID: <20261014102700.GC4121339@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20261013185603.1347265-3-harisokn@amazon.com>
On Tue, Oct 13, 2026 at 01:56:01PM -0500, Haris Okanovic wrote:
> Add a "device" pmu::scope for PMUs counted on a single CPU drawn
> from a driver-supplied set instead of a fixed topology.
>
> This mechanism is implemented by new callbacks: filter_allowed_cpus()
> is invoked to constrain the running CPU set to an allowed set for a
> particular device; migrate_cpu() is used to perform any device specific
> migration steps. Both are optional, e.g. for devices that can run on
> any CPU or have no additional migration steps.
>
> Placement initially happens in perf_pmu_register() before the PMU
> becomes visible, and is subsequently re-evaluated on hotplug events.
> A new CPU selection is made by cpumask_any_distribute() to spread out
> load from multiple devices, but only when the previous CPU selection is
> offline or no longer allowed by filter_allowed_cpus().
>
> PMU events of these devices follow the chosen CPU. They are initially
> bound to a CPU in perf_try_init_event() then reassigned by
> perf_pmu_migrate_context() when a new CPU is selected.
>
> The initial CPU assignment can race with migration, leaving a stranded
> event. A sequence counter is added to close this gap without additional
> locks. A count in struct pmu increments on each migration and is copied
> to struct perf_event on init. The copied count is checked again before
> the event is installed, under the same context mutex, which causes
> perf_event_open() and perf_event_create_kernel_counter() to return -EBUSY
> during migration periods.
I'm not entirely sure on this. How is this race different from changing
CPU on hotplug?
next prev parent reply other threads:[~2026-10-14 10:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 18:55 [PATCH 0/4] perf: Manage single-CPU PMU affinity in perf core Haris Okanovic
2026-10-13 18:56 ` [PATCH 1/4] perf/core: Fix perf_pmu_migrate_context() leaving events behind Haris Okanovic
2026-10-13 18:56 ` [PATCH 2/4] perf/core: Add PERF_PMU_SCOPE_DEVICE Haris Okanovic
2026-10-14 10:27 ` Peter Zijlstra [this message]
2026-10-14 14:26 ` Robin Murphy
2026-10-13 18:56 ` [PATCH 3/4] perf/core: Allow userspace to select a device PMU's CPU Haris Okanovic
2026-10-13 18:56 ` [PATCH 4/4] perf/arm-cmn: Convert to PERF_PMU_SCOPE_DEVICE Haris Okanovic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014102700.GC4121339@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=harisokn@amazon.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®