Re: [PATCH v5] mm/page_alloc: avoid direct compaction for costly __GFP_NORETRY allocations
From: Johannes Weiner
Date: Tue Sep 15 2026 - 14:29:40 EST
On Tue, Sep 15, 2026 at 04:00:42PM +0000, Salvatore Dipietro wrote:
>
> On Fri, 11 Sep 2026 09:32:00 -0700 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > does any of this look real?
>
> The mechanism seems real, but it only shows up with vm.defrag_mode=1,
> which is off by default.
>
> With defrag_mode=1, a costly __GFP_NORETRY allocation that used to fail
> cleanly can now succeed by fragmenting another migratetype's pageblock,
> which seems like the wrong trade for a caller whose premise is a cheap
> lower-order fallback. Johannes, do we want to keep it strict?
Yes, avoiding the fallback is a good idea. The user already
communicated they can handle failure and have fallback options.
> If so, we could add a condition like below. It is equally
> applicable to v4 and v5. Happy to send it separately or in v6.
>
> /*
> * Reclaim/compaction cannot run, so defrag_mode's strategy
> * of enforcing ALLOC_NOFRAGMENT cannot be fulfilled. Allow
> * fallbacks rather than failing the allocation outright.
> * Not for costly __GFP_NORETRY: those have a cheap lower
> * order fallback, so failing beats fragmenting.
> */
> if (defrag_mode && (alloc_flags & ALLOC_NOFRAGMENT) &&
> !(costly_order && (gfp_mask & __GFP_NORETRY)) &&
It would be possible to remove the costly_order gate here and just
bail on __GFP_NORETRY. But no strong feelings.