The commit is pushed to "branch-rh10-6.12.0-55.13.1.2.x.vz10-ovz" and will 
appear at [email protected]:openvz/vzkernel.git
after rh10-6.12.0-55.13.1.2.10.vz10
------>
commit 7318b8eee387b89511c7adcac0f865fb020dd7b0
Author: Pavel Tikhomirov <[email protected]>
Date:   Mon Oct 6 12:45:57 2025 +0800

    ve/proc: Fix meminfo swap calculations on cgroup-v2
    
    The memsw counter in cgroup-v2 is reused by swap counter and does not
    include memory usage, we should use it directly instead of subtracting
    memory from memsw.
    
    While on it let's reorder loading memused, memtotal, swapused and
    swaptotal before doing any calculations or corrections on them, and also
    fix comment style.
    
    Fixes: 6992eead25249 ("ve/proc: virtualize /proc/meminfo in a Container")
    
    https://virtuozzo.atlassian.net/browse/VSTOR-105819
    Signed-off-by: Pavel Tikhomirov <[email protected]>
    
    Feature: procfs: virtualize /proc/meminfo
---
 mm/show_mem.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/mm/show_mem.c b/mm/show_mem.c
index be4985e672dc4..0453e3c635eb2 100644
--- a/mm/show_mem.c
+++ b/mm/show_mem.c
@@ -106,13 +106,23 @@ void si_meminfo_ve(struct sysinfo *si, struct ve_struct 
*ve)
 
        memtotal = READ_ONCE(memcg->memory.max);
        memused = page_counter_read(&memcg->memory);
-       si->totalram = memtotal;
 
-       swaptotal = READ_ONCE(memcg->memsw.max) - memtotal;
-       swapused = page_counter_read(&memcg->memsw) - memused;
+       if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
+               swaptotal = READ_ONCE(memcg->swap.max);
+               swapused = page_counter_read(&memcg->swap);
+       } else {
+               swaptotal = READ_ONCE(memcg->memsw.max) - memtotal;
+               swapused = page_counter_read(&memcg->memsw) - memused;
+       }
+
+       si->totalram = memtotal;
        si->totalswap = swaptotal;
-       /* Due to global reclaim, memory.memsw.usage can be greater than
-        * (memory.memsw.max - memory.max). */
+
+       /*
+        * Due to global reclaim, memory.memsw.usage can be greater than
+        * (memory.memsw.max - memory.max), and we show this "excess" swap
+        * usage as if it's memory usage.
+        */
        if (swaptotal >= swapused) {
                si->freeswap = swaptotal - swapused;
        } else {
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to