[PATCH 2/3] mm/lru_gen: add configuration option to select debugfs/procfs for lru_gen

Zicheng Wang posted 3 patches 2 months, 2 weeks ago
[PATCH 2/3] mm/lru_gen: add configuration option to select debugfs/procfs for lru_gen
Posted by Zicheng Wang 2 months, 2 weeks ago
Signed-off-by: Zicheng Wang <wangzicheng@honor.com>
---
 mm/Kconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/mm/Kconfig b/mm/Kconfig
index e443fe8cd..be7efa794 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -1325,6 +1325,16 @@ config LRU_GEN_STATS
 config LRU_GEN_WALKS_MMU
 	def_bool y
 	depends on LRU_GEN && ARCH_HAS_HW_PTE_YOUNG
+
+config LRU_GEN_PROCFS_CTRL
+	bool "Move lru_gen files from debugfs to procfs"
+	depends on LRU_GEN && PROC_FS
+	help
+	  Move lru_gen management from debugfs to procfs (/proc/lru_gen).
+	  This production-ready feature provides critical memory reclaim
+	  prediction and control. It is no longer experimental.
+	  The migration ensures availability in commercial products where
+	  debugfs may be disabled.
 # }
 
 config ARCH_SUPPORTS_PER_VMA_LOCK
-- 
2.25.1
Re: [PATCH 2/3] mm/lru_gen: add configuration option to select debugfs/procfs for lru_gen
Posted by Yuanchu Xie 2 months, 1 week ago
On Thu, Nov 27, 2025 at 8:54 PM Zicheng Wang <wangzicheng@honor.com> wrote:
>
> Signed-off-by: Zicheng Wang <wangzicheng@honor.com>
> ---
>  mm/Kconfig | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/mm/Kconfig b/mm/Kconfig
> index e443fe8cd..be7efa794 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -1325,6 +1325,16 @@ config LRU_GEN_STATS
>  config LRU_GEN_WALKS_MMU
>         def_bool y
>         depends on LRU_GEN && ARCH_HAS_HW_PTE_YOUNG
> +
> +config LRU_GEN_PROCFS_CTRL
> +       bool "Move lru_gen files from debugfs to procfs"
> +       depends on LRU_GEN && PROC_FS
> +       help
> +         Move lru_gen management from debugfs to procfs (/proc/lru_gen).
> +         This production-ready feature provides critical memory reclaim
> +         prediction and control. It is no longer experimental.
> +         The migration ensures availability in commercial products where
> +         debugfs may be disabled.
Hi Zicheng,

A config option determining where LRU_gen files reside creates a
fragile procfs interface. Consider adding a similar interface with
less implementation detail to /sys/kernel/mm/lru_gen/ if the goal is
to stabilize the debugfs APIs.

If the goal is to proactively age lruvecs that have been at
MIN_NR_GENS for some time/events/etc, is it possible to integrate this
into the kernel and avoid leaking MGLRU implementation details into
userspace?

Thanks,
Yuanchu
RE: [PATCH 2/3] mm/lru_gen: add configuration option to select debugfs/procfs for lru_gen
Posted by wangzicheng 2 months, 1 week ago
Hi Yuanchu,

> 
> On Thu, Nov 27, 2025 at 8:54 PM Zicheng Wang <wangzicheng@honor.com>
> wrote:
> >
> > Signed-off-by: Zicheng Wang <wangzicheng@honor.com>
> > ---
> >  mm/Kconfig | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/mm/Kconfig b/mm/Kconfig
> > index e443fe8cd..be7efa794 100644
> > --- a/mm/Kconfig
> > +++ b/mm/Kconfig
> > @@ -1325,6 +1325,16 @@ config LRU_GEN_STATS
> >  config LRU_GEN_WALKS_MMU
> >         def_bool y
> >         depends on LRU_GEN && ARCH_HAS_HW_PTE_YOUNG
> > +
> > +config LRU_GEN_PROCFS_CTRL
> > +       bool "Move lru_gen files from debugfs to procfs"
> > +       depends on LRU_GEN && PROC_FS
> > +       help
> > +         Move lru_gen management from debugfs to procfs (/proc/lru_gen).
> > +         This production-ready feature provides critical memory reclaim
> > +         prediction and control. It is no longer experimental.
> > +         The migration ensures availability in commercial products where
> > +         debugfs may be disabled.
> Hi Zicheng,
> 
> A config option determining where LRU_gen files reside creates a
> fragile procfs interface. Consider adding a similar interface with
> less implementation detail to /sys/kernel/mm/lru_gen/ if the goal is
> to stabilize the debugfs APIs.

