Re: [PATCH 0/3] mm/lru_gen: move lru_gen control interface from debugfs to procfs

Barry Song
2025-12-01T10:39:40Z

Hi Zicheng,

On Mon, Dec 1, 2025 at 5:55 PM wangzicheng <wangzicheng@honor.com> wrote:
>
> Hi Barry,
>
> Thank you for the comment, actually we do know the cgroup file.
>
> What we really need is to *proactive aging 2~3 gens* before proactive reclaim.
> (especially after cold launches when no anon pages in the oldest gens)
>
> The proactive aging also helps distribute the anon and file pages evenly in
> MGLRU gens. And reclaiming won't fall into file caches.

I’m not quite sure what you mean by “reclaiming won’t fall into file caches.”

I assume you mean you configured a high swappiness for MGLRU proactive
reclamation, so when both anon and file have four generations,
`get_type_to_scan()` effectively always returns anon?

>
> > Also note that memcg already has an interface for proactive reclamation,
> > so I’m not certain whether your patchset can coexist with it or extend
> > it to meet your requirements—which seems quite impossible to me
> >
> > memory.reclaim
> > A write-only nested-keyed file which exists for all cgroups.
> >
> > This is a simple interface to trigger memory reclaim in the
> > target cgroup.
> >
> > Example::
> >
> > echo "1G" > memory.reclaim
> >
> > Please note that the kernel can over or under reclaim from
> > the target cgroup. If less bytes are reclaimed than the
> > specified amount, -EAGAIN is returned.
> >
> This remind me that adding a `memor.aging` under memcg directories
> rather than adding new procfs files is also a great option.

I still don’t understand why. Aging is something MGLRU itself should
handle; components outside MGLRU, such as cgroup v2, do not need to be
aware of this concept at all. Exposing it will likely lead to another
immediate NAK.

In short, aging should remain within MGLRU’s internal scope.

But it seems you do want some policy control for your proactive
reclamation, such as always reclaiming anon pages or reclaiming them
more aggressively than file pages. I assume Zhongkun’s patch [1] we
mentioned earlier should provide support for that, correct?

As a workaround, you can set `swappiness=max` for `memory.reclaim` before
we internally improve the handling of the aging issue. In short,
“proactive aging” and similar mechanisms should be handled automatically
and internally within the scope of the MGLRU code.

[1] https://lore.kernel.org/linux-mm/cover.1744169302.git.hezhongkun.hzk@bytedance.com/

Thanks
Barry