Subject: Re: [vserver] make the host safe with 10% of ressources :)
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Thu, 6 Sep 2007 04:05:27 +0200

On Wed, Sep 05, 2007 at 10:14:10AM +0200, ADNET Ghislain wrote:
> thanks for the answers :)
> >Let's see the settings for the vserver:
> >
> >My goal is to limit the physical ram to  something like 80/90% of the 
> >ram , same thing for the swap so the host still got:
> >
> >- 10% of cpu
> >  
> >
> >  
> ok thanks i will remove the idle-time fair share, so i guess you
> cannot say:
>
> 9 guest, 1 host - 10% of CPU for the host - 10% of cpu per 
> guest with idle time of 8/10 for the guests t share 
> (so i allways keep 10% for host)

well, IDLE time, per definition, is the the time when
_nothing_ else is running (this, of course, includes
host processes), so why would you even want to share
that with the host?

> i have to choose between 10% per guest/host HARD LIMIT or 
> 10%+ idle time for all host included. Understood thanks :)

no, the idle time just affects the guests, as long as
a single host process is running, idle time will never
kick in ... once the cpu goes idle, the time will be
shared between the guests, according to their settings

> By the way i saw that if you make the mistake of doing:
> 
> sudo vsched --xid 40134 --fill-rate 0 --interval 0
> 
> you will freeze the whole computer, not only the guest 
> (this was an error i wanted to put the fillrate2 and 
> interval2 at zero to have hard limit). 

this should not be possible with recent kernels, what
kernel and patch version are you using?

> Is it normal , it should only freeze the guest to make 
> this error i guess ?

it was a bug, some time ago, let me know if it is back

> >>- 10% of ram
> >>    
> >
> >very hard to do, unless you switch off overcommitment
> >(btw, this isn't terribly important, as ram can always
> >be freed by discading buffers and read only mappings
> >  
> yes but the guest is consumming all the memory and then 
> swap like crazy. 

how do you verify that?

> I'd like to keep control of the host when the guest goes 
> mad so i can stop or restart it or constrain it :)

yes, that is the purpose of all the limits

> >>- 10% of swap
> >>    
> >
> >not implemented yet, but having strict limits to the
> >guest memory will automagically leave some of the swap
> >space (swap+ram - Sum[guests]) unused by guest processes

> ok, does the RSS limit include swap size as well i was 
> beleiving it was only a limit on the physical memory ?

it _is_ only a memory limit, but some part of it is
shown as swap inside the guest (to make the guest
experience more 'realistic' :)

> the problem i face is that a guest (i have only 1 guest 
> here) is taking all the memory. 
> The host is therefor unreachable because the guest has 
> all memory and swap like crazy. 

that basically means that your limits are too high
for the actual memory available on the host. with
proper limits a single guest should never be able
to cause trashing on the host ...

> My goal is to keep 10% of the memory for the host so i 
> still can launch a process there. 

> How will you do that if this is possible? 

usually restricting the guest to 90% of the available
memory should be enough (RSS)

> turn off overcommitment and  restrict memory to 90% 
> of the pages ?

with overcommitment off, you can also restrict the VM
and get a meaningful return code (ENOMEM, inside the 
guest) instead of OOM killer reaping (guest) processes

> My try lead to a server where the swap seems disabled 
> (i have nothing in the swap 0k since days so i wonder 
> it allways had something before i limit RSS but perhaps 
> this is not the case and the swap state is not a 
> consequence of limiting my guest RSS.

basically swap should only be used to cover for memory
which actually gets swapped out, not as memory extension.
memory being used all the time (active set) will always
cause trashing when swapped out

> >but if you really want absolute memory control and a
> >guarantee that no process will get more memory than 
> >available, then you have to turn off overcommitment
> >on your linux system 
> >  
> hum i wonder how bad this will be, i guess that if 
> this is on by default this is not a good idea to change 
> it.  

well, indeed most applications in linux simply assume
that they have all the memory in the world, and the
way process spawning works in linux somewhat enforces
this behaviour ...

> If anyone has experience on this i will be glad to hear 
> it , how do you control the ram sharing between 
> guests?

it is not controlled, it happens and makes your system
more performant if used properly :)

HTH,
Herbert

> -- 
> Cordialement,
> Ghislain