linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: xu.xin.sc@gmail.com
To: xu.xin16@zte.com.cn
Cc: akpm@linux-foundation.org, david@redhat.com,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, wang.yaxin@zte.com.cn,
	yang.yang29@zte.com.cn
Subject: [PATCH v2 5/9] memcontrol: add ksm_merging_pages in cgroup/memory.ksm_stat
Date: Thu,  1 May 2025 04:15:14 +0000	[thread overview]
Message-ID: <20250501041514.3324403-1-xu.xin16@zte.com.cn> (raw)
In-Reply-To: <20250501120854885LyBCW0syCGojqnJ8crLVl@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

Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
 mm/memcontrol.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 509098093bbd..9569d32944e3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4393,6 +4393,7 @@ static int memory_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)
@@ -4404,6 +4405,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);
 	}
 
@@ -4418,11 +4420,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




  parent reply	other threads:[~2025-05-01  4:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01  4:08 [PATCH v2 0/9] support ksm_stat showing at cgroup level xu.xin16
2025-05-01  4:11 ` [PATCH v2 1/9] memcontrol: rename mem_cgroup_scan_tasks() xu.xin.sc
2025-05-01  4:13 ` [PATCH v2 2/9] memcontrol: introduce the new mem_cgroup_scan_tasks() xu.xin.sc
2025-05-01  4:14 ` [PATCH v2 3/9] memcontrol: introduce ksm_stat at memcg-v2 xu.xin.sc
2025-05-01  4:14 ` [PATCH v2 4/9] memcontrol: add ksm_zero_pages in cgroup/memory.ksm_stat xu.xin.sc
2025-05-01  4:15 ` xu.xin.sc [this message]
2025-05-01  4:15 ` [PATCH v2 6/9] memcontrol: add ksm_profit " xu.xin.sc
2025-05-01  4:16 ` [PATCH v2 7/9] memcontrol-v1: add ksm_stat at memcg-v1 xu.xin.sc
2025-05-01  4:17 ` [PATCH v2 8/9] Documentation: add ksm_stat description in cgroup-v1/memory.rst xu.xin.sc
2025-05-01  4:17 ` [PATCH v2 9/9] Documentation: add ksm_stat description in cgroup-v2.rst xu.xin.sc
2025-05-01 20:27 ` [PATCH v2 0/9] support ksm_stat showing at cgroup level Andrew Morton
2025-05-05 21:30 ` Shakeel Butt
2025-05-06  5:09   ` xu.xin16
2025-05-08 18:56     ` Shakeel Butt
2025-06-02 14:14       ` 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=20250501041514.3324403-1-xu.xin16@zte.com.cn \
    --to=xu.xin.sc@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=wang.yaxin@zte.com.cn \
    --cc=xu.xin16@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