From: Xueyuan Chen <xueyuan.chen21@gmail.com>
To: "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Michal Hocko" <mhocko@kernel.org>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Muchun Song" <muchun.song@linux.dev>,
"Andrew Morton" <akpm@linux-foundation.org>
Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Xueyuan Chen <xueyuan.chen21@gmail.com>
Subject: [PATCH] mm/memcontrol: expose anon and file reclaim statistics in memory.stat
Date: Tue, 24 Nov 2026 15:51:27 +0800 [thread overview]
Message-ID: <20261124-memcg-reclain-stat-v1-1-c6cb14b0d917@gmail.com> (raw)
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
next reply other threads:[~2026-11-24 7:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 7:51 Xueyuan Chen [this message]
2026-11-26 8:30 ` Michal Hocko
2026-11-26 15:26 ` Shakeel Butt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124-memcg-reclain-stat-v1-1-c6cb14b0d917@gmail.com \
--to=xueyuan.chen21@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=hannes@cmpxchg.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=rdunlap@infradead.org \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=skhan@linuxfoundation.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®