From: Will Deacon <will@kernel.org>
To: Leo Yan <leo.yan@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Mike Leach <mike.leach@arm.com>,
James Clark <james.clark@linaro.org>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Tamas Petz <tamas.petz@arm.com>,
Tamas Zsoldos <tamas.zsoldos@arm.com>,
Michiel van Tol <michiel.vantol@arm.com>,
Dev Jain <dev.jain@arm.com>, David Hildenbrand <david@kernel.org>,
Yabin Cui <yabinc@google.com>, James Morse <james.morse@arm.com>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/2] perf: arm_spe: Prefer large AUX mappings
Date: Tue, 6 Oct 2026 17:14:28 +0100 [thread overview]
Message-ID: <asUeZA5Z4VjQtf1g@willie-the-truck> (raw)
In-Reply-To: <20261005174144.GL1208404@e132581.arm.com>
On Mon, Oct 05, 2026 at 06:41:44PM +0100, Leo Yan wrote:
> On Thu, Oct 01, 2026 at 08:16:09AM +0100, Will Deacon wrote:
> > On Wed, Sep 30, 2026 at 05:43:11PM +0100, Leo Yan wrote:
>
> > > How about adding a field to struct pmu to specify a preferred maximum
> > > page order for the AUX buffer? The perf core could try that order first
> > > and fall back to smaller orders if the allocation fails.
> >
> > I'm not sure that's thr right place for it, really. The driver has no
> > clue about whether it makes sense to use large contiguous mappings or
> > not, so I'd have thought that decision should be driven from userspace
> > (e.g. like MADV_HUGEPAGE) because it really depends on the user's
> > preference and isn't a fixed property of the hardware.
>
> Here MADV_HUGEPAGE cannot directly apply on this case: perf allocates
> the AUX pages during mmap, while TRBE accesses them through a separate
> kernel vmap() mapping.
>
> MADV_HUGEPAGE is applied after mmap, but a preference (or flag) would
> need to be specified before the AUX mmap.
I was using the madvise option as an example of a user-controllable hint,
I'm not suggesting you use it directly as-is.
> > > Given the single L1 TRBE TLB entry, the TRBE driver could prefer
> > > PMD_ORDER (2 MiB with 4 KiB pages) to reduce TLB pressure. This reflects
> > > the hardware characteristic.
> > >
> > > This could be a trade-off instead of using PERF_PMU_CAP_AUX_PREFER_LARGE,
> > > avoiding large contiguous allocations that could reintroduce the Android
> > > OOM issue. I did a quick test with this approach and the results look
> > > positive.
> >
> > I really don't want the driver to second-guess userspace based on whatever
> > information it happens to have hard-coded about the specific CPU it's
> > running on.
>
> The kernel already takes the PERF_PMU_CAP_AUX_PREFER_LARGE flag from a
> PMU; a preferred maximum order would let the driver give it a bounded
> value.
But the driver doesn't have this information.
> I do not intend to hard-code or guess a preference for a particular CPU
> variant. We can map TRBE or SPE buffer at PMD granularity. On a 4
> KiB-page system, PMD_ORDER is order 9, or 2 MiB. Requesting a larger
> contiguous chunk cannot increase the mapping granule, so I would cap the
> preference there. It remains a preference: perf can fall back to smaller
> orders when allocation fails.
My understanding of 18049c8cff9c is that it's not about allocation
failures, so this doesn't work.
> Exposing the preference to userspace also seems problematic. Users
> generally lack the hardware details needed to choose an appropriate
> value. Even if tools provide a default, the same policy would need to
> be duplicated across perf, simpleperf, and proprietary tools. I don't
> think userspace tools are the right place for this policy.
Well I don't think it belongs in the kernel either. I suppose you could
make it a driver module option but it's ugly as hell. We really need
Yabin's input here, I think.
Will
prev parent reply other threads:[~2026-10-06 16:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 14:44 [PATCH 0/2] perf/arm: Prefer large AUX mappings for CoreSight and SPE Leo Yan
2026-08-10 14:44 ` [PATCH 1/2] coresight: perf: Prefer large AUX mappings Leo Yan
2026-08-10 14:44 ` [PATCH 2/2] perf: arm_spe: " Leo Yan
2026-08-10 15:10 ` Will Deacon
2026-08-10 17:41 ` Leo Yan
2026-08-11 9:02 ` James Clark
2026-08-11 10:17 ` Leo Yan
2026-09-01 17:06 ` Leo Yan
2026-10-08 10:43 ` Dev Jain
2026-09-30 16:43 ` Leo Yan
2026-10-01 7:16 ` Will Deacon
2026-10-05 17:41 ` Leo Yan
2026-10-06 16:14 ` Will Deacon [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=asUeZA5Z4VjQtf1g@willie-the-truck \
--to=will@kernel.org \
--cc=anshuman.khandual@arm.com \
--cc=coresight@lists.linaro.org \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=james.clark@linaro.org \
--cc=james.morse@arm.com \
--cc=leo.yan@arm.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=michiel.vantol@arm.com \
--cc=mike.leach@arm.com \
--cc=peterz@infradead.org \
--cc=suzuki.poulose@arm.com \
--cc=tamas.petz@arm.com \
--cc=tamas.zsoldos@arm.com \
--cc=yabinc@google.com \
/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