]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm-avoid-zeroing-user-movable-page-twice-with-init_on_alloc=1-fix
authorZi Yan <ziy@nvidia.com>
Tue, 22 Oct 2024 14:33:40 +0000 (10:33 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 1 Nov 2024 04:29:07 +0000 (21:29 -0700)
comment fixes, per David

Link: https://lkml.kernel.org/r/97DB52E1-C594-49B5-9736-89AC302FAB01@nvidia.com
Signed-off-by: Zi Yan <ziy@nvidia.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c
mm/memory.c

index 8d4ab7cf80393fcdb932274d8a1480187e45ee4b..0f8ea7d98be22f469092b46520c9cf058d8bf47c 100644 (file)
@@ -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);
        /*
index 5c503a4a95a9ecb8794ba2bee7b415c3bd410ba7..68e57b33363b4e8e83e4f1dcc13c287159458168 100644 (file)
@@ -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;