Difference between revisions of "util-vserver:Cgroups"

From Linux-VServer

Jump to: navigation, search
(Draft - Distributing cpu shares with cgroups)
Line 35: Line 35:
  
 
== Draft - Distributing cpu shares with cgroups ==
 
== Draft - Distributing cpu shares with cgroups ==
 +
 +
From what i gathered in sched-design-CFS.txt [http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt|sched-design-CFS.txt]
  
 
This is simply done by adjusting the cpu.shares. Just do:
 
This is simply done by adjusting the cpu.shares. Just do:

Revision as of 09:27, 27 February 2009

Draft - Cgroups and vservers

to make cgroups works with vserver your kernel must have the following settings:

CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
# CONFIG_CGROUP_NS is not set
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_MEM_RES_CTLR=y


Or in the menu:

[*] Control Group support                               [ ]   Example debug cgroup subsystem
[ ]   Namespace cgroup subsystem
[*]   control group freezer subsystem
[*]   Device controller for cgroups
[*]   Cpuset support
[*] Group CPU scheduler
[*]   Group scheduling for SCHED_OTHER
[ ]   Group scheduling for SCHED_RR/FIFO
      Basis for grouping tasks (Control groups)  --->
[*] Simple CPU accounting cgroup subsystem
[*] Resource counters
[*] Memory Resource Controller for Control Groups


Then you must create on you guest /etc/vservers/<guest>/cgroup/ all the files put here will be copied to the guest cgroup when created. The doc for cgroup is not on the great flower page but in the source of the latests utils. You can have a default cgroup directory for all guest that can be overrided by each guest's cgroup directory.

Draft - Distributing cpu shares with cgroups

From what i gathered in sched-design-CFS.txt [1]

This is simply done by adjusting the cpu.shares. Just do:

echo '512' > /dev/cgroup/<guest name>/cpu.shares

The share you get is equal to the guest's share divided by the sum of the cpu shares of all the guest. So for exemple :

vserver guest 1 => 512   
vserver guest 2 => 512
vserver guest 3 => 2048
vserver guest 4 => 512

then you get :

vserver guest 1 => 512 / 3584 = 14%  cpu
vserver guest 2 => 512 / 3584 = 14%  cpu
vserver guest 3 => 2048 / 3584 = 57% cpu
vserver guest 4 => 512 / 3584 = 14%  cpu



Note that this is fair scheduling and this will not enfore HARD limit (as far as i know).

Regards, Ghislain.

Personal tools