Re: [RFC PATCH 0/6] mm: pass alloc_flags through folio, filemap, and bulk allocators

From: Gregory Price

Date: Fri Oct 09 2026 - 19:29:10 EST


On Fri, Oct 09, 2026 at 10:55:05PM +0200, David Hildenbrand (Arm) wrote:
> I do agree that two sets of flags is suboptimal, but likely more flexible. I
> guess an alloc_flags only interface is not easily possible ...
>
> I do wonder whether it should be:
>
> typedef int __bitwise alloc_flags_t;
>
> instead of "unsigned int alloc_flags".
>
> ... while at it

Does it make sense to leave alloc_flags to internal-only state
and just implement a new flag field?

gfp_t -> describe the page (fully public)
req_t -> describe the allocator behavior (mm-internal only)
alloc_flags -> internal allocator state only

typedef int __bitwise pa_req_t; /* Page Allocator Request Flags */

#define PA_REQ_DEFAULT 0
#define PA_REQ_NOLOCK BIT(0) /* from ALLOC_NOLOCK */
#define PA_REQ_NO_CODETAG BIT(1) /* from ALLOC_NO_CODETAG */
#define PA_REQ_SPREAD_DIRTY BIT(2) /* from __GFP_WRITE */
#define PA_REQ_DEFER_INIT BIT(3) /* from __GFP_SKIP_ZERO */
#define PA_REQ_ZERO_TAGS BIT(4) /* from __GFP_ZERO_TAGS */
#define PA_REQ_NO_FALLBACK BIT(5) /* select no fallback list */
#define PA_REQ_NO_OOM BIT(6) /* do not oom */

Off the bat we recover 2 ALLOC flags and 3 GFP flags. Possibly more with
a bit more work.

Then we get:

#define PA_REQ_PRIVATE BIT(7) /* allow private node allocation */
#define PA_REQ_UNMAPPED BIT(8) /* page must be unmapped */

And we might not even need a new zonelist for private nodes in this case
as long as we require internal users to pass PA_REQ_PRIVATE and add a
function like

folio_alloc_private(void *owner, ...) {
/* validate (pgdat->owner == owner) before allowing allocation */
__folio_alloc(..., req | PA_REQ_PRIVATE | PA_REQ_NOFALLBACK, ...);
}

User still has the option to request NO_OOM via __GFP_THISNODE :]

~Gregory