Re: [vserver] cgroup to allocate CPU resource

From: Corey Wright <undefined_at_pobox.com>
Date: Thu 17 Jun 2010 - 16:09:49 BST
Message-Id: <20100617100949.dfd980ab.undefined@pobox.com>

On Tue, 15 Jun 2010 14:37:58 -0700
Nirmal Guhan <vavatutu@gmail.com> wrote:

> Am trying to put a (hard)limit on the CPU util of two of my VPS.
> I set
> 1) VPS 1 :
> cpu.rt_period_us to 1000000
> cpu.rt_runtime_us to 500000
> cpuset.cpus to 1
> 2) VPS 2:
> cpu.rt_period_us to 1000000
> cpu.rt_runtime_us to 100000
> cpuset.cpus to 1
> Basically I want VPS1 to use not more than 50% of CPU and VPS2 not more
> than 10%. This doesn't seem to work.

i believe s/cpu.rt_/cpu.cfs_/, according to both my personal experience and
http://linux-vserver.org/util-vserver:Cgroups.

> I can see these values are set
> correctly when I cat /dev/cgroup/<VPS> but when I do vtop I always see
> ~50% from each of the VPS

i see the same (incorrect) behavior.

processors: single processor, dual core, no hyperthreading
kernel: 2.6.32.15
linux-vserver: 2.3.0.36.29.4
vservers: test1 & test2

# cat++ /dev/cgroup/*/cpu.cfs_*_us
/dev/cgroup/test1/cpu.cfs_period_us ...
100000
/dev/cgroup/test1/cpu.cfs_runtime_us ...
50000
/dev/cgroup/test2/cpu.cfs_period_us ...
100000
/dev/cgroup/test2/cpu.cfs_runtime_us ...
10000

so, vserver1 should use 50% of a core (50 out of 100 ms) and vserver2
should use 10% of a core (10 out of 100 ms; whether the same or the other
core). but instead i'm seeing on average 70% and 20%. i say "on average"
because the actual numbers vary greatly with a vtop refresh rate of 1 sec
(ie "70%" means low of 60% to high of 80%). this variance is suprising as
cpu.shares/soft-limits gives me very consistent numbers with almost no
variance in vtop with a 1 sec refresh rate.

if i set both vservers to the first core (ie cpuset.cpus = 0), then
vserver1 is 75% and vserver2 is 25% (of the first core) with little
variance.

just to fully disclose, my soft-limits (which shouldn't matter as
supposedly hard-limits override , but maybe i'm incorrect or there's a bug
and my soft-limit settings will shed a light on the situation) are:

# cat++ /dev/cgroup/*/cpu.shares
/dev/cgroup/test1/cpu.shares ...
1024
/dev/cgroup/test2/cpu.shares ...
1024

so according to my soft-limits, vservers test1 and test2 should get equal
time.

> (Am just executing a C program that goes on an
> infinite loop in both the VPS for testing).

i use stress (http://weather.ou.edu/~apw/projects/stress/), as in "stress
--cpu <worker count>". one cpu worker is good enough for testing limits,
but i use various counts to help distinguish what vserver the process is
running in because my preferred top application, htop, doesn't support
identifying what vserver a process is running in (at least not the version
in debian lenny).

> Could someone sched some light? Am referring to
> http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6-Beta/html/Resource_Management_Guide/cpu.htmlfor
> the documentation.

i believe the more appropriate documentation for using cfs in cooperation
with linux-vserver would be http://linux-vserver.org/util-vserver:Cgroups,
which i have referenced previously, twice.

corey

-- 
undefined@pobox.com
Received on Thu Jun 17 16:15:02 2010
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Thu 17 Jun 2010 - 16:15:05 BST by hypermail 2.1.8