The patch titled Subject: mm: alloc_anon_folio: avoid doing vma_thp_gfp_mask in fallback cases has been added to the -mm mm-unstable branch. Its filename is mm-alloc_anon_folio-avoid-doing-vma_thp_gfp_mask-in-fallback-cases.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-alloc_anon_folio-avoid-doing-vma_thp_gfp_mask-in-fallback-cases.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Barry Song <v-songbaohua@xxxxxxxx> Subject: mm: alloc_anon_folio: avoid doing vma_thp_gfp_mask in fallback cases Date: Fri, 29 Mar 2024 20:37:50 +1300 Fallback rates surpassing 90% have been observed on phones utilizing 64KiB CONT-PTE mTHP. In these scenarios, when one out of every 16 PTEs fails to allocate large folios, the remaining 15 PTEs fallback. Consequently, invoking vma_thp_gfp_mask seems redundant in such cases. Furthermore, abstaining from its use can also contribute to improved code readability. Link: https://lkml.kernel.org/r/20240329073750.20012-1-21cnbao@xxxxxxxxx Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx> Cc: Ryan Roberts <ryan.roberts@xxxxxxx> Cc: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Alistair Popple <apopple@xxxxxxxxxx> Cc: Anshuman Khandual <anshuman.khandual@xxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: "Huang, Ying" <ying.huang@xxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Itaru Kitayama <itaru.kitayama@xxxxxxxxx> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Luis Chamberlain <mcgrof@xxxxxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Yang Shi <shy828301@xxxxxxxxx> Cc: Yin Fengwei <fengwei.yin@xxxxxxxxx> Cc: Yu Zhao <yuzhao@xxxxxxxxxx> Cc: Zi Yan <ziy@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/memory.c~mm-alloc_anon_folio-avoid-doing-vma_thp_gfp_mask-in-fallback-cases +++ a/mm/memory.c @@ -4359,6 +4359,9 @@ static struct folio *alloc_anon_folio(st pte_unmap(pte); + if (!orders) + goto fallback; + /* Try allocating the highest of the remaining orders. */ gfp = vma_thp_gfp_mask(vma); while (orders) { _ Patches currently in -mm which might be from v-songbaohua@xxxxxxxx are arm64-mm-swap-support-thp_swap-on-hardware-with-mte.patch mm-hold-ptl-from-the-first-pte-while-reclaiming-a-large-folio.patch mm-alloc_anon_folio-avoid-doing-vma_thp_gfp_mask-in-fallback-cases.patch