All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/memcontrol: expose anon and file reclaim statistics in memory.stat
@ 2026-11-24  7:51 Xueyuan Chen
  2026-11-26  8:30 ` Michal Hocko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xueyuan Chen @ 2026-11-24  7:51 UTC (permalink / raw)
  To: Tejun Heo, Johannes Weiner, Michal Koutný, Jonathan Corbet,
	Shuah Khan, Randy Dunlap, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song, Andrew Morton
  Cc: cgroups, linux-doc, linux-kernel, linux-mm, Xueyuan Chen

The aggregate reclaim counters in memory.stat do not show how reclaim
is split between the anonymous and file LRUs of a cgroup.

Expose the existing per-memcg scan and steal counters by LRU type so
userspace can measure reclaim balance and efficiency when evaluating
reclaim policy. Report the same counters per node in memory.numa_stat.
Both files report the counters in base pages.

Signed-off-by: Xueyuan Chen <xueyuan.chen21@gmail.com>
---
 Documentation/admin-guide/cgroup-v2.rst | 20 ++++++++++++++++++--
 mm/memcontrol.c                         |  8 ++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 9e3c67b02ae2..eeeaf635754c 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -1726,6 +1726,22 @@ The following nested keys are defined.
 	  pgsteal_proactive (npn)
 		Amount of reclaimed pages proactively
 
+	  pgscan_anon
+		Number of base pages scanned for reclaim from the anonymous
+		LRU. With the multi-gen LRU, counts pages isolated for reclaim.
+
+	  pgscan_file
+		Number of base pages scanned for reclaim from the file LRU.
+		With the multi-gen LRU, counts pages isolated for reclaim.
+
+	  pgsteal_anon
+		Number of base pages reclaimed from the anonymous LRU,
+		including pages demoted to another node.
+
+	  pgsteal_file
+		Number of base pages reclaimed from the file LRU,
+		including pages demoted to another node.
+
 	  pgfault (npn)
 		Total number of page faults incurred
 
@@ -1829,11 +1845,11 @@ The following nested keys are defined.
 	application performance by combining this information with the
 	application's CPU allocation.
 
-	All memory amounts are in bytes.
+	All memory amounts are in bytes. Reclaim counters are in base pages.
 
 	The output format of memory.numa_stat is::
 
-	  type N0=<bytes in node 0> N1=<bytes in node 1> ...
+	  type N0=<value for node 0> N1=<value for node 1> ...
 
 	The entries are ordered to be human readable, and new entries
 	can show up in the middle. Don't rely on items remaining in a
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1ebc9330aeae..ac12ff69a633 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1647,10 +1647,14 @@ static const struct memory_stat memory_stats[] = {
 	{ "pgsteal_direct",		PGSTEAL_DIRECT		},
 	{ "pgsteal_khugepaged",		PGSTEAL_KHUGEPAGED	},
 	{ "pgsteal_proactive",		PGSTEAL_PROACTIVE	},
+	{ "pgsteal_anon",		PGSTEAL_ANON		},
+	{ "pgsteal_file",		PGSTEAL_FILE		},
 	{ "pgscan_kswapd",		PGSCAN_KSWAPD		},
 	{ "pgscan_direct",		PGSCAN_DIRECT		},
 	{ "pgscan_khugepaged",		PGSCAN_KHUGEPAGED	},
 	{ "pgscan_proactive",		PGSCAN_PROACTIVE	},
+	{ "pgscan_anon",		PGSCAN_ANON		},
+	{ "pgscan_file",		PGSCAN_FILE		},
 	{ "pgrefill",			PGREFILL		},
 #ifdef CONFIG_NUMA_BALANCING
 	{ "pgpromote_success",		PGPROMOTE_SUCCESS	},
@@ -1699,10 +1703,14 @@ static int memcg_page_state_output_unit(int item)
 	case PGSTEAL_DIRECT:
 	case PGSTEAL_KHUGEPAGED:
 	case PGSTEAL_PROACTIVE:
+	case PGSTEAL_ANON:
+	case PGSTEAL_FILE:
 	case PGSCAN_KSWAPD:
 	case PGSCAN_DIRECT:
 	case PGSCAN_KHUGEPAGED:
 	case PGSCAN_PROACTIVE:
+	case PGSCAN_ANON:
+	case PGSCAN_FILE:
 	case PGREFILL:
 #ifdef CONFIG_NUMA_BALANCING
 	case PGPROMOTE_SUCCESS:

---
base-commit: b024a51b0184b1efb6f55b11aaf7b15a490a6307

--  
Best regards,
Xueyuan


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/memcontrol: expose anon and file reclaim statistics in memory.stat
  2026-11-24  7:51 [PATCH] mm/memcontrol: expose anon and file reclaim statistics in memory.stat Xueyuan Chen
@ 2026-11-26  8:30 ` Michal Hocko
  2026-11-26 15:26 ` Shakeel Butt
  2026-11-27  1:31 ` + mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat.patch added to mm-new branch Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2026-11-26  8:30 UTC (permalink / raw)
  To: Xueyuan Chen
  Cc: Tejun Heo, Johannes Weiner, Michal Koutný, Jonathan Corbet,
	Shuah Khan, Randy Dunlap, Roman Gushchin, Shakeel Butt,
	Muchun Song, Andrew Morton, cgroups, linux-doc, linux-kernel,
	linux-mm

