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

From: Andrew Morton

Date: Sun Dec 14 2025 - 18:49:45 EST


On Sat, 13 Dec 2025 14:06:39 +0530 Deepanshu Kartikey <kartikey406@xxxxxxxxx> wrote:

> When laptop_mode is enabled, may_writepage is set to 0 in
> try_to_free_mem_cgroup_pages(). This triggers a warning in MGLRU's
> lru_gen_shrink_lruvec():
>
> VM_WARN_ON_ONCE(!sc->may_writepage || !sc->may_unmap);
>
> The warning occurs because MGLRU expects full reclaim capabilities to
> function correctly. The call path is:
>
> mem_cgroup_resize_max()
> try_to_free_mem_cgroup_pages()
> do_try_to_free_pages()
> shrink_node()
> shrink_lruvec()
> lru_gen_shrink_lruvec() <-- WARNING
>
> Unlike kswapd or direct reclaim where laptop_mode's disk-saving behavior
> is a reasonable optimization, memcg limit enforcement is a hard
> requirement - memory MUST be freed when a cgroup exceeds its limit.
> The may_unmap field is already set unconditionally to 1 in this path,
> acknowledging that memcg reclaim needs full capabilities.
>
> Set may_writepage unconditionally to 1 for memcg reclaim to ensure
> MGLRU works correctly and memory limits are properly enforced.
>

Thanks, I'll add this to mm.git's mm-new branch for testing. I expect
a few days after that I'll quietly move it into the mm-unstable branch
where it will receive linux-next exposure. Further progress into
mm.git's non-rebasing for-next-merge-window mm-stable branch will
depend upon review outcomes.