[Devel] [PATCH RHEL7 COMMIT] mm/memcontrol: Fix mem cgroup usage statistics.

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jan 23 02:47:55 PST 2017


The commit is pushed to "branch-rh7-3.10.0-514.6.1.vz7.28.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.6.1.vz7.28.2
------>
commit 7e9a740f1e974b0a5d8236824c060ece43a59865
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Mon Jan 23 14:47:55 2017 +0400

    mm/memcontrol: Fix mem cgroup usage statistics.
    
    mem_cgroup_usage() reports usage in pages for non-root cgroup, and in bytes
    otherwise. Make it always in pages and update mem_cgroup_read() caller
    which wants result in bytes.
    
    https://jira.sw.ru/browse/PSBM-58993
    
    Fixes: 1af99077c135 ("ms/mm: memcontrol: revert use of root_mem_cgroup res_counter")
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 mm/memcontrol.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index dc83f4e..233f542 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4194,7 +4194,7 @@ static inline u64 mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)
 	if (swap)
 		val += mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_SWAP);
 
-	return val << PAGE_SHIFT;
+	return val;
 }
 
 void mem_cgroup_fill_meminfo(struct mem_cgroup *memcg, struct meminfo *mi)
@@ -4268,9 +4268,9 @@ static ssize_t mem_cgroup_read(struct cgroup *cont, struct cftype *cft,
 	switch (MEMFILE_ATTR(cft->private)) {
 	case RES_USAGE:
 		if (counter == &memcg->memory)
-			val = mem_cgroup_usage(memcg, false);
+			val = mem_cgroup_usage(memcg, false) * PAGE_SIZE;
 		else if (counter == &memcg->memsw)
-			val = mem_cgroup_usage(memcg, true);
+			val = mem_cgroup_usage(memcg, true) * PAGE_SIZE;
 		else
 			val = (u64)page_counter_read(counter) * PAGE_SIZE;
 		break;


More information about the Devel mailing list