mm/huge_memory: avoid transient none PMDs during lazyfree reclaim
Subsystems (4)
PATCH 1/1 mm/huge_memory: avoid transient none PMDs during lazyfree reclaim
__discard_anon_folio_pmd_locked() clears and flushes a huge PMD before checking whether the folio can be discarded. If the folio was redirtied or has unexpected references, it restores the original PMD. Reclaim holds the PMD lock and the anon_vma read lock, but not the owning mmap_lock.
Both zap_pmd_range() and mremap's get_old_pmd() can skip a none PMD without taking its lock. A concurrent munmap() or whole-VMA MREMAP_DONTUNMAP can therefore miss the PMD and later unlink the source VMA from its anon_vma, leaving a restored mapping behind. The anon_vma write lock taken by unlink_anon_vmas() waits for reclaim to finish, but does not repeat the skipped page-table walk. Once the remaining VMA links are removed, the folio's positive mapcount no longer guarantees a live anon_vma. Racing lazyfree reclaim against MREMAP_DONTUNMAP as an unprivileged user reproduces a KASAN use-after-free in folio_lock_anon_vma_read().
Use pmdp_invalidate() to keep a recognizable, non-none huge PMD while the discard can still fail. Concurrent unmap and move operations then have to synchronize on the PMD lock instead of skipping the mapping. Clear the invalidated PMD only after the dirty and reference checks have succeeded, before removing the rmap and withdrawing the deposited page table. The full invalidation retains the TLB flush required for the dirty and GUP-fast checks.
--- mm/huge_memory.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
mm/huge_memory.c +9 -2
@@ -3569,11 +3569,17 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,return false; } - orig_pmd =pmdp_huge_clear_flush (vma, addr, pmdp); +/* +* The discard may fail, so keep the PMD non-none until we're +* committed to discarding it. Otherwise, concurrent munmap() or +* mremap() can skip the PMD without taking the PTL and later unlink +* the VMA from its anon_vma despite a restored mapping. +*/ + orig_pmd =pmdp_invalidate (vma, addr, pmdp);/* * Syncing against concurrent GUP-fast: -* - clear PMD; barrier; read refcount +* - invalidate PMD; barrier; read refcount * - inc refcount; barrier; read PMD */ smp_mb ();
@@ -3607,6 +3613,7 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,return false; } +pmdp_huge_get_and_clear (mm, addr, pmdp);folio_remove_rmap_pmd (folio,pmd_page (orig_pmd), vma);zap_deposited_table (mm, pmdp);add_mm_counter (mm,MM_ANONPAGES , -HPAGE_PMD_NR );
Quoted 37 lines · Kyle Zeng
__discard_anon_folio_pmd_locked()clears and flushes a huge PMD before checking whether the folio can be discarded. If the folio was redirtied or has unexpected references, it restores the original PMD. Reclaim holds the PMD lock and theanon_vmaread lock, but not the owningmmap_lock.Both
zap_pmd_range()and mremap'sget_old_pmd()can skip a none PMD without taking its lock. A concurrentmunmap()or whole-VMAMREMAP_DONTUNMAPcan therefore miss the PMD and later unlink the source VMA from itsanon_vma, leaving a restored mapping behind. Theanon_vmawrite lock taken byunlink_anon_vmas()waits for reclaim to finish, but does not repeat the skipped page-table walk. Once the remaining VMA links are removed, the folio's positive mapcount no longer guarantees a liveanon_vma. Racing lazyfree reclaim againstMREMAP_DONTUNMAPas an unprivileged user reproduces a KASAN use-after-free infolio_lock_anon_vma_read().Use
pmdp_invalidate()to keep a recognizable, non-none huge PMD while the discard can still fail. Concurrent unmap and move operations then have to synchronize on the PMD lock instead of skipping the mapping. Clear the invalidated PMD only after the dirty and reference checks have succeeded, before removing the rmap and withdrawing the deposited page table. The full invalidation retains the TLB flush required for the dirty and GUP-fast checks.Fixes 735ecdfaf4e8 ("mm/vmscan: avoid split lazyfree THP during shrink_folio_list()")Assisted-by Codex:gpt-6-astraSigned-off-by Kyle Zeng <[email protected]>--- mm/huge_memory.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)mm/huge_memory.c +0
-0
mm/huge_memory.c static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma, · line 3577
Quoted 10 lines
mm/huge_memory.c +6
-1@@ -3569,11 +3569,17 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,return false; } - orig_pmd =pmdp_huge_clear_flush (vma, addr, pmdp); +/* +* The discard may fail, so keep the PMD non-none until we're +* committed to discarding it. Otherwise, concurrent munmap() or +* mremap() can skip the PMD without taking the PTL and later unlink +* the VMA from its anon_vma despite a restored mapping. +*/
You can drop the entire comment. This is what we should do in most cases where the mapping might be restored/changed, for example, in set_pmd_migration_entry().
Quoted 10 lines
mm/huge_memory.c +2
-1+ orig_pmd =pmdp_invalidate (vma, addr, pmdp);/* * Syncing against concurrent GUP-fast: -* - clear PMD; barrier; read refcount +* - invalidate PMD; barrier; read refcount * - inc refcount; barrier; read PMD */ smp_mb ();
mm/huge_memory.c static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma, · line 3619
Quoted 7 lines
mm/huge_memory.c +1
-0@@ -3607,6 +3613,7 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,return false; } +pmdp_huge_get_and_clear (mm, addr, pmdp);folio_remove_rmap_pmd (folio,pmd_page (orig_pmd), vma);zap_deposited_table (mm, pmdp);add_mm_counter (mm,MM_ANONPAGES , -HPAGE_PMD_NR );
Thanks!
Signature · 3 lines
Cheers, David
Zi Yan
reviewerQuoted 38 lines · Kyle Zeng
__discard_anon_folio_pmd_locked()clears and flushes a huge PMD before checking whether the folio can be discarded. If the folio was redirtied or has unexpected references, it restores the original PMD. Reclaim holds the PMD lock and theanon_vmaread lock, but not the owningmmap_lock.Both
zap_pmd_range()and mremap'sget_old_pmd()can skip a none PMD without taking its lock. A concurrentmunmap()or whole-VMAMREMAP_DONTUNMAPcan therefore miss the PMD and later unlink the source VMA from itsanon_vma, leaving a restored mapping behind. Theanon_vmawrite lock taken byunlink_anon_vmas()waits for reclaim to finish, but does not repeat the skipped page-table walk. Once the remaining VMA links are removed, the folio's positive mapcount no longer guarantees a liveanon_vma. Racing lazyfree reclaim againstMREMAP_DONTUNMAPas an unprivileged user reproduces a KASAN use-after-free infolio_lock_anon_vma_read().Use
pmdp_invalidate()to keep a recognizable, non-none huge PMD while the discard can still fail. Concurrent unmap and move operations then have to synchronize on the PMD lock instead of skipping the mapping. Clear the invalidated PMD only after the dirty and reference checks have succeeded, before removing the rmap and withdrawing the deposited page table. The full invalidation retains the TLB flush required for the dirty and GUP-fast checks.Fixes 735ecdfaf4e8 ("mm/vmscan: avoid split lazyfree THP during shrink_folio_list()")Assisted-by Codex:gpt-6-astraSigned-off-by Kyle Zeng <[email protected]>--- mm/huge_memory.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)mm/huge_memory.c +0
-0@@ -3569,11 +3569,17 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,return false;
mm/huge_memory.c static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma, · line 3578
Quoted 10 lines
mm/huge_memory.c +7
-1} - orig_pmd =pmdp_huge_clear_flush (vma, addr, pmdp); +/* +* The discard may fail, so keep the PMD non-none until we're +* committed to discarding it. Otherwise, concurrent munmap() or +* mremap() can skip the PMD without taking the PTL and later unlink +* the VMA from its anon_vma despite a restored mapping. +*/ + orig_pmd =pmdp_invalidate (vma, addr, pmdp);
There are some gaps we need to close before getting this fix in:
1. GUP-fast cannot follow the invalidated PMD: riscv and LoongArch need pmd_access_permitted() that requires _PAGE_PRESENT; s390's pmdp_invalidate() needs a change.
2. sparc64's thp_pte_count can be imbalanced with this change (based on Lance's offlist feedback).
In addition, powerpc has a page table check issue similr to riscv, where riscv fixed it with commit 9f4a88b8d01a6. This is not related to this issue but discovered along with the investigation.
Quoted 16 lines
mm/huge_memory.c +2
-1/* * Syncing against concurrent GUP-fast: -* - clear PMD; barrier; read refcount +* - invalidate PMD; barrier; read refcount * - inc refcount; barrier; read PMD */ smp_mb ();@@ -3607,6 +3613,7 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,return false; } +pmdp_huge_get_and_clear (mm, addr, pmdp);folio_remove_rmap_pmd (folio,pmd_page (orig_pmd), vma);zap_deposited_table (mm, pmdp);add_mm_counter (mm,MM_ANONPAGES , -HPAGE_PMD_NR );
Signature · 2 lines
Best Regards, Yan, Zi
David Hildenbrand (Arm)
maintainerQuoted 52 lines · Zi Yan
Quoted 38 lines · Kyle Zeng
__discard_anon_folio_pmd_locked()clears and flushes a huge PMD before checking whether the folio can be discarded. If the folio was redirtied or has unexpected references, it restores the original PMD. Reclaim holds the PMD lock and theanon_vmaread lock, but not the owningmmap_lock.Both
zap_pmd_range()and mremap'sget_old_pmd()can skip a none PMD without taking its lock. A concurrentmunmap()or whole-VMAMREMAP_DONTUNMAPcan therefore miss the PMD and later unlink the source VMA from itsanon_vma, leaving a restored mapping behind. Theanon_vmawrite lock taken byunlink_anon_vmas()waits for reclaim to finish, but does not repeat the skipped page-table walk. Once the remaining VMA links are removed, the folio's positive mapcount no longer guarantees a liveanon_vma. Racing lazyfree reclaim againstMREMAP_DONTUNMAPas an unprivileged user reproduces a KASAN use-after-free infolio_lock_anon_vma_read().Use
pmdp_invalidate()to keep a recognizable, non-none huge PMD while the discard can still fail. Concurrent unmap and move operations then have to synchronize on the PMD lock instead of skipping the mapping. Clear the invalidated PMD only after the dirty and reference checks have succeeded, before removing the rmap and withdrawing the deposited page table. The full invalidation retains the TLB flush required for the dirty and GUP-fast checks.Fixes 735ecdfaf4e8 ("mm/vmscan: avoid split lazyfree THP during shrink_folio_list()")Assisted-by Codex:gpt-6-astraSigned-off-by Kyle Zeng <[email protected]>--- mm/huge_memory.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)mm/huge_memory.c +0
-0@@ -3569,11 +3569,17 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,return false;mm/huge_memory.c static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma, · line 3578
Quoted 10 lines
mm/huge_memory.c +7
-1} - orig_pmd =pmdp_huge_clear_flush (vma, addr, pmdp); +/* +* The discard may fail, so keep the PMD non-none until we're +* committed to discarding it. Otherwise, concurrent munmap() or +* mremap() can skip the PMD without taking the PTL and later unlink +* the VMA from its anon_vma despite a restored mapping. +*/ + orig_pmd =pmdp_invalidate (vma, addr, pmdp);There are some gaps we need to close before getting this fix in:
Quoted 3 lines
1. GUP-fast cannot follow the invalidated PMD: riscv and LoongArch need
pmd_access_permitted()that requires_PAGE_PRESENT; s390'spmdp_invalidate()needs a change.
Ugh. We really need pmdp_invalidate() to have reasonable semantics. This whole PMD locking is a mess :(
Quoted 3 lines
2. sparc64's
thp_pte_countcan be imbalanced with this change (based on Lance's offlist feedback).
Ack.
Quoted 4 lines
In addition, powerpc has a page table check issue similr to riscv, where riscv fixed it with commit
9f4a88b8d01a6. This is not related to this issue but discovered along with the investigation.
Zi, do you have the capacity to take over this patch?
Signature · 3 lines
Cheers, David
Zi Yan
reviewerQuoted 64 lines · David Hildenbrand (Arm)
Quoted 52 lines · Zi Yan
Quoted 38 lines · Kyle Zeng
__discard_anon_folio_pmd_locked()clears and flushes a huge PMD before checking whether the folio can be discarded. If the folio was redirtied or has unexpected references, it restores the original PMD. Reclaim holds the PMD lock and theanon_vmaread lock, but not the owningmmap_lock.Both
zap_pmd_range()and mremap'sget_old_pmd()can skip a none PMD without taking its lock. A concurrentmunmap()or whole-VMAMREMAP_DONTUNMAPcan therefore miss the PMD and later unlink the source VMA from itsanon_vma, leaving a restored mapping behind. Theanon_vmawrite lock taken byunlink_anon_vmas()waits for reclaim to finish, but does not repeat the skipped page-table walk. Once the remaining VMA links are removed, the folio's positive mapcount no longer guarantees a liveanon_vma. Racing lazyfree reclaim againstMREMAP_DONTUNMAPas an unprivileged user reproduces a KASAN use-after-free infolio_lock_anon_vma_read().Use
pmdp_invalidate()to keep a recognizable, non-none huge PMD while the discard can still fail. Concurrent unmap and move operations then have to synchronize on the PMD lock instead of skipping the mapping. Clear the invalidated PMD only after the dirty and reference checks have succeeded, before removing the rmap and withdrawing the deposited page table. The full invalidation retains the TLB flush required for the dirty and GUP-fast checks.Fixes 735ecdfaf4e8 ("mm/vmscan: avoid split lazyfree THP during shrink_folio_list()")Assisted-by Codex:gpt-6-astraSigned-off-by Kyle Zeng <[email protected]>--- mm/huge_memory.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)mm/huge_memory.c +0
-0@@ -3569,11 +3569,17 @@ static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma,return false;mm/huge_memory.c static bool __discard_anon_folio_pmd_locked(struct vm_area_struct *vma, · line 3578
Quoted 10 lines
mm/huge_memory.c +7
-1} - orig_pmd =pmdp_huge_clear_flush (vma, addr, pmdp); +/* +* The discard may fail, so keep the PMD non-none until we're +* committed to discarding it. Otherwise, concurrent munmap() or +* mremap() can skip the PMD without taking the PTL and later unlink +* the VMA from its anon_vma despite a restored mapping. +*/ + orig_pmd =pmdp_invalidate (vma, addr, pmdp);There are some gaps we need to close before getting this fix in:
Quoted 3 lines
1. GUP-fast cannot follow the invalidated PMD: riscv and LoongArch need
pmd_access_permitted()that requires_PAGE_PRESENT; s390'spmdp_invalidate()needs a change.Ugh. We really need
pmdp_invalidate()to have reasonable semantics. This whole PMD locking is a mess :(Quoted 3 lines
2. sparc64's
thp_pte_countcan be imbalanced with this change (based on Lance's offlist feedback).
Quoted 8 lines
Ack.
Quoted 4 lines
In addition, powerpc has a page table check issue similr to riscv, where riscv fixed it with commit
9f4a88b8d01a6. This is not related to this issue but discovered along with the investigation.Zi, do you have the capacity to take over this patch?
Yes, I can take over it. My plan is to send a series including patches for 1 and this patch as is. powerpc fix can be a separate one.
Best Regards,
Yan, Zi
David Hildenbrand (Arm)
maintainerQuoted 24 lines · Zi Yan
Quoted 22 lines · David Hildenbrand (Arm)
Quoted 6 lines · Zi Yan
There are some gaps we need to close before getting this fix in:
1. GUP-fast cannot follow the invalidated PMD: riscv and LoongArch need
pmd_access_permitted()that requires_PAGE_PRESENT; s390'spmdp_invalidate()needs a change.Ugh. We really need
pmdp_invalidate()to have reasonable semantics. This whole PMD locking is a mess :(Quoted 3 lines
2. sparc64's
thp_pte_countcan be imbalanced with this change (based on Lance's offlist feedback).Ack.
Quoted 4 lines
In addition, powerpc has a page table check issue similr to riscv, where riscv fixed it with commit
9f4a88b8d01a6. This is not related to this issue but discovered along with the investigation.
Quoted 7 lines
Quoted 1 line
Zi, do you have the capacity to take over this patch?
Yes, I can take over it. My plan is to send a series including patches for 1 and this patch as is. powerpc fix can be a separate one.
Best Regards,
Yan, Zi
If we need a quick stable fix we could temporarily disable the whole thing until it is fixed, just a thought.
Signature · 3 lines
Cheers, David
Lance Yang
reviewerQuoted 27 lines · David Hildenbrand (Arm)
Quoted 26 lines · Zi Yan
Quoted 23 lines · David Hildenbrand (Arm)
Quoted 6 lines · Zi Yan
There are some gaps we need to close before getting this fix in:
1. GUP-fast cannot follow the invalidated PMD: riscv and LoongArch need
pmd_access_permitted()that requires_PAGE_PRESENT; s390'spmdp_invalidate()needs a change.Ugh. We really need
pmdp_invalidate()to have reasonable semantics. This whole PMD locking is a mess :(Quoted 3 lines
2. sparc64's
thp_pte_countcan be imbalanced with this change (based on Lance's offlist feedback).Ack.
Quoted 4 lines
In addition, powerpc has a page table check issue similr to riscv, where riscv fixed it with commit
9f4a88b8d01a6. This is not related to this issue but discovered along with the investigation.Zi, do you have the capacity to take over this patch?
Quoted 8 lines
Quoted 5 lines
Yes, I can take over it. My plan is to send a series including patches for 1 and this patch as is. powerpc fix can be a separate one.
Best Regards,
Yan, ZiIf we need a quick stable fix we could temporarily disable the whole thing until it is fixed, just a thought.
+1 we could do that for now. A quick fix with minimal churn (correctness comes first).
Zi Yan
reviewerQuoted 33 lines · Lance Yang
Quoted 30 lines · David Hildenbrand (Arm)
Quoted 29 lines · Zi Yan
Quoted 15 lines · David Hildenbrand (Arm)
Quoted 6 lines · Zi Yan
There are some gaps we need to close before getting this fix in:
1. GUP-fast cannot follow the invalidated PMD: riscv and LoongArch need
pmd_access_permitted()that requires_PAGE_PRESENT; s390'spmdp_invalidate()needs a change.Ugh. We really need
pmdp_invalidate()to have reasonable semantics. This whole PMD locking is a mess :(Quoted 3 lines
2. sparc64's
thp_pte_countcan be imbalanced with this change (based on Lance's offlist feedback).Quoted 8 lines
Ack.
Quoted 4 lines
In addition, powerpc has a page table check issue similr to riscv, where riscv fixed it with commit
9f4a88b8d01a6. This is not related to this issue but discovered along with the investigation.Zi, do you have the capacity to take over this patch?
Yes, I can take over it. My plan is to send a series including patches for 1 and this patch as is. powerpc fix can be a separate one.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Best Regards,
Yan, ZiIf we need a quick stable fix we could temporarily disable the whole thing until it is fixed, just a thought.
+1 we could do that for now. A quick fix with minimal churn (correctness comes first).
How about the patch below? unmap_huge_pmd_locked() and __discard_anon_folio_pmd_locked() will be dead code to keep the patch small. Later, with arch fixes, the function can be re-enabled.
From 2204b9d08530796847a586428b1f782b987d071c Mon Sep 17 00:00:00 2001
From: Zi Yan <[email protected]>
Date: Fri, 9 Oct 2026 21:28:10 -0400
Subject: [PATCH] mm/rmap: don't discard lazyfree THPs at PMD level
__discard_anon_folio_pmd_locked() clears a lazyfree THP PMD before it knows whether the folio can be discarded, and restores it if the folio was redirtied or has extra references. A concurrent munmap() or MREMAP_DONTUNMAP skips the temporary none PMD and unlinks the VMA from its anon_vma, so the folio stays mapped after the anon_vma is freed and a later rmap walk uses the freed anon_vma.
Using an invalidated PMD instead of a cleared one requires additional arch code fixes. Instead, disable the PMD level discard of lazyfree THPs, as before commit 735ecdfaf4e8 ("mm/vmscan: avoid split lazyfree THP during shrink_folio_list()").
--- mm/rmap.c | 11 ----------- 1 file changed, 11 deletions(-)
mm/rmap.c +0 -11
@@ -2275,17 +2275,6 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, }if (!pvmw.pte) { -if (folio_test_lazyfree (folio)) { -if (unmap_huge_pmd_locked (vma, pvmw.address, pvmw.pmd, folio)) - goto walk_done; -/* -* unmap_huge_pmd_locked has either already marked -* the folio as swap-backed or decided to retain it -* due to GUP or speculative references. -*/ - goto walk_abort; - } -if (flags &TTU_SPLIT_HUGE_PMD ) {/* * We temporarily have to drop the PTL and
Signature · 7 lines
2.53.0 -- Best Regards, Yan, Zi
Quoted 40 lines · Zi Yan
Quoted 39 lines · Lance Yang
Quoted 35 lines · David Hildenbrand (Arm)
Quoted 24 lines · Zi Yan
Quoted 22 lines · David Hildenbrand (Arm)
Quoted 6 lines · Zi Yan
There are some gaps we need to close before getting this fix in:
1. GUP-fast cannot follow the invalidated PMD: riscv and LoongArch need
pmd_access_permitted()that requires_PAGE_PRESENT; s390'spmdp_invalidate()needs a change.Ugh. We really need
pmdp_invalidate()to have reasonable semantics. This whole PMD locking is a mess :(Quoted 3 lines
2. sparc64's
thp_pte_countcan be imbalanced with this change (based on Lance's offlist feedback).Ack.
Quoted 4 lines
In addition, powerpc has a page table check issue similr to riscv, where riscv fixed it with commit
9f4a88b8d01a6. This is not related to this issue but discovered along with the investigation.Quoted 7 lines
Quoted 1 line
Zi, do you have the capacity to take over this patch?
Yes, I can take over it. My plan is to send a series including patches for 1 and this patch as is. powerpc fix can be a separate one.
Best Regards,
Yan, ZiIf we need a quick stable fix we could temporarily disable the whole thing until it is fixed, just a thought.
Quoted 6 lines
Quoted 2 lines
+1 we could do that for now. A quick fix with minimal churn (correctness comes first).
How about the patch below?
unmap_huge_pmd_locked()and__discard_anon_folio_pmd_locked()will be dead code to keep the patch small. Later, with arch fixes, the function can be re-enabled.
Looks good to me! Thanks for the quick fix!
Quoted 19 lines
From
2204b9d08530796847a586428b1f782b987d071cMon Sep 17 00:00:00 2001
From: Zi Yan <[email protected]>
Date: Fri, 9 Oct 2026 21:28:10 -0400
Subject: [PATCH] mm/rmap: don't discard lazyfree THPs at PMD level
__discard_anon_folio_pmd_locked()clears a lazyfree THP PMD before it knows whether the folio can be discarded, and restores it if the folio was redirtied or has extra references. A concurrentmunmap()orMREMAP_DONTUNMAPskips the temporary none PMD and unlinks the VMA from itsanon_vma, so the folio stays mapped after theanon_vmais freed and a later rmap walk uses the freedanon_vma.Using an invalidated PMD instead of a cleared one requires additional arch code fixes. Instead, disable the PMD level discard of lazyfree THPs, as before commit
735ecdfaf4e8("mm/vmscan: avoid split lazyfree THP duringshrink_folio_list()").
Quoted 7 lines
Fixes 735ecdfaf4e8 ("mm/vmscan: avoid split lazyfree THP during shrink_folio_list()")Reported-by Kyle Zeng <[email protected]>Assisted-by LLMSigned-off-by Zi Yan <[email protected]>---
Quoted 25 lines
mm/rmap.c | 11 ----------- 1 file changed, 11 deletions(-)mm/rmap.c +0
-11@@ -2275,17 +2275,6 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, }if (!pvmw.pte) { -if (folio_test_lazyfree (folio)) { -if (unmap_huge_pmd_locked (vma, pvmw.address, pvmw.pmd, folio)) - goto walk_done; -/* -* unmap_huge_pmd_locked has either already marked -* the folio as swap-backed or decided to retain it -* due to GUP or speculative references. -*/ - goto walk_abort; - } -if (flags &TTU_SPLIT_HUGE_PMD ) {/* * We temporarily have to drop the PTL and