[PATCH] mm/page_alloc: apply per-task GFP context in bulk allocator
From: Qiqi Liu
Date: Sun Sep 13 2026 - 22:46:22 EST
alloc_pages_bulk_noprof() does not call current_gfp_context(), so
per-task scoped allocation constraints (PF_MEMALLOC_NOIO,
PF_MEMALLOC_NOFS, PF_MEMALLOC_PIN) are not applied on the bulk fast
path.
The most direct consequence is PF_MEMALLOC_PIN: without clearing
__GFP_MOVABLE, prepare_alloc_pages() selects MIGRATE_MOVABLE for the
PCP list, and a task under memalloc_pin_save() receives movable
pages from the bulk allocator.
Fixes: 387ba26fb1cb ("mm/page_alloc: add a bulk page allocator")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Qiqi Liu <liuqiqi@xxxxxxxxxx>
---
mm/page_alloc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 12fac9084c48..3be7288a1aa7 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5207,6 +5207,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
/* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */
gfp &= gfp_allowed_mask;
+ gfp = current_gfp_context(gfp);
if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &gfp, &alloc_flags))
goto out;
--
2.25.1