[Devel] [PATCH RHEL8 COMMIT] ve/memcg: Fix /proc/vmstat virtualization (drop extra recursion)

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jul 26 19:55:01 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 73f35c53e979033f9935d7fc5084e16fbfe205e2
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Thu Jul 22 15:46:46 2021 +0300

    ve/memcg: Fix /proc/vmstat virtualization (drop extra recursion)
    
    Fixes: 5f48326db336 ("ve/memcg: Virtualize /proc/vmstat view inside CT")
    
    https://jira.sw.ru/browse/PSBM-131992
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/memcontrol.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d0285243200f..4638d9fe1ebf 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4180,7 +4180,7 @@ void mem_cgroup_fill_meminfo(struct mem_cgroup *memcg, struct meminfo *mi)
 
 void mem_cgroup_fill_vmstat(struct mem_cgroup *memcg, unsigned long *stats)
 {
-	int cpu, i;
+	int i;
 	unsigned long limit = READ_ONCE(memcg->memory.max);
 	unsigned long memory = page_counter_read(&memcg->memory);
 	unsigned long *zone_stats = stats;
@@ -4203,28 +4203,18 @@ void mem_cgroup_fill_vmstat(struct mem_cgroup *memcg, unsigned long *stats)
 	node_stats[NR_FILE_PAGES] = node_stats[NR_ACTIVE_FILE] +
 				    node_stats[NR_INACTIVE_FILE];
 
-	node_stats[NR_SLAB_RECLAIMABLE_B] = mem_page_state_recursive(
-			memcg, NR_SLAB_RECLAIMABLE_B);
-	node_stats[NR_SLAB_UNRECLAIMABLE_B] = mem_page_state_recursive(
-			memcg, NR_SLAB_UNRECLAIMABLE_B);
-	node_stats[NR_FILE_MAPPED] = mem_page_state_recursive(
-			memcg, NR_FILE_MAPPED);
-	node_stats[NR_SHMEM] = mem_page_state_recursive(
-			memcg, NR_SHMEM);
-
-
+	node_stats[NR_SLAB_RECLAIMABLE_B] =
+				memcg_page_state(memcg, NR_SLAB_RECLAIMABLE_B);
+	node_stats[NR_SLAB_UNRECLAIMABLE_B] =
+				memcg_page_state(memcg, NR_SLAB_UNRECLAIMABLE_B);
+	node_stats[NR_FILE_MAPPED] = memcg_page_state(memcg, NR_FILE_MAPPED);
+	node_stats[NR_SHMEM] = memcg_page_state(memcg, NR_SHMEM);
 
 #ifdef CONFIG_VM_EVENT_COUNTERS
-	for_each_possible_cpu(cpu) {
-		vm_stats[PSWPIN] += per_cpu(
-			memcg->vmstats_local->events[PSWPIN], cpu);
-		vm_stats[PSWPOUT] += per_cpu(
-			memcg->vmstats_local->events[PSWPOUT], cpu);
-		vm_stats[PGFAULT] += per_cpu(
-			memcg->vmstats_local->events[PGFAULT], cpu);
-		vm_stats[PGMAJFAULT] += per_cpu(
-			memcg->vmstats_local->events[PGMAJFAULT], cpu);
-	}
+	vm_stats[PSWPIN] = memcg_events(memcg, PSWPIN);
+	vm_stats[PSWPOUT] = memcg_events(memcg, PSWPOUT);
+	vm_stats[PGFAULT] = memcg_events(memcg, PGFAULT);
+	vm_stats[PGMAJFAULT] = memcg_events(memcg, PGMAJFAULT);
 #endif
 }
 


More information about the Devel mailing list