Thank you for the comments.
Your suggestion on sysfs really make sence. The only challenge is the show
buffers of sysfs are limited to PAGE_SIZE according to the kernel doc.
It can hardly show all memcg infos in a single read, as debugfs file
currently does.

> 
> If the goal is to proactively age lruvecs that have been at
> MIN_NR_GENS for some time/events/etc, is it possible to integrate this
> into the kernel and avoid leaking MGLRU implementation details into
> userspace?

We will explore the possible options in the next version. :-)

> 
> Thanks,
> Yuanchu

Best,
Zicheng
Re: [PATCH 2/3] mm/lru_gen: add configuration option to select debugfs/procfs for lru_gen
Posted by Randy Dunlap 2 months, 1 week ago

On 11/27/25 6:53 PM, Zicheng Wang wrote:
> Signed-off-by: Zicheng Wang <wangzicheng@honor.com>
> ---
>  mm/Kconfig | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/mm/Kconfig b/mm/Kconfig
> index e443fe8cd..be7efa794 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -1325,6 +1325,16 @@ config LRU_GEN_STATS
>  config LRU_GEN_WALKS_MMU
>  	def_bool y
>  	depends on LRU_GEN && ARCH_HAS_HW_PTE_YOUNG
> +
> +config LRU_GEN_PROCFS_CTRL
> +	bool "Move lru_gen files from debugfs to procfs"
> +	depends on LRU_GEN && PROC_FS
> +	help
> +	  Move lru_gen management from debugfs to procfs (/proc/lru_gen).
> +	  This production-ready feature provides critical memory reclaim
> +	  prediction and control. It is no longer experimental.
> +	  The migration ensures availability in commercial products where
> +	  debugfs may be disabled.

A. missing patch description
B. The help message above sounds like a patch description.

If someone does not enable this kconfig option, what happens?
a. lru_gen files stay in debugfs
b. lru_gen files are not present
c. something else. If so, what?


-- 
~Randy
RE: [PATCH 2/3] mm/lru_gen: add configuration option to select debugfs/procfs for lru_gen
Posted by wangzicheng 2 months, 1 week ago
> On 11/27/25 6:53 PM, Zicheng Wang wrote:
> > Signed-off-by: Zicheng Wang <wangzicheng@honor.com>
> > ---
> >  mm/Kconfig | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/mm/Kconfig b/mm/Kconfig
> > index e443fe8cd..be7efa794 100644
> > --- a/mm/Kconfig
> > +++ b/mm/Kconfig
> > @@ -1325,6 +1325,16 @@ config LRU_GEN_STATS
> >  config LRU_GEN_WALKS_MMU
> >  	def_bool y
> >  	depends on LRU_GEN && ARCH_HAS_HW_PTE_YOUNG
> > +
> > +config LRU_GEN_PROCFS_CTRL
> > +	bool "Move lru_gen files from debugfs to procfs"
> > +	depends on LRU_GEN && PROC_FS
> > +	help
> > +	  Move lru_gen management from debugfs to procfs (/proc/lru_gen).
> > +	  This production-ready feature provides critical memory reclaim
> > +	  prediction and control. It is no longer experimental.
> > +	  The migration ensures availability in commercial products where
> > +	  debugfs may be disabled.
> 
> A. missing patch description
> B. The help message above sounds like a patch description.
> 

Thanks for the comments, will be fix in the next version.

> If someone does not enable this kconfig option, what happens?
> a. lru_gen files stay in debugfs
> b. lru_gen files are not present
> c. something else. If so, what?
> 
> 
> --
> ~Randy

Regard to the questions,
If this Kconfig option is enabled, the `lru_gen` and `lru_gen_full` files will appear under /proc/.
If it is not enabled, the files remain under debugfs, which is the current default behavior.

Thanks,
Zicheng