Re: cgroups: Assigning tasks to a cgroup slow and does not scale

From: Mike Galbraith
Date: Sat Jun 04 2011 - 06:11:33 EST


On Sat, 2011-06-04 at 10:23 +0200, Martin Baum wrote:
> Hello,
>
> assigning a task to new cgroup takes an unexpected high amount of time
> on my system - about 0.05s. Strangely it does it does not scale with
> more processes: When I run 10 processes that do nothing but change
> their cgroups each cgroup change takes about 0.5 seconds while CPU
> usage remains very low. So my system maxes out at 20 cgroup changes
> per second while cpu and disk usage remain minimal (according to top).
> Is this expected behaviour?

Attaching a task invokes synchronize_rcu() along the way, so yup, it's
the expected behavior.

> It is a problem for me: I run a daemon that forks and calls suid for
> each request. I want to assign each of these forks to a different
> cgroup. However this currently kills performance going down from >100
> req/sec to about 20 req/sec.

You can work around it via static cgroups with an agent waiting inside
each one. Tell your agent what to do, he forks off a worker. You can
inherit a cgroup quickly, but moving between cgroups is very expensive,
as you noticed.

(right way is eventually stop exporting rcu grace periods to userland)

-Mike

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/