[Devel] [PATCH rh7 2/3] mm: memcontrol: fix meminfo:SUnreclaim output in containers

Vladimir Davydov vdavydov at virtuozzo.com
Thu May 12 07:11:05 PDT 2016


We calculate SUnreclaim as total kmem usage minus SReclaimable. This is
wrong, because kmem also charges non-slab objects, such as page tables
and kernel stack pages.

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 mm/memcontrol.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f42f7708d19d..476352078f1b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4979,17 +4979,15 @@ static unsigned long mem_cgroup_recursive_stat(struct mem_cgroup *memcg,
 void mem_cgroup_fill_meminfo(struct mem_cgroup *memcg, struct meminfo *mi)
 {
 	int nid;
-	unsigned long slab;
 
 	memset(&mi->pages, 0, sizeof(mi->pages));
 	for_each_online_node(nid)
 		mem_cgroup_get_nr_pages(memcg, nid, mi->pages);
 
-	slab = res_counter_read_u64(&memcg->kmem, RES_USAGE) >> PAGE_SHIFT;
-	mi->slab_reclaimable = res_counter_read_u64(&memcg->dcache, RES_USAGE)
-								>> PAGE_SHIFT;
-	mi->slab_unreclaimable = max_t(long, slab - mi->slab_reclaimable, 0);
-
+	mi->slab_reclaimable = mem_cgroup_recursive_stat(memcg,
+					MEM_CGROUP_STAT_SLAB_RECLAIMABLE);
+	mi->slab_unreclaimable = mem_cgroup_recursive_stat(memcg,
+					MEM_CGROUP_STAT_SLAB_UNRECLAIMABLE);
 	mi->cached = mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_CACHE);
 	mi->shmem = mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_SHMEM);
 }
-- 
2.1.4



More information about the Devel mailing list