The commit is pushed to "branch-rh9-5.14.0-427.44.1.vz9.80.x-ovz" and will 
appear at g...@bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.44.1.vz9.80.32
------>
commit b6c70d31dc3782fb97e32b7950af8d3809006018
Author: Konstantin Khorenko <khore...@virtuozzo.com>
Date:   Wed Apr 30 14:35:15 2025 +0200

    memcg: fix memsw max calculation for oom_score in cgroup-v2
    
    The memsw counter in cgroup-v2 is reused by swap counter and does not
    include memory usage, we need to replace it with memory + swap.
    
    Fixes: 0cfabaf0eedad ("proc,memcg: use memcg limits for showing oom_score
    inside CT")
    
    https://virtuozzo.atlassian.net/browse/VSTOR-104929
    
    Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com>
    Reviewed-by: Pavel Tikhomirov <ptikhomi...@virtuozzo.com>
    
    Feature: mm/oom: per-CT oom_score virtualization
---
 include/linux/memcontrol.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index f51d7f4df3059..9b766ef9f0585 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1008,11 +1008,17 @@ unsigned long mem_cgroup_get_zone_lru_size(struct 
lruvec *lruvec,
 
 static inline unsigned long mem_cgroup_total_pages(struct mem_cgroup *memcg)
 {
-       unsigned long ram, ram_swap;
+       unsigned long ram, memsw, ram_swap;
        extern long total_swap_pages;
 
        ram = min_t(unsigned long, totalram_pages(), memcg->memory.max);
-       ram_swap = min_t(unsigned long, memcg->memsw.max, ram + 
total_swap_pages);
+
+       if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+               memsw = memcg->memory.max + memcg->swap.max;
+       else
+               memsw = memcg->memsw.max;
+
+       ram_swap = min_t(unsigned long, memsw, ram + total_swap_pages);
 
        return ram_swap;
 }
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to