On Tue 24-11-26 15:51:27, Xueyuan Chen wrote:
> The aggregate reclaim counters in memory.stat do not show how reclaim
> is split between the anonymous and file LRUs of a cgroup.
> 
> Expose the existing per-memcg scan and steal counters by LRU type so
> userspace can measure reclaim balance and efficiency when evaluating
> reclaim policy. Report the same counters per node in memory.numa_stat.
> Both files report the counters in base pages.

We have found these stats quite useful when debugging issues at the
global level many times. So I think this is a useful addition to memcg
stats as well. Especially when we already collect the data so this is
purely a change to show the already available information.

> Signed-off-by: Xueyuan Chen <xueyuan.chen21@gmail.com>

Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!

> ---
>  Documentation/admin-guide/cgroup-v2.rst | 20 ++++++++++++++++++--
>  mm/memcontrol.c                         |  8 ++++++++
>  2 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
> index 9e3c67b02ae2..eeeaf635754c 100644
> --- a/Documentation/admin-guide/cgroup-v2.rst
> +++ b/Documentation/admin-guide/cgroup-v2.rst
> @@ -1726,6 +1726,22 @@ The following nested keys are defined.
>  	  pgsteal_proactive (npn)
>  		Amount of reclaimed pages proactively
>  
> +	  pgscan_anon
> +		Number of base pages scanned for reclaim from the anonymous
> +		LRU. With the multi-gen LRU, counts pages isolated for reclaim.
> +
> +	  pgscan_file
> +		Number of base pages scanned for reclaim from the file LRU.
> +		With the multi-gen LRU, counts pages isolated for reclaim.
> +
> +	  pgsteal_anon
> +		Number of base pages reclaimed from the anonymous LRU,
> +		including pages demoted to another node.
> +
> +	  pgsteal_file
> +		Number of base pages reclaimed from the file LRU,
> +		including pages demoted to another node.
> +
>  	  pgfault (npn)
>  		Total number of page faults incurred
>  
> @@ -1829,11 +1845,11 @@ The following nested keys are defined.
>  	application performance by combining this information with the
>  	application's CPU allocation.
>  
> -	All memory amounts are in bytes.
> +	All memory amounts are in bytes. Reclaim counters are in base pages.
>  
>  	The output format of memory.numa_stat is::
>  
> -	  type N0=<bytes in node 0> N1=<bytes in node 1> ...
> +	  type N0=<value for node 0> N1=<value for node 1> ...
>  
>  	The entries are ordered to be human readable, and new entries
>  	can show up in the middle. Don't rely on items remaining in a
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 1ebc9330aeae..ac12ff69a633 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1647,10 +1647,14 @@ static const struct memory_stat memory_stats[] = {
>  	{ "pgsteal_direct",		PGSTEAL_DIRECT		},
>  	{ "pgsteal_khugepaged",		PGSTEAL_KHUGEPAGED	},
>  	{ "pgsteal_proactive",		PGSTEAL_PROACTIVE	},
> +	{ "pgsteal_anon",		PGSTEAL_ANON		},
> +	{ "pgsteal_file",		PGSTEAL_FILE		},
>  	{ "pgscan_kswapd",		PGSCAN_KSWAPD		},
>  	{ "pgscan_direct",		PGSCAN_DIRECT		},
>  	{ "pgscan_khugepaged",		PGSCAN_KHUGEPAGED	},
>  	{ "pgscan_proactive",		PGSCAN_PROACTIVE	},
> +	{ "pgscan_anon",		PGSCAN_ANON		},
> +	{ "pgscan_file",		PGSCAN_FILE		},
>  	{ "pgrefill",			PGREFILL		},
>  #ifdef CONFIG_NUMA_BALANCING
>  	{ "pgpromote_success",		PGPROMOTE_SUCCESS	},
> @@ -1699,10 +1703,14 @@ static int memcg_page_state_output_unit(int item)
>  	case PGSTEAL_DIRECT:
>  	case PGSTEAL_KHUGEPAGED:
>  	case PGSTEAL_PROACTIVE:
> +	case PGSTEAL_ANON:
> +	case PGSTEAL_FILE:
>  	case PGSCAN_KSWAPD:
>  	case PGSCAN_DIRECT:
>  	case PGSCAN_KHUGEPAGED:
>  	case PGSCAN_PROACTIVE:
> +	case PGSCAN_ANON:
> +	case PGSCAN_FILE:
>  	case PGREFILL:
>  #ifdef CONFIG_NUMA_BALANCING
>  	case PGPROMOTE_SUCCESS:
> 
> ---
> base-commit: b024a51b0184b1efb6f55b11aaf7b15a490a6307
> 
> --  
> Best regards,
> Xueyuan
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/memcontrol: expose anon and file reclaim statistics in memory.stat
  2026-11-24  7:51 [PATCH] mm/memcontrol: expose anon and file reclaim statistics in memory.stat Xueyuan Chen
  2026-11-26  8:30 ` Michal Hocko
@ 2026-11-26 15:26 ` Shakeel Butt
  2026-11-27  1:31 ` + mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat.patch added to mm-new branch Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Shakeel Butt @ 2026-11-26 15:26 UTC (permalink / raw)
  To: Xueyuan Chen
  Cc: Tejun Heo, Johannes Weiner, Michal Koutný, Jonathan Corbet,
	Shuah Khan, Randy Dunlap, Michal Hocko, Roman Gushchin,
	Muchun Song, Andrew Morton, cgroups, linux-doc, linux-kernel,
	linux-mm

On Tue, Nov 24, 2026 at 03:51:27PM +0800, Xueyuan Chen wrote:
> The aggregate reclaim counters in memory.stat do not show how reclaim
> is split between the anonymous and file LRUs of a cgroup.
> 
> Expose the existing per-memcg scan and steal counters by LRU type so
> userspace can measure reclaim balance and efficiency when evaluating
> reclaim policy. Report the same counters per node in memory.numa_stat.
> Both files report the counters in base pages.
> 
> Signed-off-by: Xueyuan Chen <xueyuan.chen21@gmail.com>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* + mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat.patch added to mm-new branch
  2026-11-24  7:51 [PATCH] mm/memcontrol: expose anon and file reclaim statistics in memory.stat Xueyuan Chen
  2026-11-26  8:30 ` Michal Hocko
  2026-11-26 15:26 ` Shakeel Butt
@ 2026-11-27  1:31 ` Andrew Morton
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2026-11-27  1:31 UTC (permalink / raw)
  To: mm-commits, tj, skhan, shakeel.butt, roman.gushchin, rdunlap,
	muchun.song, mkoutny, mhocko, mhocko, hannes, corbet,
	xueyuan.chen21, akpm

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5751 bytes --]


