Subject: Re: [vserver] Can vservers' RSS limits be decreased dynamically?
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Fri, 30 Oct 2009 13:06:51 +0100

On Thu, Oct 29, 2009 at 07:24:54PM -0700, Matei Zaharia wrote:
> Hi,

> I've tried to use vlimit to change a vserver guest's resident set size  
> (RSS) limit at runtime, as described at 
> http://linux-vserver.org/Memory_Limits . 

> I noticed that if the guest's RSS is above my limit when I run        
> vlimit, then it is allowed to stay above this limit until its         
> processes finish. 

well, it should not be allowed to instantiate any
new pages in memory without invoking the OOM killer,
but yes, as long as it doesn't need a new page, the
process is fine (i.e. the limit is only applied to 
allocations)

> For example, if one of my guests is running a process with a 50 MB    
> RSS, and I set the limit to 20 MB, the process continues to run, and  
> vserver-stat and vtop show its RSS staying at 50.                     

correct

> However, if I kill this process and try launching a new one with  
> the same RSS in the guest VM, the new process is killed. It appears  
> that the limit is set properly but is not applied to existing  
> processes. 

it is not checked when changed, it is checked on the
first allocation done inside the guest (rlimit not
ulimit that is)

> Is there any way to force the existing process to be killed  
> when the RSS limit is lowered?

basically you could use vkill to kill whatever process
you consider 'over limit' with whatever signal you
consider appropriate ... you could also add a check
to the function changing the limit, although I'm not
sure (yet) that this is a good idea (i.e. you have
to convince me with good arguments first :)

> The same issue happens if I set the address space (AS) limit 
> instead of the RSS limit.                                                     

yes, same applies there, allocations are checked, but
not the 'current' over limit

> It also happens if I write my limits to /etc/vserver/ 
> <whatever>/rlimits/rss before running the vlimit command.

yep, that doesn't change/affect anything ...

> I'm running the Ubuntu Jaunty version of vserver from 
> http://linux-vserver.org/Installation_on_Ubuntu . Vserver-info says it's 
> the following version:

>                    Kernel: 2.6.28-16-vserver
>                    VS-API: ???
>              util-vserver: 0.30.216-pre2772; Jan 12 2009, 12:13:20

won't hurt to update to a newer kernel/patch and
util-vserver ... but won't change anything in this
regard ...

best,
Herbert

> Thanks,
> Matei Zaharia