Re: [LSF/MM/BPF TOPIC][RFC PATCH v4 00/27] Private Memory Nodes (w/ Compressed RAM)
From: Gregory Price
Date: Wed Jun 10 2026 - 18:18:31 EST
On Wed, Jun 10, 2026 at 08:59:59PM +0200, David Hildenbrand (Arm) wrote:
>
> At LSF/MM we talked about how GFP flags are bad and how deriving stuff from the
> context might be better. I think there was also talk about how the memalloc_*
> interface might be a better way forward. Maybe we would start giving the
> allocator more context ("we are allocating a folio").
>
> The following is incomplete (esp. hugetlb stuff I assume), just as some idea:
>
Ok, this was easier to test than I expected, and hugetlb is indeed a
stickler. We can't get there 100% with just MEMALLOC_FOLIO, we still
need a MEMALLOC_PRIVATE - specifically because of users like hugetlb.
hugetlb uses __GFP_THISNODE to do its allocations, and all hugetlb
allocations are folio allocations - so the code you shared by itself
does not gate hugetlb from spilling into private nodes.
That means we still need something like this in hugetlb:
if (node_is_private(nid))
/* fail allocation */
HOWEVER... if you have MEMALLOC_PRIVATE - you make the allocation
failure a *page allocator* problem, and it serves exactly the same
purpose that __GFP_PRIVATE did.
the resulting code is two lines in my anondax driver:
unsigned int priv_flags = memalloc_private_save();
ret = do_anonymous_page_node(vmf, dev_dax->target_node);
memalloc_private_restore(priv_flags);
No special hugetlb, slab, arch code handling - they all just fail
to allocate / fall back. If they fail - it means that code is using
a bad nodemask and we need to go fix it (exactly what we want!)
I think additionally, we might be able to repurpose MEMALLOC_PRIVATE
flag for Brendan's needs as well [1].
Their goal (IIRC) was to have a pile of unmapped blocks that could
be opportunistically converted to normal memory, but otherwise left
unmapped and sitting in the buddy.
Same thing - different filter point (blocks vs nodes).
If you set MEMALLOC_PRIVATE - it makes private node allocations
possible, and "private block" access (without conversion) possible.
Otherwise private nodes are unreachable, and private blocks would be
treated like CMA (last-resort stealing, lazy-direct-mapping).
And they stack (private blocks on private nodes :V).
I don't have enough time looking at his proposal, but it seems like we
can kill two birds with one stone on this.
[1] https://lore.kernel.org/linux-mm/agYJcRgOHho8upVv@gourry-fedora-PF4VCD3F/
~Gregory