Re: [PATCH v5 08/14] mm/mglru: remove redundant swap constrained check upon isolation
From: Chen Ridong
Date: Tue Apr 14 2026 - 03:44:06 EST
On 2026/4/13 0:48, Kairui Song via B4 Relay 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
> 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>
> ---
> mm/vmscan.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 5ae6bd967b17..965d8905a4fe 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -4650,12 +4650,6 @@ static bool isolate_folio(struct lruvec *lruvec, struct folio *folio, struct sca
> {
> bool success;
>
> - /* swap constrained */
> - if (!(sc->gfp_mask & __GFP_IO) &&
> - (folio_test_dirty(folio) ||
> - (folio_test_anon(folio) && !folio_test_swapcache(folio))))
> - return false;
> -
> /* raced with release_pages() */
> if (!folio_try_get(folio))
> return false;
>
Reviewed-by: Chen Ridong <chenridong@xxxxxxxxxxxxxxx>
--
Best regards,
Ridong