Skip to contentSkip to conversation

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

PATCH Superseded Wei Yang 4 participants 4 messages Oct 1, 2025

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 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.

Add it as expected.

Cc David Hildenbrand <[email protected]>
Cc Lance Yang <[email protected]>
Cc Dev Jain <[email protected]>
---
 mm/huge_memory.c | 1 +
 1 file changed, 1 insertion(+)
mm/huge_memory.c +1 -0
index 1b81680b4225..963cba933cb6 100644
@@ -1878,6 +1878,7 @@ static vm_fault_t do_huge_zero_wp_pmd(struct vm_fault *vmf)
 		goto release;
 	(void)pmdp_huge_clear_flush(vma, haddr, vmf->pmd);
 	map_anon_folio_pmd(folio, vmf->pmd, vma, haddr);
+	deferred_split_folio(folio, false);
 	goto unlock;
 release:
 	folio_put(folio);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 11 lines · Wei Yang

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.

Add it as expected.

Cc David Hildenbrand <[email protected]>
Cc Lance Yang <[email protected]>
Cc Dev Jain <[email protected]>
Fixes please, and I think we want CC stable.
Quoted 9 lines
---
  mm/huge_memory.c | 1 +
  1 file changed, 1 insertion(+)
mm/huge_memory.c +0 -0
index 1b81680b4225..963cba933cb6 100644

mm/huge_memory.c static vm_fault_t do_huge_zero_wp_pmd(struct vm_fault *vmf) · line 1884

Quoted 7 lines
mm/huge_memory.c +1 -0
@@ -1878,6 +1878,7 @@ static vm_fault_t do_huge_zero_wp_pmd(struct vm_fault *vmf)
  		goto release;
  	(void)pmdp_huge_clear_flush(vma, haddr, vmf->pmd);
  	map_anon_folio_pmd(folio, vmf->pmd, vma, haddr);
+	deferred_split_folio(folio, false);
  	goto unlock;
  release:
  	folio_put(folio);

Which raises the question whether the deferred_split_folio() should actually go into the map_anon_folio_pmd(). I think you should just move the one from __do_huge_pmd_anonymous_page() in there.

Signature · 3 lines
Cheers

David / dhildenb
reviewer
#2 lore raw
Quoted 7 lines · David Hildenbrand
Quoted 6 lines · Wei Yang

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.

Add it as expected.

Good catch!

Quoted 12 lines
Quoted 5 lines
Cc David Hildenbrand <[email protected]>
Cc Lance Yang <[email protected]>
Cc Dev Jain <[email protected]>
Fixes please, and I think we want CC stable.
Quoted 4 lines

---
  mm/huge_memory.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 15 lines
Quoted 11 lines
mm/huge_memory.c +1 -0
index 1b81680b4225..963cba933cb6 100644
@@ -1878,6 +1878,7 @@ static vm_fault_t do_huge_zero_wp_pmd(struct 
 vm_fault *vmf)
           goto release;
       (void)pmdp_huge_clear_flush(vma, haddr, vmf->pmd);
       map_anon_folio_pmd(folio, vmf->pmd, vma, haddr);
+    deferred_split_folio(folio, false);
       goto unlock;
Quoted 2 lines

  release:
      folio_put(folio);

Which raises the question whether the deferred_split_folio() should actually go into the map_anon_folio_pmd(). I think you should just move the one from __do_huge_pmd_anonymous_page() in there.

+1 Moving the call into map_anon_folio_pmd() feels way cleaner :)

Cheers,
Lance

maintainer
#3 lore raw
In reply to David Hildenbrand
Quoted 6 lines · On Wed, 1 Oct 2025 16:34:45 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 5 lines · Wei Yang

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.

Quoted 8 lines
Quoted 6 lines

Add it as expected.

Cc David Hildenbrand <[email protected]>
Cc Lance Yang <[email protected]>
Cc Dev Jain <[email protected]>
Fixes please, and I think we want CC stable.

And a reason for Fixes: and Cc:stable, please. ie, a description of the userspace visible runtime effects.

Cheers, akpmbot.