The patch titled Subject: mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list-fix has been added to the -mm mm-unstable branch. Its filename is mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list-fix.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list-fix.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: Lance Yang <ioworker0@xxxxxxxxx> Subject: mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list-fix Date: Thu, 13 Jun 2024 15:28:58 +0800 fix bug: https://lore.kernel.org/linux-mm/20240613065521.15960-1-ioworker0@xxxxxxxxx/ Link: https://lkml.kernel.org/r/20240613072858.16512-1-ioworker0@xxxxxxxxx Signed-off-by: Lance Yang <ioworker0@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/huge_memory.c | 10 +++------- mm/rmap.c | 7 +------ 2 files changed, 4 insertions(+), 13 deletions(-) --- a/mm/huge_memory.c~mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list-fix +++ a/mm/huge_memory.c @@ -2707,10 +2707,8 @@ static bool __discard_anon_folio_pmd_loc if (unlikely(page_folio(page) != folio)) return false; - if (folio_test_dirty(folio) || pmd_dirty(orig_pmd)) { - folio_set_swapbacked(folio); + if (folio_test_dirty(folio) || pmd_dirty(orig_pmd)) return false; - } orig_pmd = pmdp_huge_clear_flush(vma, addr, pmdp); @@ -2737,10 +2735,8 @@ static bool __discard_anon_folio_pmd_loc * * The only folio refs must be one from isolation plus the rmap(s). */ - if (folio_test_dirty(folio) || pmd_dirty(orig_pmd)) - folio_set_swapbacked(folio); - - if (folio_test_swapbacked(folio) || ref_count != map_count + 1) { + if (folio_test_dirty(folio) || pmd_dirty(orig_pmd) || + ref_count != map_count + 1) { set_pmd_at(mm, addr, pmdp, orig_pmd); return false; } --- a/mm/rmap.c~mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list-fix +++ a/mm/rmap.c @@ -1824,12 +1824,7 @@ static bool try_to_unmap_one(struct foli */ if (unlikely(folio_test_swapbacked(folio) != folio_test_swapcache(folio))) { - /* - * unmap_huge_pmd_locked() will unmark a - * PMD-mapped folio as lazyfree if the folio or - * its PMD was redirtied. - */ - WARN_ON_ONCE(!pmd_mapped); + WARN_ON_ONCE(1); goto walk_done_err; } _ Patches currently in -mm which might be from ioworker0@xxxxxxxxx are mm-rmap-remove-duplicated-exit-code-in-pagewalk-loop.patch mm-rmap-add-helper-to-restart-pgtable-walk-on-changes.patch mm-rmap-integrate-pmd-mapped-folio-splitting-into-pagewalk-loop.patch mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list.patch mm-vmscan-avoid-split-lazyfree-thp-during-shrink_folio_list-fix.patch mm-mlock-implement-folio_mlock_step-using-folio_pte_batch.patch