Re: [vserver] dynamic memory limits for vserver-guests?

From: Dallas Kashuba <dallas_at_dreamhost.com>
Date: Thu 29 Oct 2009 - 22:27:31 GMT
Message-Id: <DFF88DD0-5FF3-4472-B19D-DE9032987CB8@dreamhost.com>

On Oct 28, 2009, at 3:42 PM, ADNET Ghislain wrote:

> Jarry a écrit :
>> Hi,
>>
>> I have set up memory limits for all my vserver-guests with
>> rlimits/rss.soft and rss.hard. Now sometimes I hit on memory
>> limits, e.g. when compilling gcc (which I do quite frequently
>> because all my guests are gentoo).
>>
>> But I can not increase memory limits for all vserver-guests,
>> because when counted together, it would be more than physical
>> memory + swap of my vserver-host.
>>
>> So my question is:
>> Is it possible to set those limits dynamically? What I mean
>> is something similar as for cpu-time: to grant a guest certain
>> memory, and in addition, some common "memory-pool" from which
>> any guest could grab memory, if needed. And if "memory-pool"
>> is empty, a guest does not get any extra memory.
>>
>> Jarry
>>
> hi jarry,
>
> from: http://linux-vserver.org/util-vserver:Cheatsheet
>
> it seems that
>
> vlimit : to change the limits of a live guest (cpu, fsize, data,
> stack, core, rss, nproc,nofile, memlock, as, locks, msgqueue, nsock,
> openfd, anon, shmem, semary,nsems, and dentry).
>
> should be the tools for that.
>

Here's a little shell script we use to temporarily double the
available memory on a guest, setting it back how it was afterwards.
It acts as a wrapper around 'vserver' and also works for 'vserver blah
enter'. It's not especially robust but it works for our needs...

#!/bin/sh
# run a vserver command on a guest after doubling the allowed memory
V=$1
shift
guest_as=`cat /etc/vservers/$V/rlimits/as.soft`
guest_rss=`cat /etc/vservers/$V/rlimits/rss.soft`
guest_rss_hard=`cat /etc/vservers/$V/rlimits/rss.hard`

let guest_as_big="$guest_as * 2"
let guest_rss_big="$guest_rss * 2"
let guest_rss_hard_big="$guest_rss_hard * 2"

/usr/sbin/vserver $V running && (/usr/sbin/vlimit --xid $V -H --as
$guest_as_big; /usr/sbin/vlimit --xid $V -S --as $guest_as_big; /usr/
sbin/vlimit --xid $V -H --rss $guest_rss_hard_big; /usr/sbin/vlimit --
xid $V -S --rss $guest_rss_big)

vserver $V "$@"

/usr/sbin/vserver $V running && (/usr/sbin/vlimit --xid $V -H --as
$guest_as; /usr/sbin/vlimit --xid $V -S --as $guest_as; /usr/sbin/
vlimit --xid $V -H --rss $guest_rss_hard; /usr/sbin/vlimit --xid $V -S
--rss $guest_rss)

  - Dallas
Received on Thu Oct 29 22:27:55 2009

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Thu 29 Oct 2009 - 22:27:57 GMT by hypermail 2.1.8