Re: [PATCH v5 08/14] mm/mglru: remove redundant swap constrained check upon isolation
From: Barry Song
Date: Thu Apr 16 2026 - 05:05:29 EST
On Mon, Apr 13, 2026 at 12:48 AM Kairui Song via B4 Relay
<devnull+kasong.tencent.com@xxxxxxxxxx> wrote:
>
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> Remove the swap-constrained early reject check upon isolation. This
> check is a micro optimization when swap IO is not allowed, so folios are
> rejected early. But it is redundant and overly broad since
> shrink_folio_list() already handles all these cases with proper
> granularity.
>
> Notably, this check wrongly rejected lazyfree folios, and it doesn't
It seems the original code somehow missed folio_test_swapbacked().
> cover all rejection cases. shrink_folio_list() uses may_enter_fs(),
> which distinguishes non-SWP_FS_OPS devices from filesystem-backed swap
> and does all the checks after folio is locked, so flags like swap cache
> are stable.
>
> This check also covers dirty file folios, which are not a problem now
> since sort_folio() already bumps dirty file folios to the next
> generation, but causes trouble for unifying dirty folio writeback
> handling.
>
> And there should be no performance impact from removing it. We may have
> lost a micro optimization, but unblocked lazyfree reclaim for NOIO
> contexts, which is not a common case in the first place.
>
> Reviewed-by: Axel Rasmussen <axelrasmussen@xxxxxxxxxx>
> Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
Reviewed-by: Barry Song <baohua@xxxxxxxxxx>