Re: [PATCH v2] mm/shmem, swap: fix race of truncate and swap entry split
From: Kairui Song
Date: Sun Jan 18 2026 - 22:17:52 EST
On Mon, Jan 19, 2026 at 11:04 AM Baolin Wang
<baolin.wang@xxxxxxxxxxxxxxxxx> wrote:
> On 1/19/26 12:55 AM, Kairui Song wrote:
> > From: Kairui Song <kasong@xxxxxxxxxxx>
> >
> > if (!swaps_freed) {
> > + /*
> > + * If found a large swap entry cross the end border,
> > + * skip it as the truncate_inode_partial_folio above
> > + * should have at least zerod its content once.
> > + */
> > + order = shmem_confirm_swap(mapping, indices[i],
> > + radix_to_swp_entry(folio));
> > + if (order > 0 && indices[i] + order > end)
> > + continue;
>
> The latter check shoud be 'indices[i] + 1 << order > end', right?
Yes, you are right, it should be 1 << order, thanks!