From: Herbert Poetzl (herbert_at_13thfloor.at)
Date: Mon 20 Dec 2004 - 03:32:29 GMT
On Mon, Dec 20, 2004 at 02:00:42AM +0100, Thorsten Gunkel wrote:
> (Please ignore that until Herbert/Bertl acknowledges that I didn't
> misunderstood him completely ;-))
okay, so I'm adding my remarks now ...
> Hi *,
> just in case this is interesting for someone:
>
> ********* Mini Howto for CPU hard limits ************
>
> I did it with:
>
> - 2.6.9 vanilla Kernel
> - patch-2.6.9-vs1.9.3.diff
>
> In kernel config enable
>
> CONFIG_VSERVER_HARDCPU=y
>
> and optionally
only required if you explicitely want the idle
process to be limited too (i.e. get lower idle
intervals between vserver schedules)
> CONFIG_VSERVER_HARDCPU_IDLE=y
>
> You may check if your kernel already supports this with:
>
> gzip -dc /proc/config.gz | grep CONFIG_VSERVER_HARDCPU
> (this will only work if your kernel creates a /proc/config.gz file,
> otherwise try
> grep /usr/src/linux/.config -e CONFIG_VSERVER_HARDCPU
> otherwise)
>
> Now change to the etc folder for the vserver you want to hardlimit the
> cpu power.
>
> Create a file named flags and write
>
> sched_hard
>
> into it (don't forget final linebreak). If this file already exists
> just append the new line.
>
> Now create a file named schedule. It must have 6 lines:
>
> FillRate
> Interval
> StartNrOfTokens
> tokens_min
> tokens_max
> IGNOREFORNOW
>
> In short your vserver can only consume cpu power if it has tokens
> left (to be more precisely: if it has more than tokens_min tokens).
well, you can consume as long as tokens are availabel
(regardless of the tokens_min setting) but to get back
into 'businenss' you need at least tokens_min tokens
in the bucket ...
> The more cpu power it uses the more token it looses :-).
each running process consumes a token per jiffie (tick)
but only if it is actually executed by a cpu ...
> At the start it has StartNrOfTokens (or TokensMax if that is
> smaller?). After each Interval has passed it gets FillRate new ones
> until it reaches tokens_max.
>
> So in short:
> higher FillRate and lower Interval -> more cpu power.
>
> Example for your schedule file:
>
> 20
> 100
> 600
> 0
> 500
> 0
>
> Every 100 ticks 20 new tokens, no tokens_min (one token is enough to be
> back in business) max 500 tokens and a startvalue of
> 600 tokens (well, ...).
the 100/20 means 20% of the total available 'cpu power'
(in average) and the 500 tokens max, means a 'burst' time
of about half a second with 1k ticks (default)
> Now start your vserver (don't enter it yet) and check
>
> cat /proc/virtual/YOURID/status
>
> | ...
> | Flags: 0000000202000110
> ^
>
> It should end with 1..
> If it doesn't your flags file is broken, try:
>
> vattribute --set --xid YOURID --flag ^8
> or
> vattribute --set --xid YOURID --flag sched_hard
>
>
> Now check
>
> cat /proc/virtual/YOURID/sched
>
> Token: 500
> FillRate: 20
> Interval: 100
> TokensMin: 0
> TokensMax: 500
> PrioBias: 0
> cpu 0: 59 48 0
>
>
> If you now consume CPU power inside the vserver the Token value will
> drop, if it reaches zero your vserver will stop and after 20 ticks
> you'll get new tokens.
>
> Have fun
> Thorsten
looks good,
thanks,
Herbert
> _______________________________________________
> Vserver mailing list
> Vserver_at_list.linux-vserver.org
> http://list.linux-vserver.org/mailman/listinfo/vserver
_______________________________________________
Vserver mailing list
Vserver_at_list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver