Re: [PATCH v5] mm/page_alloc: avoid direct compaction for costly __GFP_NORETRY allocations

From: Salvatore Dipietro

Date: Tue Sep 15 2026 - 12:31:07 EST



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?
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)) &&
(gfp_mask & __GFP_KSWAPD_RECLAIM)) {
alloc_flags &= ~ALLOC_NOFRAGMENT;
goto retry;
}


Salvatore





AMAZON DEVELOPMENT CENTER ITALY SRL, viale Monte Grappa 3/5, 20124 Milano, Italia, Registro delle Imprese di Milano Monza Brianza Lodi REA n. 2504859, Capitale Sociale: 10.000 EUR i.v., Cod. Fisc. e P.IVA 10100050961, Societa con Socio Unico