From: Zi Yan Date: Tue, 22 Oct 2024 14:33:40 +0000 (-0400) Subject: mm-avoid-zeroing-user-movable-page-twice-with-init_on_alloc=1-fix X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e52b7c34cb8effc8337b415c0d2431b312ea8f1d;p=users%2Fjedix%2Flinux-maple.git mm-avoid-zeroing-user-movable-page-twice-with-init_on_alloc=1-fix comment fixes, per David Link: https://lkml.kernel.org/r/97DB52E1-C594-49B5-9736-89AC302FAB01@nvidia.com Signed-off-by: Zi Yan Cc: Alexander Potapenko Cc: David Hildenbrand Cc: "Huang, Ying" Cc: John Hubbard Cc: Kees Cook Cc: Kefeng Wang Cc: Matthew Wilcox Cc: Miaohe Lin Cc: Ryan Roberts Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 8d4ab7cf8039..0f8ea7d98be2 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1165,6 +1165,11 @@ 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), + * 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 (!alloc_zeroed()) folio_zero_user(folio, addr); /* diff --git a/mm/memory.c b/mm/memory.c index 5c503a4a95a9..68e57b33363b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4719,6 +4719,13 @@ 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), 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 (!alloc_zeroed()) folio_zero_user(folio, vmf->address); return folio;