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

From: Mani Tofigh

Date: Sun Nov 01 2026 - 10:55:04 EST


On 10/31/26 1:54 AM, Kairui Song wrote:
On Sat, Oct 31, 2026 at 6:54 AM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
Also, won't this change cause try_to_unuse() to keep spinning away until
someone kills it? Might be better to return -EBUSY and fail the
swapoff?

It seems fine? The folio is removed from the swap cache, so the next pass
will go on. But you're right about the dirty and WARN case, it spins, so
maybe:

if (unlikely(folio_test_large(folio) && !folio_test_anon(folio))) {
if (WARN_ON_ONCE(folio_test_dirty(folio)))
return -EBUSY;
swap_cache_del_folio(folio);
return 0;
}


Right, in the normal case the next pass of try_to_unuse() just swaps the
entry in as a small folio, so only the dirty case would spin.

David suggested a VM_WARN_ON_ONCE() since a dirty folio here would mean
a bug elsewhere, so for v2 I'm thinking of combining the two. It'd be
a VM_WARN_ON_ONCE() for the dirty case, and the folio stays in the swap
cache with -EBUSY returned.

Thanks for taking a look!

Mani