[PATCH v11 5/7] mm: skip zeroing in alloc_anon_folio for pre-zeroed pages

From: Michael S. Tsirkin

Date: Thu Nov 19 2026 - 07:03:45 EST


Initialize newly allocated anonymous multi-size THP folios through
folio_init_user().

Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Assisted-by: LLM
---
mm/memory.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index ec3d9d99ccee2..020ae881b226e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5479,15 +5479,7 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf)
goto fallback;
}
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, vmf->address);
+ folio_init_user(folio, vmf->address);
return folio;
next:
count_mthp_stat(order, MTHP_STAT_ANON_FAULT_FALLBACK);
--
MST