Linux Perf Users
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: "Okanovic, Haris" <harisokn@amazon.com>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"will@kernel.org" <will@kernel.org>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf/arm-cmn: Allow userspace to select the PMU's CPU
Date: Fri, 2 Oct 2026 17:43:02 +0100	[thread overview]
Message-ID: <2d70be7b-12c0-46e0-b308-744a3159388a@arm.com> (raw)
In-Reply-To: <CY2PR18MB8432185386B28FBC1DA23F3333A88B2@CY2PR18MB843218.namprd18.prod.outlook.com>

On 30/09/2026 8:29 pm, Okanovic, Haris wrote:
> Hi Robin,
> 
>>> All of the PMU's recurring work therefore lands on one CPU. This is
>>> problematic on systems which reserve particular CPUs for latency
>>> sensitive work or confine background activity to a chosen set of
>>> housekeeping CPUs.
> 
>>> There is no way to set it explicitly. perf_event_open() and 'perf stat
>>> -C' have no effect because arm_cmn_event_init() overwrites event->cpu;
>>> /proc/irq/*/smp_affinity is refused for the DTC interrupts, which are
>>> requested with IRQF_NOBALANCING because their affinity has to follow the
>>> owning CPU.
> 
>> All system PMU drivers have the same concern in this regard - why
>> should arm-cmn be special?
> 
> As I mentioned earlier, we can improve performance on certain system
> topologies by assigning PMU work to housekeeping CPUs.
> 
> arm-cmn has no constraints around CPU assignment, so this is possible.
> Every register access is MMIO and the DTC interrupts can be affinitised
> anywhere, so any online CPU can own it. That's what makes "write any
> online CPU" a sound interface here. I've moved it to CPUs in both NUMA
> nodes on the two platforms I tested.
> 
> You're right that the concern is general, but a single interface isn't
> easily shared, because the set of CPUs that a PMU may be driven from
> is platform/device-specific:
> 
> arm_dsu_pmu, for instance, can only be driven from the CPUs attached to
> the DSU, which it already exposes as "associated_cpus" and enforces in
> event_init(); hisi_uncore_pmu publishes the same attribute.
> 
> Intel uncore is per-die: MSR-accessed boxes must be read from a CPU on
> the target die, since rdmsr reads the executing CPU. Accepting an
> arbitrary CPU there would silently read a different die's counters.

You seem to have missed my point. Pretty much all system/uncore PMU 
drivers - other than the trivial ones with non-programmable free-running 
counters and no interrupt - have to pick a CPU to associate with, 
irrespective of whether it's from the whole system or some specific 
subset, and they all do so effectively arbitrarily, whether that's by 
cpumask_local_spread(), cpumask_any(), cpumask_any_and() or whatever. If 
one driver picking an arbitrary CPU is a problem that needs fixing, why 
do the dozens of other drivers which also pick an arbitrary CPU not also 
need fixing?

And the answer is that they do! Irrespective of whether systems might 
want particular CPUs to do particular things, we've already seen that in 
systems with lots of PMU instances, when they all end up on the same 
default "any CPU", it ends up severely over-serialising event scheduling 
to a degree that can start to significantly impact event runtimes.

> Do you have an alternate API in mind?

I don't see this being practical without first generalising the notion 
of CPU affinity so that it can at least be dealt with from a single 
place in the perf core. Inconsistent, ad-hoc hacks in individual drivers 
will not scale or be maintainable. Perf core also then has a reasonable 
chance of being able to reliably avoid racing against itself, whereas 
attempting to mitigate racy calls from within those calls when it's 
already too late is never really going to be a proper solution.

Thanks,
Robin.

      reply	other threads:[~2026-10-02 16:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 22:32 [PATCH] perf/arm-cmn: Allow userspace to select the PMU's CPU Haris Okanovic
2026-09-29 22:46 ` sashiko-bot
2026-09-30 13:36 ` Robin Murphy
2026-09-30 19:29   ` Okanovic, Haris
2026-10-02 16:43     ` Robin Murphy [this message]

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=2d70be7b-12c0-46e0-b308-744a3159388a@arm.com \
    --to=robin.murphy@arm.com \
    --cc=harisokn@amazon.com \
    --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=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