* [PATCH v2 0/5] memcg: Support per-memcg KSM metrics
@ 2025-09-14 10:00 xu.xin16
2025-09-14 10:03 ` [PATCH v2 1/5] memcg: add per-memcg ksm_rmap_items stat xu.xin16
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: xu.xin16 @ 2025-09-14 10:00 UTC (permalink / raw)
To: akpm, shakeel.butt, hannes, mhocko, roman.gushchin
Cc: david, chengming.zhou, xu.xin16, muchun.song, linux-kernel,
linux-mm, cgroups
From: xu xin <xu.xin16@zte.com.cn>
Dear all,
This is the v2 of patchset, as Shakeel suggested:
https://lore.kernel.org/all/ir2s6sqi6hrbz7ghmfngbif6fbgmswhqdljlntesurfl2xvmmv@yp3w2lqyipb5/
With the enablement of container-level KSM (e.g., via prctl [1]), there is
a growing demand for container-level observability of KSM behavior. However,
current cgroup implementations lack support for exposing KSM-related metrics.
So add the counter in the existing memory.stat without adding a new interface.
To diaplay per-memcg KSM statistic counters, we traverse all processes of a
memcg and summing the processes' ksm_rmap_items counters instead of adding enum
item in memcg_stat_item or node_stat_item and updating the corresponding enum
counter when ksmd manipulate pages.
Now Linux users can look up all per-memcg KSM counters by:
# cat /sys/fs/cgroup/xuxin/memory.stat | grep ksm
ksm_rmap_items 0
ksm_zero_pages 0
ksm_merging_pages 0
ksm_profit 0
Q&A
====
why don't I add enum item in memcg_stat_item or node_stat_item like
other items in memory.stat ?
I tried the way of adding enum item in memcg_stat_item and updating them when
ksmd manipulate pages, but it failed with error statistic ksm counters of
memcg. This is because of the following reasons:
1) The KSM counter of memcgroup can be correctly incremented, but cannot be
properly decremented. E,g,, when ksmd scans pages of a process, it can use
the mm_struct of the struct ksm_rmap_item to reverse-lookup the memcg
and then increase the value via mod_memcg_state(memcg, MEMCG_KSM_COUNT, 1).
However, when the process exits abruptly, since ksmd asynchronously scans
the mmslot list in the background, it is no longer able to correctly locate
the original memcg through mm_struct by get_mem_cgroup_from_mm(), as the
task_struct has already been freed.
2) The first issue could potentially be addressed by adding a memcg
pointer directly into the ksm_rmap_item structure. However, this
increases memory overhead, especially when there are a large
number of ksm_rmap_items in the system (due to a high volume of
pages being scanned by ksmd). Moreover, this approach does not
resolve the same problem for ksm_zero_pages, because updates to
ksm_zero_pages are not performed through ksm_rmap_item, but
rather directly during unmap or page table entry (pte) faults
based on the mm_struct. At that point, if the process has
already exited, the corresponding memcg can no longer be
accurately identified.
xu xin (5):
memcg: add per-memcg ksm_rmap_items stat
memcg: show ksm_zero_pages count in memory.stat
memcg: show ksm_merging_pages in memory.stat
memcg: add per-memcg ksm_profit
Documentation: add KSM statistic counters description in cgroup-v2.rst
Documentation/admin-guide/cgroup-v2.rst | 17 +++++++
include/linux/ksm.h | 1 +
mm/ksm.c | 67 ++++++++++++++++++++++---
mm/memcontrol.c | 5 ++
4 files changed, 84 insertions(+), 6 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/5] memcg: add per-memcg ksm_rmap_items stat
2025-09-14 10:00 [PATCH v2 0/5] memcg: Support per-memcg KSM metrics xu.xin16
@ 2025-09-14 10:03 ` xu.xin16
2025-09-14 13:54 ` kernel test robot
2025-09-14 10:05 ` [PATCH v2 2/5] memcg: show ksm_zero_pages count in memory.stat xu.xin16
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: xu.xin16 @ 2025-09-14 10:03 UTC (permalink / raw)
To: akpm
Cc: shakeel.butt, hannes, mhocko, roman.gushchin, david,
chengming.zhou, muchun.song, linux-kernel, linux-mm, cgroups,
xu.xin16
From: xu xin <xu.xin16@zte.com.cn>
With the enablement of container-level KSM (e.g., via prctl), there is
a growing demand for container-level observability of KSM behavior.
The value of "ksm_rmap_items" indicates the total allocated ksm
rmap_items of this memcg, which could be used to determine how
unbeneficial the ksm-policy (like madvise), they are using brings,
since the bigger the ratio of ksm_rmap_items over ksm_merging_pages,
the more unbeneficial the ksm bring.
Add the counter in the existing memory.stat without adding a new interface.
We traverse all processes of a memcg and summing the processes'
ksm_rmap_items counters instead of adding enum item in memcg_stat_item
or node_stat_item and updating the corresponding enum counter when
ksmd manipulate pages.
Finally, we can look up ksm_rmap_items of per-memcg simply by:
cat /sys/fs/cgroup/memory.stat | grep ksm_rmap_items
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
include/linux/ksm.h | 1 +
mm/ksm.c | 38 ++++++++++++++++++++++++++++++++++++++
mm/memcontrol.c | 5 +++++
3 files changed, 44 insertions(+)
diff --git a/include/linux/ksm.h b/include/linux/ksm.h
index 22e67ca7cba3..a41ed503f152 100644
--- a/include/linux/ksm.h
+++ b/include/linux/ksm.h
@@ -94,6 +94,7 @@ void collect_procs_ksm(const struct folio *folio, const struct page *page,
struct list_head *to_kill, int force_early);
long ksm_process_profit(struct mm_struct *);
bool ksm_process_mergeable(struct mm_struct *mm);
+void memcg_stat_ksm_show(struct mem_cgroup *memcg, struct seq_buf *s);
#else /* !CONFIG_KSM */
diff --git a/mm/ksm.c b/mm/ksm.c
index 2ef29802a49b..b533f0edaf96 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -3308,6 +3308,44 @@ long ksm_process_profit(struct mm_struct *mm)
}
#endif /* CONFIG_PROC_FS */
+#ifdef CONFIG_MEMCG
+struct memcg_ksm_stat {
+ unsigned long ksm_rmap_items;
+};
+
+static int evaluate_memcg_ksm_stat(struct task_struct *task, void *arg)
+{
+ struct mm_struct *mm;
+ struct memcg_ksm_stat *ksm_stat = arg;
+
+ mm = get_task_mm(task);
+ if (mm) {
+ ksm_stat->ksm_rmap_items += mm->ksm_rmap_items;
+ mmput(mm);
+ }
+
+ return 0;
+}
+
+/* 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);
+ }
+ /* Print memcg ksm statistic items */
+ seq_buf_printf(s, "ksm_rmap_items %lu\n", ksm_stat.ksm_rmap_items);
+}
+#endif
+
#ifdef CONFIG_SYSFS
/*
* This all compiles without CONFIG_SYSFS, but is a waste of space.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 257d2c76b730..9595b132c6c3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -63,6 +63,7 @@
#include <linux/seq_buf.h>
#include <linux/sched/isolation.h>
#include <linux/kmemleak.h>
+#include <linux/ksm.h>
#include "internal.h"
#include <net/sock.h>
#include <net/ip.h>
@@ -1492,6 +1493,10 @@ static void memcg_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
}
}
+#ifdef CONFIG_KSM
+ memcg_stat_ksm_show(memcg, s);
+#endif
+
/* Accumulated memory events */
seq_buf_printf(s, "pgscan %lu\n",
memcg_events(memcg, PGSCAN_KSWAPD) +
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/5] memcg: show ksm_zero_pages count in memory.stat
2025-09-14 10:00 [PATCH v2 0/5] memcg: Support per-memcg KSM metrics xu.xin16
2025-09-14 10:03 ` [PATCH v2 1/5] memcg: add per-memcg ksm_rmap_items stat xu.xin16
@ 2025-09-14 10:05 ` xu.xin16
2025-09-14 10:06 ` [PATCH v2 3/5] memcg: show ksm_merging_pages " xu.xin16
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: xu.xin16 @ 2025-09-14 10:05 UTC (permalink / raw)
To: akpm
Cc: akpm, shakeel.butt, hannes, mhocko, roman.gushchin, david,
chengming.zhou, muchun.song, linux-kernel, linux-mm, cgroups,
xu.xin16
From: xu xin <xu.xin16@zte.com.cn>
Users can obtain ksm_zero_pages of a cgroup just by:
'cat /sys/fs/cgroup/memory.stat | grep ksm_zero_pages
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
mm/ksm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mm/ksm.c b/mm/ksm.c
index b533f0edaf96..5832159214f8 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -3311,6 +3311,7 @@ long ksm_process_profit(struct mm_struct *mm)
#ifdef CONFIG_MEMCG
struct memcg_ksm_stat {
unsigned long ksm_rmap_items;
+ long ksm_zero_pages;
};
static int evaluate_memcg_ksm_stat(struct task_struct *task, void *arg)
@@ -3321,6 +3322,7 @@ static int evaluate_memcg_ksm_stat(struct task_struct *task, void *arg)
mm = get_task_mm(task);
if (mm) {
ksm_stat->ksm_rmap_items += mm->ksm_rmap_items;
+ ksm_stat->ksm_zero_pages += mm_ksm_zero_pages(mm);
mmput(mm);
}
@@ -3335,14 +3337,17 @@ void memcg_stat_ksm_show(struct mem_cgroup *memcg, struct seq_buf *s)
if (mem_cgroup_is_root(memcg)) {
/* Just use the global counters when root memcg */
ksm_stat.ksm_rmap_items = ksm_rmap_items;
+ ksm_stat.ksm_zero_pages = atomic_long_read(&ksm_zero_pages);
} else {
/* Initialization */
ksm_stat.ksm_rmap_items = 0;
+ ksm_stat.ksm_zero_pages = 0;
/* Summing all processes'ksm statistic items */
mem_cgroup_scan_tasks(memcg, evaluate_memcg_ksm_stat, &ksm_stat);
}
/* Print memcg ksm statistic items */
seq_buf_printf(s, "ksm_rmap_items %lu\n", ksm_stat.ksm_rmap_items);
+ seq_buf_printf(s, "ksm_zero_pages %lu\n", ksm_stat.ksm_zero_pages);
}
#endif
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/5] memcg: show ksm_merging_pages in memory.stat
2025-09-14 10:00 [PATCH v2 0/5] memcg: Support per-memcg KSM metrics xu.xin16
2025-09-14 10:03 ` [PATCH v2 1/5] memcg: add per-memcg ksm_rmap_items stat xu.xin16
2025-09-14 10:05 ` [PATCH v2 2/5] memcg: show ksm_zero_pages count in memory.stat xu.xin16
@ 2025-09-14 10:06 ` xu.xin16
2025-09-14 10:07 ` [PATCH v2 4/5] memcg: add per-memcg ksm_profit xu.xin16
2025-09-14 10:09 ` [PATCH v2 5/5] Documentation: add KSM statistic counters description in cgroup-v2.rst xu.xin16
4 siblings, 0 replies; 8+ messages in thread
From: xu.xin16 @ 2025-09-14 10:06 UTC (permalink / raw)
To: akpm
Cc: akpm, shakeel.butt, hannes, mhocko, roman.gushchin, david,
chengming.zhou, muchun.song, linux-kernel, linux-mm, cgroups,
xu.xin16
From: xu xin <xu.xin16@zte.com.cn>
Users can obtain ksm_merging_pages of a cgroup just by:
'cat /sys/fs/cgroup/memory.stat | grep ksm_merging_pages
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
mm/ksm.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/ksm.c b/mm/ksm.c
index 5832159214f8..4cc47ad1e887 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -3312,6 +3312,7 @@ long ksm_process_profit(struct mm_struct *mm)
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)
@@ -3323,6 +3324,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);
}
@@ -3338,16 +3340,20 @@ void memcg_stat_ksm_show(struct mem_cgroup *memcg, struct seq_buf *s)
/* Just use the global counters when root memcg */
ksm_stat.ksm_rmap_items = ksm_rmap_items;
ksm_stat.ksm_zero_pages = atomic_long_read(&ksm_zero_pages);
+ ksm_stat.ksm_merging_pages = ksm_pages_shared +
+ ksm_pages_sharing;
} else {
/* 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 */
mem_cgroup_scan_tasks(memcg, evaluate_memcg_ksm_stat, &ksm_stat);
}
/* Print memcg ksm statistic items */
seq_buf_printf(s, "ksm_rmap_items %lu\n", ksm_stat.ksm_rmap_items);
seq_buf_printf(s, "ksm_zero_pages %lu\n", ksm_stat.ksm_zero_pages);
+ seq_buf_printf(s, "ksm_merging_pages %lu\n", ksm_stat.ksm_merging_pages);
}
#endif
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/5] memcg: add per-memcg ksm_profit
2025-09-14 10:00 [PATCH v2 0/5] memcg: Support per-memcg KSM metrics xu.xin16
` (2 preceding siblings ...)
2025-09-14 10:06 ` [PATCH v2 3/5] memcg: show ksm_merging_pages " xu.xin16
@ 2025-09-14 10:07 ` xu.xin16
2025-09-14 13:02 ` kernel test robot
2025-09-14 10:09 ` [PATCH v2 5/5] Documentation: add KSM statistic counters description in cgroup-v2.rst xu.xin16
4 siblings, 1 reply; 8+ messages in thread
From: xu.xin16 @ 2025-09-14 10:07 UTC (permalink / raw)
To: akpm
Cc: shakeel.butt, hannes, mhocko, roman.gushchin, david,
chengming.zhou, muchun.song, linux-kernel, linux-mm, cgroups,
xu.xin16
From: xu xin <xu.xin16@zte.com.cn>
Users can obtain ksm_profit of a cgroup just by:
'cat /sys/fs/cgroup/memory.stat | grep ksm_profit
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
mm/ksm.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/mm/ksm.c b/mm/ksm.c
index 4cc47ad1e887..c01567a3d5ca 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -3308,11 +3308,18 @@ long ksm_process_profit(struct mm_struct *mm)
}
#endif /* CONFIG_PROC_FS */
+static inline long ksm_general_profit(void)
+{
+ return (ksm_pages_sharing + atomic_long_read(&ksm_zero_pages)) * PAGE_SIZE -
+ ksm_rmap_items * sizeof(struct ksm_rmap_item);
+}
+
#ifdef CONFIG_MEMCG
struct memcg_ksm_stat {
unsigned long ksm_rmap_items;
long ksm_zero_pages;
unsigned long ksm_merging_pages;
+ long ksm_profit;
};
static int evaluate_memcg_ksm_stat(struct task_struct *task, void *arg)
@@ -3325,6 +3332,7 @@ static int evaluate_memcg_ksm_stat(struct task_struct *task, void *arg)
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;
+ ksm_stat->ksm_profit += ksm_process_profit(mm);
mmput(mm);
}
@@ -3342,11 +3350,13 @@ void memcg_stat_ksm_show(struct mem_cgroup *memcg, struct seq_buf *s)
ksm_stat.ksm_zero_pages = atomic_long_read(&ksm_zero_pages);
ksm_stat.ksm_merging_pages = ksm_pages_shared +
ksm_pages_sharing;
+ ksm_stat.ksm_profit = ksm_general_profit();
} else {
/* Initialization */
ksm_stat.ksm_rmap_items = 0;
ksm_stat.ksm_zero_pages = 0;
ksm_stat.ksm_merging_pages = 0;
+ ksm_stat.ksm_profit = 0;
/* Summing all processes'ksm statistic items */
mem_cgroup_scan_tasks(memcg, evaluate_memcg_ksm_stat, &ksm_stat);
}
@@ -3354,6 +3364,7 @@ void memcg_stat_ksm_show(struct mem_cgroup *memcg, struct seq_buf *s)
seq_buf_printf(s, "ksm_rmap_items %lu\n", ksm_stat.ksm_rmap_items);
seq_buf_printf(s, "ksm_zero_pages %lu\n", ksm_stat.ksm_zero_pages);
seq_buf_printf(s, "ksm_merging_pages %lu\n", ksm_stat.ksm_merging_pages);
+ seq_buf_printf(s, "ksm_profit %lu\n", ksm_stat.ksm_profit);
}
#endif
@@ -3648,12 +3659,7 @@ KSM_ATTR_RO(ksm_zero_pages);
static ssize_t general_profit_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
- long general_profit;
-
- general_profit = (ksm_pages_sharing + atomic_long_read(&ksm_zero_pages)) * PAGE_SIZE -
- ksm_rmap_items * sizeof(struct ksm_rmap_item);
-
- return sysfs_emit(buf, "%ld\n", general_profit);
+ return sysfs_emit(buf, "%ld\n", ksm_general_profit());
}
KSM_ATTR_RO(general_profit);
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 5/5] Documentation: add KSM statistic counters description in cgroup-v2.rst
2025-09-14 10:00 [PATCH v2 0/5] memcg: Support per-memcg KSM metrics xu.xin16
` (3 preceding siblings ...)
2025-09-14 10:07 ` [PATCH v2 4/5] memcg: add per-memcg ksm_profit xu.xin16
@ 2025-09-14 10:09 ` xu.xin16
4 siblings, 0 replies; 8+ messages in thread
From: xu.xin16 @ 2025-09-14 10:09 UTC (permalink / raw)
To: akpm
Cc: akpm, shakeel.butt, hannes, mhocko, roman.gushchin, david,
chengming.zhou, muchun.song, linux-kernel, linux-mm, cgroups,
xu.xin16
From: xu xin <xu.xin16@zte.com.cn>
This add KSM-related statistic counters description in cgroup-v2.rst,
including "ksm_rmap_items", "ksm_zero_pages", "ksm_merging_pages" and
"ksm_profit".
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
Documentation/admin-guide/cgroup-v2.rst | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index a1e3d431974c..c8c4faa4e3fd 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -1776,6 +1776,23 @@ The following nested keys are defined.
up if hugetlb usage is accounted for in memory.current (i.e.
cgroup is mounted with the memory_hugetlb_accounting option).
+ ksm_rmap_items
+ Number of ksm_rmap_item structures in use. The structure
+ ksm_rmap_item stores the reverse mapping information for virtual
+ addresses. KSM will generate a ksm_rmap_item for each
+ ksm-scanned page of the process.
+
+ ksm_zero_pages
+ Number of empty pages are merged with kernel zero pages by KSM,
+ which is only useful when /sys/kernel/mm/ksm/use_zero_pages.
+
+ ksm_merging_pages
+ Number of pages of this process are involved in KSM merging
+ (not including ksm_zero_pages).
+
+ ksm_profit
+ Amount of profitable memory that KSM brings (Saved bytes).
+
memory.numa_stat
A read-only nested-keyed file which exists on non-root cgroups.
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 4/5] memcg: add per-memcg ksm_profit
2025-09-14 10:07 ` [PATCH v2 4/5] memcg: add per-memcg ksm_profit xu.xin16
@ 2025-09-14 13:02 ` kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-09-14 13:02 UTC (permalink / raw)
To: xu.xin16, akpm
Cc: llvm, oe-kbuild-all, shakeel.butt, hannes, mhocko, roman.gushchin,
david, chengming.zhou, muchun.song, linux-kernel, linux-mm,
cgroups, xu.xin16
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on tj-cgroup/for-next linus/master v6.17-rc5 next-20250912]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/xu-xin16-zte-com-cn/memcg-add-per-memcg-ksm_rmap_items-stat/20250914-181132
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20250914180750448qMRz3iTon78DoExPyZusD%40zte.com.cn
patch subject: [PATCH v2 4/5] memcg: add per-memcg ksm_profit
config: um-randconfig-001-20250914 (https://download.01.org/0day-ci/archive/20250914/202509142046.QatEaTQV-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 21857ae337e0892a5522b6e7337899caa61de2a6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250914/202509142046.QatEaTQV-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509142046.QatEaTQV-lkp@intel.com/
All errors (new ones prefixed by >>):
/usr/bin/ld: warning: .tmp_vmlinux1 has a LOAD segment with RWX permissions
/usr/bin/ld: mm/ksm.o: in function `evaluate_memcg_ksm_stat':
>> mm/ksm.c:3335:(.ltext+0x163d): undefined reference to `ksm_process_profit'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
vim +3335 mm/ksm.c
3324
3325 static int evaluate_memcg_ksm_stat(struct task_struct *task, void *arg)
3326 {
3327 struct mm_struct *mm;
3328 struct memcg_ksm_stat *ksm_stat = arg;
3329
3330 mm = get_task_mm(task);
3331 if (mm) {
3332 ksm_stat->ksm_rmap_items += mm->ksm_rmap_items;
3333 ksm_stat->ksm_zero_pages += mm_ksm_zero_pages(mm);
3334 ksm_stat->ksm_merging_pages += mm->ksm_merging_pages;
> 3335 ksm_stat->ksm_profit += ksm_process_profit(mm);
3336 mmput(mm);
3337 }
3338
3339 return 0;
3340 }
3341
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/5] memcg: add per-memcg ksm_rmap_items stat
2025-09-14 10:03 ` [PATCH v2 1/5] memcg: add per-memcg ksm_rmap_items stat xu.xin16
@ 2025-09-14 13:54 ` kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-09-14 13:54 UTC (permalink / raw)
To: xu.xin16, akpm
Cc: oe-kbuild-all, shakeel.butt, hannes, mhocko, roman.gushchin,
david, chengming.zhou, muchun.song, linux-kernel, linux-mm,
cgroups, xu.xin16
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on tj-cgroup/for-next linus/master v6.17-rc5 next-20250912]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/xu-xin16-zte-com-cn/memcg-add-per-memcg-ksm_rmap_items-stat/20250914-181132
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20250914180351288rcLuZnPAMUej48nuTc7KV%40zte.com.cn
patch subject: [PATCH v2 1/5] memcg: add per-memcg ksm_rmap_items stat
config: parisc-randconfig-001-20250914 (https://download.01.org/0day-ci/archive/20250914/202509142147.WQI0impC-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250914/202509142147.WQI0impC-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509142147.WQI0impC-lkp@intel.com/
All errors (new ones prefixed by >>):
mm/ksm.c: In function 'memcg_stat_ksm_show':
>> mm/ksm.c:3345:2: error: implicit declaration of function 'seq_buf_printf'; did you mean 'seq_bprintf'? [-Werror=implicit-function-declaration]
seq_buf_printf(s, "ksm_rmap_items %lu\n", ksm_stat.ksm_rmap_items);
^~~~~~~~~~~~~~
seq_bprintf
cc1: some warnings being treated as errors
vim +3345 mm/ksm.c
3329
3330 /* Show the ksm statistic count at memory.stat under cgroup mountpoint */
3331 void memcg_stat_ksm_show(struct mem_cgroup *memcg, struct seq_buf *s)
3332 {
3333 struct memcg_ksm_stat ksm_stat;
3334
3335 if (mem_cgroup_is_root(memcg)) {
3336 /* Just use the global counters when root memcg */
3337 ksm_stat.ksm_rmap_items = ksm_rmap_items;
3338 } else {
3339 /* Initialization */
3340 ksm_stat.ksm_rmap_items = 0;
3341 /* Summing all processes'ksm statistic items */
3342 mem_cgroup_scan_tasks(memcg, evaluate_memcg_ksm_stat, &ksm_stat);
3343 }
3344 /* Print memcg ksm statistic items */
> 3345 seq_buf_printf(s, "ksm_rmap_items %lu\n", ksm_stat.ksm_rmap_items);
3346 }
3347 #endif
3348
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-09-14 13:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-14 10:00 [PATCH v2 0/5] memcg: Support per-memcg KSM metrics xu.xin16
2025-09-14 10:03 ` [PATCH v2 1/5] memcg: add per-memcg ksm_rmap_items stat xu.xin16
2025-09-14 13:54 ` kernel test robot
2025-09-14 10:05 ` [PATCH v2 2/5] memcg: show ksm_zero_pages count in memory.stat xu.xin16
2025-09-14 10:06 ` [PATCH v2 3/5] memcg: show ksm_merging_pages " xu.xin16
2025-09-14 10:07 ` [PATCH v2 4/5] memcg: add per-memcg ksm_profit xu.xin16
2025-09-14 13:02 ` kernel test robot
2025-09-14 10:09 ` [PATCH v2 5/5] Documentation: add KSM statistic counters description in cgroup-v2.rst xu.xin16
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).