[Devel] [PATCH RHEL8 COMMIT] mm/memcontrol: fix oom counting

Konstantin Khorenko khorenko at virtuozzo.com
Tue Jun 22 14:39:56 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.47
------>
commit f0a51092091d908bc778db4d3731b59e6d355d6a
Author: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Date:   Tue Jun 22 14:39:56 2021 +0300

    mm/memcontrol: fix oom counting
    
    Fix oom_total in /sys/fs/cgroup/memory/memory.stat being always zero due to
    incrementing pointer instead of value in accumulate_ooms().
    
    Drop cond_resched() - looks like an overkill to call it after each two
    atomic_long_read()
    
    Fixes: 64e8dc809dd9 ("mm, memcg: Fix "add oom counter to memory.stat memcgroup
    file"")
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 mm/memcontrol.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 74bad9ff98b9..4958d2a6aad7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4290,19 +4290,19 @@ static const unsigned int memcg1_events[] = {
 	PSWPOUT,
 };
 
-static void accumulate_ooms(struct mem_cgroup *memcg, unsigned long *total_oom,
-			unsigned long *total_oom_kill)
+static void accumulate_ooms(struct mem_cgroup *memcg, unsigned long *oom,
+			unsigned long *kill)
 {
 	struct mem_cgroup *mi;
-
-	total_oom_kill = total_oom = 0;
+	unsigned long total_oom_kill = 0, total_oom = 0;
 
 	for_each_mem_cgroup_tree(mi, memcg) {
 		total_oom += atomic_long_read(&mi->memory_events[MEMCG_OOM]);
 		total_oom_kill += atomic_long_read(&mi->memory_events[MEMCG_OOM_KILL]);
-
-		cond_resched();
 	}
+
+	*oom = total_oom;
+	*kill = total_oom_kill;
 }
 
 static int memcg_stat_show(struct seq_file *m, void *v)


More information about the Devel mailing list