Subject: Re: [vserver] vserver and cgroups
From: Jean Weisbuch <jean@phpnet.org>
Date: Mon, 31 Mar 2014 16:45:31 +0200

Hi,

I havent tried a 3.13 kernel yet but these informaitons are applicable 
to 3.10 kernels (and olders too).

With the util-vserver supplied on the BenG repository you dont need to 
manually mount the cgroups, memory limit support should be loaded 
automatically.

As for modifying limits on /etc/vservers/<guest>/cgroup/memory, the 
limits will only be used at the VServer start, not if the VServer is 
already running.
You can change the live value on : /dev/cgroup/<guest>/memory.* (wont be 
kept at reboot).

I am not sure that putting an "*G" argument will work, i personally use 
integer values such as :
	VSERVERNAME=thevservername MEMLIMITGB=4

	[[ ! -d "/etc/vservers/${VSERVERNAME}/cgroup" ]] && mkdir 
/etc/vservers/${VSERVERNAME}/cgroup
	echo $((${MEMLIMITGB}*1024*1024*1024)) > 
/etc/vservers/${VSERVERNAME}/cgroup/memory.limit_in_bytes
	echo $((${MEMLIMITGB}*1024*1024*1024)) > 
/etc/vservers/${VSERVERNAME}/cgroup/memory.memsw.limit_in_bytes
	perl -i -pe 's/^#(virt_mem)/\1/' /etc/vservers/${VSERVERNAME}/cflags
	echo $((${MEMLIMITGB}*1024*1024*1024)) > 
/dev/cgroup/${VSERVERNAME}/memory.limit_in_bytes
	echo $((${MEMLIMITGB}*1024*1024*1024)) > 
/dev/cgroup/${VSERVERNAME}/memory.memsw.limit_in_bytes


On 31/03/2014 16:37, Tomasz Pajor wrote:
> Hi,
>
> I have problem with setting up memory limit on a vserver.
> I'm using 3.13.6-vs2.3.6.11-beng from repo.psand.net.
>
> Steps
> - added "cgroup_enable=memory swapaccount=1" to GRUB_CMDLINE_LINUX
> - added "none /dev/cgroup cgroup cpu,cpuset,memory 0 0" to /etc/fstab
> - added "INFO_INIT,VIRT_MEM,VIRT_UPTIME,VIRT_LOAD,REBOOT_KILL" to cflags
> of the guest
> - mkdir /etc/vservers/.defaults/cgroup
> - mkdir /etc/vservers/<guest>/cgroup
> - echo "4G" > /etc/vservers/<guest>/cgroup/memory.limit_in_bytes
> - echo "8G" > /etc/vservers/<guest>/cgroup/memory.memsw.limit_in_bytes
>
> When I enter the guest, limits are not applied, also when I run
> vserver-stat I got "open(memory.stat): No such file or directory".
>
> Can anyone point out what am I doing wrong?