Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/huge_memory: add pmd folio to ds_queue in do_huge_zero_wp_pmd()

We add pmd folio into ds_queue on the first page fault in
__do_huge_pmd_anonymous_page(), so that we can split it in case of memory
pressure. This should be the same for a pmd folio during wp page fault.

Commit 1ced09e0331f ("mm: allocate THP on hugezeropage wp-fault") miss to
add it to ds_queue, which means system may not reclaim enough memory in
case of memory pressure even the pmd folio is under used.

Move deferred_split_folio() into map_anon_folio_pmd() to make the pmd
folio installation consistent.

Link: https://lkml.kernel.org/r/20251008095453.18772-2-richard.weiyang@gmail.com
Fixes: 1ced09e0331f ("mm: allocate THP on hugezeropage wp-fault")
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Acked-by: Usama Arif <usamaarif642@gmail.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Wei Yang and committed by
Andrew Morton
2a1351cd c3228747

+1 -1
+1 -1
mm/huge_memory.c
··· 1233 1233 count_vm_event(THP_FAULT_ALLOC); 1234 1234 count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_ALLOC); 1235 1235 count_memcg_event_mm(vma->vm_mm, THP_FAULT_ALLOC); 1236 + deferred_split_folio(folio, false); 1236 1237 } 1237 1238 1238 1239 static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf) ··· 1274 1273 pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable); 1275 1274 map_anon_folio_pmd(folio, vmf->pmd, vma, haddr); 1276 1275 mm_inc_nr_ptes(vma->vm_mm); 1277 - deferred_split_folio(folio, false); 1278 1276 spin_unlock(vmf->ptl); 1279 1277 } 1280 1278