Re: [PATCH v2 12/14] mm/shmem: fix truncate loop after boundary swapin failure
From: David Hildenbrand (Arm)
Date: Wed Oct 28 2026 - 04:22:53 EST
On 10/28/26 02:30, Baolin Wang wrote:
>
>
> On 10/27/26 9:03 PM, David Hildenbrand (Arm) wrote:
>> If swapping in a large entry at the new EOF fails, shmem_undo_range()
>> leaves the entry in place. Its final scan skips the entry, then restarts
>> from the same start index and finds it again. Truncation can loop forever
>> while holding i_rwsem.
>
> Right. But ...
>
>> Advance start past the skipped entry so that a restarted scan can finish,
>> as we already do for folios that cannot be split.
>
> IIRC, we originally avoided advancing start because a concurrent swapin fault
> could split the boundary large swap entry via shmem_split_large_entry(), leaving
> small swap entries below the new start.
>
> Sigh.
>
> There doesn't seem to be a simple fix. We may need to swap in the large entry as
> shmem_get_partial_folio() does, and then split the large folio. I'll work on
> this as a follow-up.
Thanks!
So you are fine with the patch as is to fix the endless loop?
--
Cheers,
David