[PATCH v11 3/7] mm: skip zeroing in vma_alloc_anon_folio_pmd for pre-zeroed pages
From: Michael S. Tsirkin
Date: Thu Nov 19 2026 - 07:03:16 EST
Initialize newly allocated anonymous PMD folios through folio_init_user(),
to skip initialization of PG_zeroed pages.
Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Assisted-by: LLM
---
mm/huge_memory.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index eb913acb03b74..80bd9b54eff2a 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1375,17 +1375,10 @@ static struct folio *vma_alloc_anon_folio_pmd(struct vm_area_struct *vma,
folio_throttle_swaprate(folio, gfp);
- /*
- * When a folio is not zeroed during allocation (__GFP_ZERO not used)
- * or user folios require special handling, folio_zero_user() is used to
- * make sure that the page corresponding to the faulting address will be
- * hot in the cache after zeroing.
- */
- if (user_alloc_needs_zeroing())
- folio_zero_user(folio, addr);
+ folio_init_user(folio, addr);
/*
* The memory barrier inside __folio_mark_uptodate makes sure that
- * folio_zero_user writes become visible before the set_pmd_at()
+ * folio initialization becomes visible before the set_pmd_at()
* write.
*/
__folio_mark_uptodate(folio);
--
MST