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

From: Harry Yoo

Date: Fri Dec 04 2026 - 08:12:45 EST


On Thu, Dec 03, 2026 at 02:05:24PM -0800, Kiryl Shutsemau (Meta) wrote:
> 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.

Yes, that's what I meant. Thanks.

> 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.

which should be avoided given the purpose of this patch.

> 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.

Sounds like we'd need a follow-up for this?
What do you think, Salvatore?

--
Cheers,
Harry / Hyeonggon