Re: [PATCH v2 8/9] mm/rmap: re-enable discarding lazyfree THPs at PMD level
From: Lance Yang
Date: Sat Dec 05 2026 - 00:30:32 EST
On Thu, Dec 03, 2026 at 11:17:56PM -0500, Zi Yan wrote:
[...]
>diff --git a/mm/rmap.c b/mm/rmap.c
>index f0c17d2e04847..32acae9efc313 100644
>--- a/mm/rmap.c
>+++ b/mm/rmap.c
>@@ -2285,6 +2285,19 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
> }
>
> if (!pvmw.pte) {
>+ if (folio_test_lazyfree(folio)) {
Good to have PMD-level lazyfree discard back :D
>+ /* Update high watermark before we lower rss */
>+ update_hiwater_rss(mm);
And, thanks (x1024) for picking up the update_hiwater_rss() bit I missed
back then :)
>+ 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;
>+ }
>+
Assuming the flush_cache_range() piece from patch 7 is sorted out, LGTM!
Reviewed-by: Lance Yang <lance.yang@xxxxxxxxx>