[vserver] Re: virtmen on 4.4 solved

From: Herbert Poetzl <herbert_at_13thfloor.at>
Date: Sat 20 Jan 2018 - 02:14:56 GMT
Message-ID: <20180120021456.GA32629@MAIL.13thfloor.at>

On Fri, Jan 19, 2018 at 10:42:34PM +0100, Ghislain Adnet wrote:
> hi,

Hey Ghislain,

> (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

Dividing inside the kernel (especially by a variable) is a
recipe for disaster - don't do that ... ever! :)

What should work is simply changing the mem_unit to the
correct value or have different cases there ...

What also works is to multiply by a variable and shift
by PAGE_SHIFT, but that doesn't help you here.

Best,
Herbert

> --- ../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.
Received on Sat Jan 20 02:12:37 2018

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