The memsw counter is unavailable in cgroup-v2, we have swap and memory
to chose from, let's put failcount on memory. Although actually it's for
memory + swap + file + reclaimable, but putting this failcount on swap
looks less intuitive.

Fixes: 8117828baaa09 ("ve/mm: add heuristic check for memory overcommit")
https://virtuozzo.atlassian.net/browse/VSTOR-105819
Signed-off-by: Pavel Tikhomirov <[email protected]>

Feature: mm: per-CT memory overcommit heuristic
---
 mm/memcontrol.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index cba985e5d3d1d..6e1f2816931fa 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3419,10 +3419,14 @@ int ve_enough_memory(long pages)
 
        css = ve_get_init_css(ve, memory_cgrp_id);
        memcg = mem_cgroup_from_css(css);
-       ret = mem_cgroup_enough_memory(memcg, pages);
 
-       if (unlikely(ret < 0))
-               memcg->memsw.failcnt++;
+       ret = mem_cgroup_enough_memory(memcg, pages);
+       if (unlikely(ret < 0)) {
+               if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+                       memcg->memory.failcnt++;
+               else
+                       memcg->memsw.failcnt++;
+       }
 
        css_put(css);
        return ret;
-- 
2.51.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to