Re: [PATCH v2] mm: vmscan: avoid anon scanning for GFP_NOIO with low swapcache

From: Bo Zhang

Date: Sun Sep 06 2026 - 01:04:44 EST


Thanks Barry.

On Sun, Sep 6, 2026 at 12:53 PM Barry Song <baohua@xxxxxxxxxx> wrote:
>
> I notice this only fixes the active/inactive LRU case. To address the
> MGLRU case, it seems we may need a more fundamental change.
>
> I'm fine with starting by fixing the active/inactive LRU case first.
> However, could we mention in the changelog that this patch only
> addresses the active/inactive LRU case, and that fixing the MGLRU case
> is on the TODO list?

You're right - MGLRU decides anon vs file scanning in its own path
(get_type_to_scan()/isolate_folios()) and does not go through this
can_reclaim_anon_pages() check for normal reclaim, so it is not covered
here. I'll note in the changelog that this patch only addresses the
active/inactive LRU case and that the MGLRU case is left as a TODO.

> > - if (get_nr_swap_pages() > 0)
> > + if (get_nr_swap_pages() > 0 &&
> > + !reclaimable_anon_is_low(memcg, nid, sc))
>
> Can we also update the comment above accordingly?
>
> /*
> * For non-memcg reclaim, do we have space on any swap device?
> * For GFP_NOIO, do we also have sufficient swapcache anon folios
> * to reclaim?
> */

Will do in v3.

> > - if (mem_cgroup_get_nr_swap_pages(memcg) > 0)
> > + if (mem_cgroup_get_nr_swap_pages(memcg) > 0 &&
> > + !reclaimable_anon_is_low(memcg, nid, sc))
>
> Do we also need to update the comment?
>
> /*
> * Is the memcg above its swap limit, and does it have enough
> * swapcache anon folios to reclaim for GFP_NOIO?
> */

Yes, updated both comments in v3.

Thanks,
Bo