Re: [PATCH] mm/page_alloc: unify __alloc_frozen_pages[_nolock]_noprof()

From: Vlastimil Babka (SUSE)

Date: Mon Jun 22 2026 - 04:24:30 EST


On 6/19/26 10:17, Brendan Jackman wrote:
> On Fri Jun 19, 2026 at 3:56 AM UTC, Matthew Wilcox wrote:
>>> +/*
>>> + * This is the 'heart' of the zoned buddy allocator.
>>> + */
>>> +struct page *__alloc_frozen_pages_noprof(gfp_t gfp, unsigned int order,
>>> + int preferred_nid, nodemask_t *nodemask, unsigned int alloc_flags)
>>> +{
>>> + struct page *page;
>>> + gfp_t alloc_gfp; /* The gfp_t that was actually used for allocation */
>>> + struct alloc_context ac = { };
>>> +
>>> + /* Other flags could be supported later if needed. */
>>> + if (WARN_ON(alloc_flags & ~ALLOC_TRYLOCK))
>>> return NULL;
>>>
>>> + if (!alloc_order_allowed(gfp, order, alloc_flags))
>>> + return NULL;
>>> +
>>> + if (alloc_flags & ALLOC_TRYLOCK) {
>>> + VM_WARN_ON_ONCE(gfp & ~__GFP_ACCOUNT);
>>
>> So the only GFP flag the user is allowed to specify is __GFP_ACCOUNT?
>> That seems bogus; other flags would be reasonable including all the ones
>> in gfp_trylock, as well as GFP_HIGHMEM, GFP_DMA, GFP_MOVABLE, GFP_HARDWALL.

We could start phasing out GFP_HIGHMEM and GFP_DMA somewhere :)

> Definitely makes sense for the ones in gfp_trylock.
>
> For the others, I'm not sure - this "nolock" functionality is a bit
> weird and sketchy, I suspect the reason for the WARN here is "let's make
> sure we have a proper think before we allow it to grow usecases that are

Yeah you were just keeping the same allowed flags that
alloc_frozen_pages_nolock_noprof() currently does.

> meaningfully different from the other ones". I think I like that
> conservatism here, I would lean towards keeping it? Not a passionately
> held opinion though.

Yeah if we expand it, I'd do it separately and in response to use cases
appearing.
We want _nolock to be used only where really necessary, as its success is
very limited, not to be (ab)used as a cheap way out of a wrongly designed
driver or something. ("oh I need to allocate something here and can't spin,
so let's just use this, solved").