Re: [PATCH] Revert "perf/aux: Allocate non-contiguous AUX pages by default"

From: Yabin Cui

Date: Thu Nov 19 2026 - 16:00:29 EST


On Wed, Nov 18, 2026 at 11:43 PM Dev Jain <dev.jain@xxxxxxx> wrote:
>
>
>
> On 18/11/26 10:27 pm, Leo Yan wrote:
> > On Sun, Nov 15, 2026 at 08:32:16PM +0530, Dev Jain wrote:
> >
> > [...]
> >
> >>> 1. Make opportunistic high-order AUX allocations no-reclaim:
> >>> When !(event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) and
> >>> order > 0, clear __GFP_RECLAIM (and add __GFP_NOMEMALLOC, matching
> >>> SLUB's allocate_slab() and GFP_TRANSHUGE_LIGHT):
> >>>
> >>> gfp_t gfp = PERF_AUX_GFP;
> >>>
> >>> if (order && !has_no_sg)
> >>> gfp = (PERF_AUX_GFP | __GFP_NOMEMALLOC) & ~__GFP_RECLAIM;
> >>
> >> Thanks for your reply.
> >>
> >> This looks like the correct solution. Note commit 0e05a469c294
> >> ("mm/page_alloc: avoid direct reclaim and compaction for costly __GFP_NORETRY allocations")
> >> post which the regression you report should reduce drastically. It only
> >> removes GFP_DIRECT_RECLAIM flag, I assume you are seeing latency even
> >> due to reclaim/compaction daemon wakeups.
> >>
> >> So instead of enhancing this commit even more by making a page-allocator
> >> change, I would rather make your proposed change on the perf side to
> >> keep it simple. This should completely solve the problem.
> >
> > Thanks a lot, Dev!
> >
> > The revert (526d945ad9c0) and 0e05a469c294 are now in mainline. My tests
> > show significantly lower PSI on v7.4-rc3, consistent with the expected
> > benefit of 0e05a469c294.
> >
> > The following PSI some values are totals in milliseconds across runs
> > 2-10 (nine runs), excluding the first run of each case to avoid
> > glitches caused by its proximity to lauching the pressure workload:
> >
> > Memory usage v7.4-rc1 v7.4-rc3 rc3 + perf patch [1]
> > 90% 0.000 0.000 0.000
> > 95% 21.781 0.000 2.061
> > 100% 27.946 0.000 0.000
> >
> > My perf patch [1] reduces pageoutrun and compact_daemon_wake, but
> > increases pgscan_kswapd at 95%. The following totals compare v7.4-rc3
>
> Exactly what I expected. I would say to not complicate with GFP_RETRY_MAYFAIL
> and keep it simple.
>
>
> > and v7.4-rc + my patch, also across runs 2-10:
> >
> > Usage pageoutrun compact_daemon_wake pgscan_kswapd
> > 90% 58 -> 0 57 -> 0 1,932 -> 0
> > 95% 3 -> 2 2 -> 1 9,664 -> 148,079
> > 100% 40 -> 1 40 -> 0 11,616 -> 1,918
> >
> > I would wait for Yabin's testing before deciding whether to proceed
> > with the additional perf changes. In my patch, changing order 0 to
> > __GFP_RETRY_MAYFAIL needs care: it may reduce allocation failures when
> > free memory is scarce, at the cost of longer reclaim stalls and
> > higher PSI.
> >
> > Yabin, could you test the current mainline (or backport
> > 526d945ad9c0/0e05a469c294) and confirm whether it resolves the PSI issue
> > on Android? If still see the reclaim pressure or observe AUX allocation
> > failures, it may also be worth testing patch [1].
> >

Hi Leo, Dev,

I tested on an arm64 Android Pixel device (4 KiB pages, 12 GiB RAM +
6 GiB zram, TRBE & SPE) using an Android kernel patched locally to match
v7.4-rc3's rb_alloc_aux() / __alloc_pages_slowpath() behavior
(526d945ad9c0, 669872181549, 53a9b4646f67, 0e05a469c294).

v7.4-rc3 alone still causes heavy PSI and compaction/reclaim stalls on
Android, while patch [1] keeping __GFP_NORETRY fixes it completely.

compact-bench (90/95/99%, 10 runs each = 30 runs, 4 MiB/CPU TRBE AUX,
0 allocation failures; system-wide PSI since Android sets
cgroup_disable=pressure):

Config PSI some(ms) cmp_stall allocstall daemon_wake
sp_kswapd_wk
order-0 297.76 0 0 0
0
revert 2,578.00 3,957 1,984 17
28
v7.4-rc3-sim 1,840.29 522 161 14
21
rc3 + [1] 270.77 0 0 0
0
rc3 + [1]-noretry 41.78 0 0 0
1

Even when order-3 pages are still plentiful (e.g. 95%, where order-3
never failed and cmp_stall/allocstall were 0), v7.4-rc3-sim still
woke kswapd/kcompactd for failed orders 4..9 on 10/10 runs (7
kcompactd wakes), producing 895.48 ms PSI vs. 2.87 ms with
[1]-noretry.

When order-3 does run out (99% Run 1), v7.4-rc3-sim bypasses
0e05a469c294 and hits 521 direct compactions / 161 direct reclaims
(Runs 2..10 dropped to 1/0 by reusing freed AUX pages; that only
helps when traces run back-to-back in a short window, which doesn't
match our use case on Android).

Under a realistic Android fragmentation test (incompressible zram
pages, unmovable pages, re-fragmented between runs), v7.4-rc3-sim also
triggered an lmkd kill (TRBE) and direct compaction/reclaim stalls
(SPE), all 0 with [1]-noretry.

When unfragmented, [1]-noretry still allocates 100% order-9 (2 MiB)
chunks for both TRBE and SPE.

So I agree with Dev to drop __GFP_RETRY_MAYFAIL and keep __GFP_NORETRY
(0 allocation failures and lower PSI). Please proceed with v2 of [1]
keeping __GFP_NORETRY (and avoid backporting 526d945ad9c0 to
stable without it).

Thanks,
Yabin

> > Thanks,
> > Leo
> >
> > [1] https://lore.kernel.org/lkml/20261109-perf_aux_alloc_optimize_psi-v1-1-d56ac4bf3ef5@xxxxxxx/
>