Subject: virtmen on 4.4 solved
From: Ghislain Adnet <gadnet@aqueos.com>
Date: Fri, 19 Jan 2018 22:42:34 +0100

hi,



(22:36:01) Ghislain1: the sysinfo unit vary, you have to convert because this is not
allways PAGE_SIZE
(22:36:14) Ghislain1: not on 64bit, they directly put bytes so val->mem_unit =1
but on 32bits it is PAGE_SIZE and some other unknow/ futur thing you never know so you
have to calculate it

where you override the sysinfo structure you must convert  * PAGE_SIZE / val->mem_unit

--- ../linux-4.4.111/kernel/vserver/limit.c     2018-01-14 10:20:44.395367243 +0100
+++ ./kernel/vserver/limit.c    2018-01-19 22:39:35.485846372 +0100
@@ -271,8 +271,8 @@
        res_usage = mem_cgroup_mem_usage_pages(mcg);

        if (res_limit != PAGE_COUNTER_MAX)
-               val->totalram = res_limit;
-       val->freeram = val->totalram - res_usage;
+               val->totalram = res_limit * ( PAGE_SIZE / val->mem_unit) ;
+       val->freeram = val->totalram - ( res_usage * PAGE_SIZE / val->mem_unit );
        val->bufferram = 0;
        val->totalhigh = 0;
        val->freehigh = 0;
@@ -305,7 +305,7 @@
        swap_limit = memsw_limit - res_limit;
        /* we have a swap limit? */
        if (memsw_limit != PAGE_COUNTER_MAX)
-               val->totalswap = swap_limit;
+               val->totalswap = swap_limit * ( PAGE_SIZE / val->mem_unit);

        /* calculate swap part */
        swap_usage = (memsw_usage > res_usage) ?
@@ -313,7 +313,7 @@

        /* total shown minus usage gives free swap */
        val->freeswap = (swap_usage < swap_limit) ?
-               val->totalswap - swap_usage : 0;
+               val->totalswap - ( swap_usage *  PAGE_SIZE / val->mem_unit) : 0;
 out:
 #else  /* !CONFIG_MEMCG_SWAP */
        val->totalswap = 0;




best regards,
Ghislain.