Re: [PATCH linux-next v3 1/6] memcg: add per-memcg ksm_rmap_items stat
From: David Hildenbrand
Date: Tue Sep 23 2025 - 04:28:20 EST
+
+/* Show the ksm statistic count at memory.stat under cgroup mountpoint */
+void memcg_stat_ksm_show(struct mem_cgroup *memcg, struct seq_buf *s)
+{
+ struct memcg_ksm_stat ksm_stat;
+
+ if (mem_cgroup_is_root(memcg)) {
+ /* Just use the global counters when root memcg */
+ ksm_stat.ksm_rmap_items = ksm_rmap_items;
+ } else {
+ /* Initialization */
+ ksm_stat.ksm_rmap_items = 0;
+ /* Summing all processes'ksm statistic items */
+ mem_cgroup_scan_tasks(memcg, evaluate_memcg_ksm_stat, &ksm_stat);
What happens here if you have to tasks that share the same MM? (CLONE_VM without CLONE_THREAD)?
Wouldn't we end up counting the same MM multiple times?
--
Cheers
David / dhildenb