[Devel] [PATCH RHEL8 COMMIT] ve/memcg: Fix /proc/meminfo virtualization (eliminate double recursion)

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jul 26 19:53:25 MSK 2021


The commit is pushed to "(no" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-305.3.1.el8
------>
commit 04182caac24d771fabad43b1da5c212ff0957ab4
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Thu Jul 22 13:16:05 2021 +0300

    ve/memcg: Fix /proc/meminfo virtualization (eliminate double recursion)
    
    This patch partially reverts commit 47f1b6c1d8e5 ("ve/memcg: Make
    virtualization of /proc/meminfo view inside CT recursive")
    
    In vz8 we have both memcg->vmstats (recursive) and
    memcg->vmstats_local (non-recursive), and mem_page_state_recursive()
    brought by the reverted commit does double recursion,
    so revert that logic, but leave the other stuff.
    
    Fixes: 47f1b6c1d8e5 ("ve/memcg: Make virtualization of /proc/meminfo
    view inside CT recursive")
    
    To_merge: 38a2f168a441 ("ve/proc: virtualize /proc/meminfo in a Container")
    
    https://jira.sw.ru/browse/PSBM-131992
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/memcontrol.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d3aa1cf20796..53ff720a34be 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4151,29 +4151,17 @@ void mem_cgroup_get_nr_pages(struct mem_cgroup *memcg, unsigned long *pages)
 		pages[lru] += mem_cgroup_nr_lru_pages(memcg, BIT(lru), true);
 }
 
-static unsigned long mem_page_state_recursive(struct mem_cgroup *memcg,
-					      int idx)
-{
-	struct mem_cgroup *iter;
-	unsigned long val = 0;
-
-	for_each_mem_cgroup_tree(iter, memcg)
-		val += memcg_page_state(iter, idx);
-
-	return val;
-}
-
 void mem_cgroup_fill_meminfo(struct mem_cgroup *memcg, struct meminfo *mi)
 {
 	memset(&mi->pages, 0, sizeof(mi->pages));
 	mem_cgroup_get_nr_pages(memcg, mi->pages);
 
-	mi->slab_reclaimable = mem_page_state_recursive(memcg, NR_SLAB_RECLAIMABLE_B);
-	mi->slab_unreclaimable = mem_page_state_recursive(memcg, NR_SLAB_UNRECLAIMABLE_B);
-	mi->cached = mem_page_state_recursive(memcg, NR_FILE_PAGES);
-	mi->shmem = mem_page_state_recursive(memcg, NR_SHMEM);
-	mi->dirty_pages = mem_page_state_recursive(memcg, NR_FILE_DIRTY);
-	mi->writeback_pages = mem_page_state_recursive(memcg, NR_WRITEBACK);
+	mi->slab_reclaimable = memcg_page_state(memcg, NR_SLAB_RECLAIMABLE_B);
+	mi->slab_unreclaimable = memcg_page_state(memcg, NR_SLAB_UNRECLAIMABLE_B);
+	mi->cached = memcg_page_state(memcg, NR_FILE_PAGES);
+	mi->shmem = memcg_page_state(memcg, NR_SHMEM);
+	mi->dirty_pages = memcg_page_state(memcg, NR_FILE_DIRTY);
+	mi->writeback_pages = memcg_page_state(memcg, NR_WRITEBACK);
 
 	/* locked pages are accounted per zone */
 	/* mi->locked = 0; */


More information about the Devel mailing list