cgroup: Remove call to synchronize_rcu in cgroup_attach_task
authorColin Cross <ccross@android.com>
Mon, 16 Apr 2012 07:01:13 +0000 (12:01 +0530)
committerVarun Wadekar <vwadekar@nvidia.com>
Mon, 16 Apr 2012 09:45:49 +0000 (14:45 +0530)
commitfaf8f118ff921d25279e894375068574b180c8c5
tree6116990272d7061e51c81a99708a4e43291feb1a
parent07f5cc84ffabddb5f4ba2c06f01b05c41880e647
cgroup: Remove call to synchronize_rcu in cgroup_attach_task

synchronize_rcu can be very expensive, averaging 100 ms in
some cases.  In cgroup_attach_task, it is used to prevent
a task->cgroups pointer dereferenced in an RCU read side
critical section from being invalidated, by delaying the
call to put_css_set until after an RCU grace period.

To avoid the call to synchronize_rcu, make the put_css_set
call rcu-safe by moving the deletion of the css_set links
into free_css_set_work, scheduled by the rcu callback
free_css_set_rcu.

The decrement of the cgroup refcount is no longer
synchronous with the call to put_css_set, which can result
in the cgroup refcount staying positive after the last call
to cgroup_attach_task returns.  To allow the cgroup to be
deleted with cgroup_rmdir synchronously after
cgroup_attach_task, have rmdir check the refcount of all
associated css_sets.  If cgroup_rmdir is called on a cgroup
for which the css_sets all have refcount zero but the
cgroup refcount is nonzero, reuse the rmdir waitqueue to
block the rmdir until free_css_set_work is called.

Signed-off-by: Colin Cross <ccross@android.com>

Conflicts:

kernel/cgroup.c

Change-Id: I3b3f245c8f5e2e5d33f1e54178b2bb6ef10a0817

Conflicts:

kernel/cgroup.c

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
kernel/cgroup.c