@@ -1821,6 +1821,40 @@ static int memcg_numa_stat_show(struct seq_file *m, void *v)
}
#endif /* CONFIG_NUMA */
+#ifdef CONFIG_KSM
+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;
+}
+
+static int memcg_ksm_stat_show(struct seq_file *m, void *v)
+{
+ struct memcg_ksm_stat ksm_stat;
+ struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
+
+ /* Initialization */
+ ksm_stat.ksm_rmap_items = 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);
+
+ return 0;
+}
+#endif
+
static const unsigned int memcg1_stats[] = {
NR_FILE_PAGES,
NR_ANON_MAPPED,
@@ -2079,6 +2113,12 @@ struct cftype mem_cgroup_legacy_files[] = {
.name = "numa_stat",
.seq_show = memcg_numa_stat_show,
},
+#endif
+#ifdef CONFIG_KSM
+ {
+ .name = "ksm_stat",
+ .seq_show = memcg_ksm_stat_show,
+ },
#endif
{
.name = "kmem.limit_in_bytes",