Convert alloc_anon_folio() to pass __GFP_ZERO instead of zeroing
at the callsite. post_alloc_hook uses the fault address passed
through vma_alloc_folio for cache-friendly zeroing.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Assisted-by: Claude:claude-opus-4-6
---
 mm/memory.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 74523bc00d8a..f3f1bc66366d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5249,7 +5249,7 @@ static struct folio *alloc_anon_folio(struct vm_fault 
*vmf)
                goto fallback;
 
        /* Try allocating the highest of the remaining orders. */
-       gfp = vma_thp_gfp_mask(vma);
+       gfp = vma_thp_gfp_mask(vma) | __GFP_ZERO;
        while (orders) {
                folio = vma_alloc_folio(gfp, order, vma, vmf->address);
                if (folio) {
@@ -5259,15 +5259,6 @@ static struct folio *alloc_anon_folio(struct vm_fault 
*vmf)
                                goto next;
                        }
                        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);
                        return folio;
                }
 next:
-- 
MST


Reply via email to