Applying CPU Limits

From Linux-VServer

Revision as of 21:08, 21 October 2011 by Glenn (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Applying CPU limits

This is a short summary on how to apply limits. This doesn't cover how to choose the values but just on how to apply the numbers in a running vserver without saving the configuration.

note: you can find soft/hard cpu limit with cgroups for vserver2.3 on util-vserver:Cgroups

Kernel config

First check whether the kernel is with CONFIG_VSERVER_HARDCPU enabled:

  # cat /boot/config-blah | grep CONFIG_VSERVER_HARDCPU

Note: With newer kernels, the config of the currently running kernel can be found with `zcat /proc/config.gz | grep VSERVER`.

Context flag

Then check if the vserver you want to apply limits has the sched_hard context flag enabled by checking the contents of /proc/virtual/<xid>/status. The sched_hard flag is 0x00000100, so you have to find this value summed up in the vserver flag (see this message for details). If its not enabled, use the following command (more info here):

 vattribute --set --xid <xid> --flag sched_hard

Setting the limits

Then you should be able to set the limits with a command like this one (more info here):

 vsched --xid <xid> --fill-rate <fill-rate> --interval <interval> \
        --fill-rate2 <fill-rate2> --interval2 <interval2> \
        --tokens-max <tokens-max> --tokens-min <tokens-min> --idle-time --force 

it's important to use the option --force so the limit is applied at the same time in the cpus. If you want to enable fair share (i.e, idle-time) for the vserver, make sure to use the --idle-time option at the previous command.

Then you should check at /proc/virtual/<xid>/sched (more info here). Try a command like

 watch -n1 cat /proc/virtual/<xid>/sched

If the collum "Ticks spent on hold" is greater than zero and the flag "On hold (H) or running (R)" assumes the hold value, then its working :)

If you want to remove the scheduling, use the command

 vattribute --set --xid <xid> --flag ~sched_hard

But remember that these instructions just cover setting limits in a running vserver. To save the values you choose please refer to the great flower page.

Personal tools