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

From: David Hildenbrand (Arm)

Date: Mon Nov 02 2026 - 01:54:02 EST


On 11/1/26 16:46, Mani Tofigh wrote:
> 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.

Was just a quick hack to se what we could do with the function name. With the
VM_WARN_ON_ONCE() we might also just move the folio-swapbache dropping to the
caller, leaving the VM_WARN_ON_ONCE() check in there.

Yes, please resend against core.git, thanks!

--
Cheers,

David