Skip to content

Commit

Permalink
cgroup: move cgroup->sibling unlinking to cgroup_put()
Browse files Browse the repository at this point in the history
Move cgroup->sibling unlinking from cgroup_destroy_css_killed() to
cgroup_put().  This is later but still before the RCU grace period, so
it doesn't break css_next_child() although there now is a larger
window in which a dead cgroup is visible during css iteration.  As css
iteration always could have included offline csses, this doesn't
affect correctness; however, it does make css_next_child() fall back
to reiterting mode more often.  This also makes cgroup_put() directly
take cgroup_mutex, which limits where it can be called from.  These
are not immediately problematic and will be dealt with later.

This change enables simplification of cgroup destruction path.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
  • Loading branch information
Tejun Heo committed May 14, 2014
1 parent 9e4173e commit 4e4e284
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,11 @@ static void cgroup_put(struct cgroup *cgrp)
if (WARN_ON_ONCE(cgrp->parent && !cgroup_is_dead(cgrp)))
return;

/* delete this cgroup from parent->children */
mutex_lock(&cgroup_mutex);
list_del_rcu(&cgrp->sibling);
mutex_unlock(&cgroup_mutex);

cgroup_idr_remove(&cgrp->root->cgroup_idr, cgrp->id);
cgrp->id = -1;

Expand Down Expand Up @@ -4561,9 +4566,6 @@ static void cgroup_destroy_css_killed(struct cgroup *cgrp)
{
lockdep_assert_held(&cgroup_mutex);

/* delete this cgroup from parent->children */
list_del_rcu(&cgrp->sibling);

cgroup_put(cgrp);
}

Expand Down

0 comments on commit 4e4e284

Please sign in to comment.