The patch titled
     Subject: mm/memcontrol: expose anon and file reclaim statistics in memory.stat
has been added to the -mm mm-new branch.  Its filename is
     mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat.patch

This patch will later appear in the mm-new branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews.  Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.

The mm-new branch of mm.git is not included in linux-next

If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Xueyuan Chen <xueyuan.chen21@gmail.com>
Subject: mm/memcontrol: expose anon and file reclaim statistics in memory.stat
Date: Tue, 24 Nov 2026 15:51:27 +0800

The aggregate reclaim counters in memory.stat do not show how reclaim is
split between the anonymous and file LRUs of a cgroup.

Expose the existing per-memcg scan and steal counters by LRU type so
userspace can measure reclaim balance and efficiency when evaluating
reclaim policy.  Report the same counters per node in memory.numa_stat. 
Both files report the counters in base pages.

Link: https://patch.msgid.link/20261124-memcg-reclain-stat-v1-1-c6cb14b0d917@gmail.com
Signed-off-by: Xueyuan Chen <xueyuan.chen21@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Muchun Song <muchun.song@linux.dev>

 Documentation/admin-guide/cgroup-v2.rst |   20 ++++++++++++++++++--
 mm/memcontrol.c                         |    8 ++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

--- a/Documentation/admin-guide/cgroup-v2.rst~mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat
+++ a/Documentation/admin-guide/cgroup-v2.rst
@@ -1726,6 +1726,22 @@ The following nested keys are defined.
 	  pgsteal_proactive (npn)
 		Amount of reclaimed pages proactively
 
