Re: [vserver] Re: virtmen on 4.4 solved

From: Ghislain Adnet <gadnet_at_aqueos.com>
Date: Sat 20 Jan 2018 - 14:34:46 GMT
Message-ID: <6fe019bb-16da-6aae-94b1-98085fb2aa58@aqueos.com>

one last try:

--- ../linux-4.4.111/kernel/vserver/limit.c 2018-01-14 10:20:44.395367243 +0100
+++ ./kernel/vserver/limit.c 2018-01-20 15:33:07.201912648 +0100
@@ -270,9 +270,10 @@
        res_limit = mem_cgroup_mem_limit_pages(mcg);
        res_usage = mem_cgroup_mem_usage_pages(mcg);

- if (res_limit != PAGE_COUNTER_MAX)
- val->totalram = res_limit;
- val->freeram = val->totalram - res_usage;
+ if (res_limit != PAGE_COUNTER_MAX)
+ val->totalram = ( val->mem_unit == 1 ) ? (res_limit << PAGE_SHIFT) : res_limit;
+
+ val->freeram = ( val->mem_unit == 1 ) ? val->totalram - ( res_usage << PAGE_SHIFT ) : val->totalram - res_usage;
        val->bufferram = 0;
        val->totalhigh = 0;
        val->freehigh = 0;
@@ -303,17 +304,19 @@
                goto out;

        swap_limit = memsw_limit - res_limit;
- /* we have a swap limit? */
- if (memsw_limit != PAGE_COUNTER_MAX)
- val->totalswap = swap_limit;
+ /* calculate swap part */
+ swap_usage = (memsw_usage > res_usage) ? memsw_usage - res_usage : 0;

- /* calculate swap part */
- swap_usage = (memsw_usage > res_usage) ?
- memsw_usage - res_usage : 0;
-
- /* total shown minus usage gives free swap */
- val->freeswap = (swap_usage < swap_limit) ?
- val->totalswap - swap_usage : 0;
+ /* we have a swap limit? */
+ if (memsw_limit != PAGE_COUNTER_MAX){
+ val->totalswap = ( val->mem_unit == 1 ) ? swap_limit << PAGE_SHIFT : swap_limit;
+ /* sysinfo unit is bytes OR PAGE_SIZE ? */
+ }
+ if ( swap_usage < swap_limit ){
+ val->freeswap = ( val->mem_unit == 1 ) ? ( swap_limit - swap_usage ) << PAGE_SHIFT : swap_limit -
swap_usage;
+ } else {
+ val->freeswap = 0;
+ }
 out:
 #else /* !CONFIG_MEMCG_SWAP */
        val->totalswap = 0;
Received on Sat Jan 20 14:32:22 2018

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Sat 20 Jan 2018 - 14:32:22 GMT by hypermail 2.1.8