Subject: Re: [vserver] CPU hard limit
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Fri, 3 Apr 2009 14:31:23 +0200

On Fri, Apr 03, 2009 at 07:12:55PM +0800, Jeff Jansen wrote:
> I'm having no luck imposing a hard limit on CPU usage on a guest.
> I'm sure I'm missing something simple, but after a couple of 
> days of looking, I can't find it. :-)
> 
> Host (vserv2) is a quad core Xeon.  
> Host and guest are both 64-bit debian lenny
> 
> vserv2:~# uname -a
> Linux vserv2 2.6.26-1-vserver-amd64 #1 SMP Fri Mar 13 20:19:13 UTC 2009 x86_64
> GNU/Linux

this debian kernel does not support hard cpu limits
please use 2.6.22.x or 2.6.28.x instead

note the debian 2.6.26 kernel has some other issues
as well, so I would strongly recommend to avoid it

known issues so far:

 - ipv6 problems with source ip selection
 - different xattr flags (means you need to change
   them when you switch from 2.6.22 to 2.6.26 and
   back, when you upgrade to 2.6.27+)
 - missing TB scheduler extension
 - incorrect resource accounting for semaphores and
   memory pages

and the 2.6.26 kernel is known for stability issues
too, so better avoid it ...

best,
Herbert

> vserv2:~# dpkg -l util-vserver
> <snip>
> ii  util-vserver                      0.30.216~r2772-6

> The guest has the sched_hard flag.

> vserv2:~# vattribute --xid 40003 --get
> <snip>
> flags:
> fakeinit,sched_hard,virt_mem,virt_uptime,hide_netif,state_init,state_admin,sc_helper
> 
> vserv2:~# cat /proc/virtual/40003/status
> UseCnt:	136
> Tasks:	57
> Flags:	0000001602030110
> BCaps:	00000000344c04ff
> CCaps:	0000000000000101
> Spaces:	1c020200
> 
> 
> I throttle the guest, giving it only 1 token every 1000 ticks. leaving all the
> other defaults alone.
> 
> vserv2:~# vsched --xid 40003 --fill-rate 1 --interval 1000 --force
> vserv2:~# cat /proc/virtual/40003/sched
> FillRate:	       1,1
> Interval:	    1000,8
> TokensMin:	      15
> TokensMax:	     125
> PrioBias:	       0
> cpu 0: 19 16 0 0 0 R- 62 15 125 1/1000 1/8 0 0
> cpu 1: 27 32 0 0 0 R- 62 15 125 1/1000 1/8 0 0
> cpu 2: 21 18 0 0 0 R- 62 15 125 1/1000 1/8 0 0
> cpu 3: 39 18 0 0 0 R- 62 15 125 1/1000 1/8 0 0
> 
> 
> Then I go into the guest and start a very CPU intensive process (a perl script
> which calculates PI to a zillion digits.)  One core immediately goes to 100%.
> If I background the script and run another instance, another core immediately
> goes to 100$
> 
> vserv2:~# vtop
> top - 19:01:33 up 13 days,  4:39,  2 users,  load average: 1.84, 0.79, 0.39
> Tasks: 795 total,   3 running, 792 sleeping,   0 stopped,   0 zombie
> Cpu0  :  0.6%us,  0.0%sy,  0.0%ni, 99.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
> Cpu1  :  0.3%us,  0.3%sy,  0.0%ni, 99.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
> Cpu2  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
> Cpu3  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
> Mem:   6133056k total,  6053108k used,    79948k free,   138624k buffers
> Swap:  1959912k total,     6096k used,  1953816k free,  3146428k cached
> 
>   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> 
> 26705 root      20   0 17748 1672 1328 R  100  0.0   2:28.88 pi.pl
> 
> 26764 root      20   0 17748 1676 1328 R  100  0.0   1:57.32 pi.pl
> 
> 
> But nothing ever shows as going on hold in the vserver.
> 
> vserv2:~# cat /proc/virtual/40003/sched
> FillRate:	       1,1
> Interval:	    1000,8
> TokensMin:	      15
> TokensMax:	     125
> PrioBias:	       0
> cpu 0: 21 16 0 0 0 R- 62 15 125 1/1000 1/8 0 0
> cpu 1: 1163 34 0 0 0 R- 62 15 125 1/1000 1/8 0 0
> cpu 2: 41631 45 0 0 0 R- 62 15 125 1/1000 1/8 0 0
> cpu 3: 32624 28 0 0 0 R- 62 15 125 1/1000 1/8 0 0
> 
> 
> Any advice, ideas, or words of wisdom are greatly appreciated.
> 
> Jeff Jansen
> 
> 
> 
> 
> 
>