From: <xu.xin16@zte.com.cn>
To: <akpm@linux-foundation.org>, <mhocko@kernel.org>
Cc: <hannes@cmpxchg.org>, <roman.gushchin@linux.dev>,
<muchun.song@linux.dev>, <shakeel.butt@linux.dev>,
<cgroups@vger.kernel.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <yang.yang29@zte.com.cn>,
<chen.haonan2@zte.com.cn>, <wang.yaxin@zte.com.cn>
Subject: [PATCH linux-next 5/6] memcontrol-v1: add ksm_merging_pages in cgroup/memory.ksm_stat
Date: Thu, 3 Apr 2025 13:38:34 +0800 (CST) [thread overview]
Message-ID: <20250403133834135T-0RJg5_VxJfmzN3dG3bE@zte.com.cn> (raw)
In-Reply-To: <20250403132534636XLwK7CWiCj1J4-FENz0vk@zte.com.cn>
From: xu xin <xu.xin16@zte.com.cn>
Users can obtain ksm_merging_pages of a cgroup just by:
/ # cat /sys/fs/cgroup/memory.ksm_stat
ksm_rmap_items 76800
ksm_zero_pages 0
ksm_merging_pages 1092
Current implementation supports cgroup v1 temporarily; cgroup v2
compatibility is planned for future versions.
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
mm/memcontrol-v1.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c
index a6eea1deebff..b52f728af963 100644
--- a/mm/memcontrol-v1.c
+++ b/mm/memcontrol-v1.c
@@ -1826,6 +1826,7 @@ static int memcg_numa_stat_show(struct seq_file *m, void *v)
struct memcg_ksm_stat {
unsigned long ksm_rmap_items;
long ksm_zero_pages;
+ unsigned long ksm_merging_pages;
};
static int evaluate_memcg_ksm_stat(struct task_struct *task, void *arg)
@@ -1837,6 +1838,7 @@ static int evaluate_memcg_ksm_stat(struct task_struct *task, void *arg)
if (mm) {
ksm_stat->ksm_rmap_items += mm->ksm_rmap_items;
ksm_stat->ksm_zero_pages += mm_ksm_zero_pages(mm);
+ ksm_stat->ksm_merging_pages += mm->ksm_merging_pages;
mmput(mm);
}
@@ -1851,12 +1853,14 @@ static int memcg_ksm_stat_show(struct seq_file *m, void *v)
/* Initialization */
ksm_stat.ksm_rmap_items = 0;
ksm_stat.ksm_zero_pages = 0;
+ ksm_stat.ksm_merging_pages = 0;
/* summing all processes'ksm statistic items of this cgroup hierarchy */
mem_cgroup_scan_tasks(memcg, evaluate_memcg_ksm_stat, &ksm_stat);
seq_printf(m, "ksm_rmap_items %lu\n", ksm_stat.ksm_rmap_items);
seq_printf(m, "ksm_zero_pages %ld\n", ksm_stat.ksm_zero_pages);
+ seq_printf(m, "ksm_merging_pages %ld\n", ksm_stat.ksm_merging_pages);
return 0;
}
--
2.15.2
next prev parent reply other threads:[~2025-04-03 5:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 5:25 [PATCH linux-next 0/6] support ksm_stat showing at cgroup xu.xin16
2025-04-03 5:27 ` [PATCH linux-next 1/6] memcontrol: rename mem_cgroup_scan_tasks() xu.xin16
2025-04-03 5:30 ` [PATCH linux-next 2/6] memcontrol: introduce the new mem_cgroup_scan_tasks() xu.xin16
2025-04-03 5:31 ` [PATCH linux-next 3/6] memcontrol-v1: introduce ksm_stat at cgroup level xu.xin16
2025-04-03 5:37 ` [PATCH linux-next 4/6] memcontrol-v1: add ksm_zero_pages in cgroup/memory.ksm_stat xu.xin16
2025-04-03 5:38 ` xu.xin16 [this message]
2025-04-03 5:40 ` [PATCH linux-next 6/6] memcontrol-v1: add ksm_profit " xu.xin16
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=20250403133834135T-0RJg5_VxJfmzN3dG3bE@zte.com.cn \
--to=xu.xin16@zte.com.cn \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=chen.haonan2@zte.com.cn \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=wang.yaxin@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
/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