[PATCH 38/60] mm/page_alloc: refuse contiguous allocation from private memory
From: Gregory Price via B4 Relay
Date: Fri Nov 20 2026 - 13:19:44 EST
From: "Gregory Price (Meta)" <gourry@xxxxxxxxxx>
Exact-PFN contiguous allocation bypasses the zonelists and can invoke
compaction and reclaim.
Reject a range on a private node with -EPERM before isolating any pages,
and document the error.
If a user of private ranges shows up, alloc_contig_range() can grow an
ACR flag or an exported api for private allocations.
Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
---
mm/page_alloc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index de1a13a91ef4..08e57f809a03 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7379,7 +7379,8 @@ static void __free_contig_frozen_range(unsigned long pfn, unsigned long nr_pages
* free_frozen_pages() also could be used to free compound frozen pages
* directly.
*
- * Return: zero on success or negative error code.
+ * Return: zero on success or negative error code
+ * -EPERM if the range is on a private memory node.
*/
int alloc_contig_frozen_range_noprof(unsigned long start, unsigned long end,
acr_flags_t alloc_flags, gfp_t gfp_mask)
@@ -7410,6 +7411,9 @@ int alloc_contig_frozen_range_noprof(unsigned long start, unsigned long end,
if (WARN_ON_ONCE((gfp_mask & __GFP_COMP) && order > MAX_FOLIO_ORDER))
return -EINVAL;
+ if (node_state(zone_to_nid(cc.zone), N_MEMORY_PRIVATE))
+ return -EPERM;
+
gfp_mask = current_gfp_context(gfp_mask);
if (__alloc_contig_verify_gfp_mask(gfp_mask, (gfp_t *)&cc.gfp_mask))
return -EINVAL;
--
2.56.1