Re: [PATCH v6] mm/page_alloc: avoid direct reclaim and compaction for costly __GFP_NORETRY allocations
From: Kiryl Shutsemau (Meta)
Date: Fri Dec 04 2026 - 17:46:11 EST
On Fri, Dec 04, 2026 at 01:12:34PM +0000, Harry Yoo wrote:
> 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.
I am not sure. I can see it both ways.
The request is not costly, but under defrag_mode the only way to serve
it is costly work: reclaim and compaction at pageblock_order. That is
what this patch spares costly __GFP_NORETRY requests.
On the other hand, non-costly requests are expected to reclaim and
compact. If these skip it, block device writes get order-0 folios
whenever no free unmovable chunk is around, even when one pass could
have made a whole block for them.
--
Kiryl Shutsemau / Kirill A. Shutemov