Re: [PATCH] mm/swapfile: drop a large unmapped swap-in folio in unuse_pte()

From: Mani Tofigh

Date: Sun Nov 01 2026 - 10:46:31 EST


On 10/30/26 6:15 PM, David Hildenbrand (Arm) wrote:
Why is this special to large folios? I guess because a single PTE keeps the
large folio alive, right?

Yup. For a small folio the one PTE maps all of it so
folio_add_new_anon_rmap() is fine there. For a larger one it marks
every page as mapped and exclusive even though only one PTE got mapped.

Can you pack the existing handling in do_swap_page() into a helper, pass
nr_pages, and reuse it here?
Sounds good, I'll do that in v2 and send it against mm/core.git
for-next. One small thing in the helper you suggested though:
the first check should be folio_test_anon() instead of
!folio_test_anon(), otherwise a large non-anon folio would
still get mapped.

Thanks!
Mani