Re: [PATCH] mm: vmscan: always allow writeback during memcg reclaim

Johannes Weiner
2025-12-15T20:22:18Z

On Mon, Dec 15, 2025 at 01:42:27PM -0600, Yuanchu Xie wrote:
> On Sun, Dec 14, 2025 at 10:52 PM Deepanshu Kartikey
> <kartikey406@gmail.com> wrote:
> >
> > On Mon, Dec 15, 2025 at 9:42 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
> >
> > > > Fixes: bd74fdaea146 ("mm: multi-gen LRU: support page table walks")
> > >
> > > That seems unrelated?
> >
> > Sorry for the wrong fixes. Correct Fixes: ee814fe23daf ("mm: vmscan:
> > clean up struct scan_control")
> >
> > I'll wait for input from someone with MGLRU context on the broader discussion.
> >
> This warning came from commit e9d4e1ee7880 ("mm: multi-gen LRU:
> clarify scan_control flags") [1].
>
> The original rationale:
> > 4. sc->may_writepage and sc->may_unmap, which indicates opportunistic
> > reclaim, are rejected, since unmapped clean folios are already
> > prioritized. Scanning for more of them is likely futile and can
> > cause high reclaim latency when there is a large number of memcgs.
>
> As far as I can tell this was a sanity check to ensure
> `lru_gen_shrink_lruvec` avoids extra work for minimal gain. Perhaps
> this shouldn't be a warning? Always setting may_writepage in this case
> would free more folios. I'm not against removing the warning either.

The premise doesn't seem correct. Aside from laptop_mode, they're used
in those scenarios:

- zone_reclaim_mode: local node is full and user would prefer clean
and/or unmapped pages over spilling to remote nodes

- watermark_boost: the page allocator finds itself in a situation
where it needs to fragment pageblocks, and it calls for additional
reclaim to get out of that situation

Neither of them are opportunistic. It's user-requested behavior.