Re: [vserver] memory limits: where & how to mount /dev/cgroups?

From: Jean Weisbuch <>
Date: Mon 21 Nov 2011 - 22:01:49 GMT
Message-ID: <>

Le 21/11/2011 21:51, Jarry a écrit :
> Hi,
> I'm trying to set-up memory limits for my vserver-guests.
> Documentation says "Beginning with vs2. you should
> use cgroups to set memory limits".
> util-vserver:Cgroups says: "make sure /dev/cgroup is mounted
> with -o...,memory to be able to use this feature".
> This I do not understand at all. I have /dev/cgroups
> already visible in vserver-host. So where should I mount
> /dev/cgroups again? In vserver-guests?
> Further, util-vserver:Cgroups says:
> "you may wish to add the cgroup mount to /etc/fstab"
> Is it fstab of vserver-host, or vserver-guest?
> Jarry

Here is an example (in this example we will have 1gb of memory on the
guest and no virtual swap (soft and hard limit are the same, raise
VDSRAMHARDLIMIT to 2048 if you want 1gb of memory + 1gb of "swap")) :
(print in mksh is a builtin "equivalent" to echo in bash)

    VDSRAMLIMITBYTES="$(print -- "${VDSRAMLIMIT}*1048576" |bc)"
    VDSRAMHARDLIMITBYTES="$(print -- "${VDSRAMHARDLIMIT}*1048576" |bc)"
    print -- "$VDSRAMLIMITBYTES" >|
    print -- "$VDSRAMLIMITBYTES" >| /dev/cgroup/${xid}/memory.limit_in_bytes

And the old way (for the same amount of memory) :

    print -- "$(( (${VDSRAMLIMIT}*1024)/4 ))" >
    print -- "$(( (${VDSRAMHARDLIMIT}*1024)/4 ))" >
    vlimit -c ${xid} -S --rss "$(( (${VDSRAMLIMIT}*1024)/4 ))"
    vlimit -c ${xid} --rss "$(( (${VDSRAMHARDLIMIT}*1024)/4 ))"

By the way, you cant access cgroups from the guests, only from the host
and in the recent VServer versions you dont even need to mount cgroup,
it mounts itself automatically on /dev/cgroup with the required cgroups
subsystems (be aware that putting incorrect mount options on cgroups
will make the system unbootable so dont try to play with mount options
on a production server).
Example of the cgroup mount on a 3.0.4-vs2.3.1-pre10.1-beng with
0.30.216-pre2994-1 utils :

    vserver on /dev/cgroup type cgroup

Received on Mon Nov 21 22:02:06 2011

[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Mon 21 Nov 2011 - 22:02:06 GMT by hypermail 2.1.8