Implement cpu limitations

The limitations we impose for cpu can be tracked mostly to the cpu
cgroup. Setting a fixed mask is the exception, being tracked to the
cpuset cgroup.

One needs to note that we cheat a bit when we interpret #cpus: upstream
Linux can't restrict a group of processes to run in a certain number of
cpus. (And according to peterz this is a lost battle, which I don't want
to tackle)

What we can do instead, is define a number of miliseconds we run for
each second. This means we can say "run for 2s each 1s", but that can
mean that 4 cpus are running the code for 0.5s each.

Signed-off-by: Glauber Costa <glommer@parallels.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
3 files changed