linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [Patch v2] mm/huge_memory: add pmd folio to ds_queue in do_huge_zero_wp_pmd()
@ 2025-10-02  1:38 Wei Yang
  2025-10-02  1:46 ` Wei Yang
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Wei Yang @ 2025-10-02  1:38 UTC (permalink / raw)
  To: akpm, david, lorenzo.stoakes, ziy, baolin.wang, Liam.Howlett,
	npache, ryan.roberts, dev.jain, baohua, lance.yang,
	wangkefeng.wang
  Cc: linux-mm, Wei Yang, stable

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.

Fixes: 1ced09e0331f ("mm: allocate THP on hugezeropage wp-fault")
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Dev Jain <dev.jain@arm.com>
Cc: <stable@vger.kernel.org>

---
v2:
  * add fix, cc stable and put description about the flow of current
    code
  * move deferred_split_folio() into map_anon_folio_pmd()
---
 mm/huge_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 1b81680b4225..f13de93637bf 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1232,6 +1232,7 @@ static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
 	count_vm_event(THP_FAULT_ALLOC);
 	count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_ALLOC);
 	count_memcg_event_mm(vma->vm_mm, THP_FAULT_ALLOC);
+	deferred_split_folio(folio, false);
 }
 
 static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf)
@@ -1272,7 +1273,6 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf)
 		pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable);
 		map_anon_folio_pmd(folio, vmf->pmd, vma, haddr);
 		mm_inc_nr_ptes(vma->vm_mm);
-		deferred_split_folio(folio, false);
 		spin_unlock(vmf->ptl);
 	}
 
-- 
2.34.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-10-14  3:49 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-02  1:38 [Patch v2] mm/huge_memory: add pmd folio to ds_queue in do_huge_zero_wp_pmd() Wei Yang
2025-10-02  1:46 ` Wei Yang
2025-10-02  2:31   ` Lance Yang
2025-10-02  3:17     ` Wei Yang
2025-10-02  7:16       ` David Hildenbrand
2025-10-02  7:27         ` Lance Yang
2025-10-02  7:14 ` David Hildenbrand
2025-10-02  7:26 ` Lance Yang
2025-10-03  7:54 ` Dev Jain
2025-10-03 13:49 ` Lance Yang
2025-10-03 14:08   ` Zi Yan
2025-10-03 15:30     ` Usama Arif
2025-10-03 17:11       ` Zi Yan
2025-10-04  2:13     ` Wei Yang
2025-10-04  2:04   ` Wei Yang
2025-10-04  2:37     ` Lance Yang
2025-10-03 13:53 ` Zi Yan
2025-10-14  3:49 ` Baolin Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox