Re: [PATCH v6] mm/page_alloc: avoid direct reclaim and compaction for costly __GFP_NORETRY allocations

From: Kiryl Shutsemau (Meta)

Date: Thu Dec 03 2026 - 17:05:47 EST


On Mon, Nov 30, 2026 at 01:27:02PM +0000, Harry Yoo wrote:
> > @@ -4802,6 +4802,18 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
> > bool can_retry_reserves = true;
> > unsigned long alloc_start_time = jiffies;
> >
> > + /*
> > + * Costly __GFP_NORETRY callers have a cheap fallback, so don't stall
> > + * them in reclaim or compaction. __GFP_THISNODE callers are exempt.
> > + */
> > + if (costly_order && (gfp_mask & __GFP_NORETRY) &&
> > + !(gfp_mask & __GFP_THISNODE))
> > + gfp_mask &= ~__GFP_DIRECT_RECLAIM;
>
> Does this apply when the order is not costly but reclaim_compact_order
> is promoted to a costly order by defrag_mode?

No, the check uses the request order and the promotion happens later.

I think the question is whether, under defrag_mode, a __GFP_NORETRY
request whose reclaim and compaction get promoted to pageblock_order
should skip direct reclaim like a costly one does.

Such a request of order 1-3 currently compacts at pageblock_order,
reclaims at pageblock_order and compacts again, then fails without
dropping ALLOC_NOFRAGMENT.

Buffered writes to a block device look like they hit this: the bdev
mapping is GFP_USER, so its large folios are unmovable, and
__filemap_get_folio_mpol() steps down through orders 3, 2 and 1 with
__GFP_NORETRY. With this patch the costly orders fail fast, but each of
the three small ones still pays for a pageblock_order pass.

--
Kiryl Shutsemau / Kirill A. Shutemov