+	  pgscan_anon
+		Number of base pages scanned for reclaim from the anonymous
+		LRU. With the multi-gen LRU, counts pages isolated for reclaim.
+
+	  pgscan_file
+		Number of base pages scanned for reclaim from the file LRU.
+		With the multi-gen LRU, counts pages isolated for reclaim.
+
+	  pgsteal_anon
+		Number of base pages reclaimed from the anonymous LRU,
+		including pages demoted to another node.
+
+	  pgsteal_file
+		Number of base pages reclaimed from the file LRU,
+		including pages demoted to another node.
+
 	  pgfault (npn)
 		Total number of page faults incurred
 
@@ -1829,11 +1845,11 @@ The following nested keys are defined.
 	application performance by combining this information with the
 	application's CPU allocation.
 
-	All memory amounts are in bytes.
+	All memory amounts are in bytes. Reclaim counters are in base pages.
 
 	The output format of memory.numa_stat is::
 
-	  type N0=<bytes in node 0> N1=<bytes in node 1> ...
+	  type N0=<value for node 0> N1=<value for node 1> ...
 
 	The entries are ordered to be human readable, and new entries
 	can show up in the middle. Don't rely on items remaining in a
--- a/mm/memcontrol.c~mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat
+++ a/mm/memcontrol.c
@@ -1668,10 +1668,14 @@ static const struct memory_stat memory_s
 	{ "pgsteal_direct",		PGSTEAL_DIRECT		},
 	{ "pgsteal_khugepaged",		PGSTEAL_KHUGEPAGED	},
 	{ "pgsteal_proactive",		PGSTEAL_PROACTIVE	},
+	{ "pgsteal_anon",		PGSTEAL_ANON		},
+	{ "pgsteal_file",		PGSTEAL_FILE		},
 	{ "pgscan_kswapd",		PGSCAN_KSWAPD		},
 	{ "pgscan_direct",		PGSCAN_DIRECT		},
 	{ "pgscan_khugepaged",		PGSCAN_KHUGEPAGED	},
 	{ "pgscan_proactive",		PGSCAN_PROACTIVE	},
+	{ "pgscan_anon",		PGSCAN_ANON		},
+	{ "pgscan_file",		PGSCAN_FILE		},
 	{ "pgrefill",			PGREFILL		},
 #ifdef CONFIG_NUMA_BALANCING
 	{ "pgpromote_success",		PGPROMOTE_SUCCESS	},
@@ -1720,10 +1724,14 @@ static int memcg_page_state_output_unit(
 	case PGSTEAL_DIRECT:
 	case PGSTEAL_KHUGEPAGED:
 	case PGSTEAL_PROACTIVE:
+	case PGSTEAL_ANON:
+	case PGSTEAL_FILE:
 	case PGSCAN_KSWAPD:
 	case PGSCAN_DIRECT:
 	case PGSCAN_KHUGEPAGED:
 	case PGSCAN_PROACTIVE:
+	case PGSCAN_ANON:
+	case PGSCAN_FILE:
 	case PGREFILL:
 #ifdef CONFIG_NUMA_BALANCING
 	case PGPROMOTE_SUCCESS:
_

Patches currently in -mm which might be from xueyuan.chen21@gmail.com are

mm-zsmalloc-remove-config_zsmalloc_stat.patch
mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat.patch


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-27  1:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  7:51 [PATCH] mm/memcontrol: expose anon and file reclaim statistics in memory.stat Xueyuan Chen
2026-11-26  8:30 ` Michal Hocko
2026-11-26 15:26 ` Shakeel Butt
2026-11-27  1:31 ` + mm-memcontrol-expose-anon-and-file-reclaim-statistics-in-memorystat.patch added to mm-new branch Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.