aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-05-14 09:15:01 -0400
committerTejun Heo <tj@kernel.org>2014-05-14 09:15:01 -0400
commitcbc125efada6d8c2555dd35e938694eb9b7cd791 (patch)
tree97f8581666b3b79d541955c9c50d1268bd1883a7 /kernel/cgroup.c
parent9d800df12d31734a6853915e9d2deb5d6747985f (diff)
cgroup: separate out cgroup_has_live_children() from cgroup_destroy_locked()
We're expecting another user. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index b57a949ae4bc..3f5f48130b6b 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3295,6 +3295,21 @@ css_next_descendant_post(struct cgroup_subsys_state *pos,
3295 return css_parent(pos); 3295 return css_parent(pos);
3296} 3296}
3297 3297
3298static bool cgroup_has_live_children(struct cgroup *cgrp)
3299{
3300 struct cgroup *child;
3301
3302 rcu_read_lock();
3303 list_for_each_entry_rcu(child, &cgrp->children, sibling) {
3304 if (!cgroup_is_dead(child)) {
3305 rcu_read_unlock();
3306 return true;
3307 }
3308 }
3309 rcu_read_unlock();
3310 return false;
3311}
3312
3298/** 3313/**
3299 * css_advance_task_iter - advance a task itererator to the next css_set 3314 * css_advance_task_iter - advance a task itererator to the next css_set
3300 * @it: the iterator to advance 3315 * @it: the iterator to advance
@@ -4465,7 +4480,6 @@ static void kill_css(struct cgroup_subsys_state *css)
4465static int cgroup_destroy_locked(struct cgroup *cgrp) 4480static int cgroup_destroy_locked(struct cgroup *cgrp)
4466 __releases(&cgroup_mutex) __acquires(&cgroup_mutex) 4481 __releases(&cgroup_mutex) __acquires(&cgroup_mutex)
4467{ 4482{
4468 struct cgroup *child;
4469 struct cgroup_subsys_state *css; 4483 struct cgroup_subsys_state *css;
4470 bool empty; 4484 bool empty;
4471 int ssid; 4485 int ssid;
@@ -4487,15 +4501,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
4487 * emptiness as dead children linger on it while being destroyed; 4501 * emptiness as dead children linger on it while being destroyed;
4488 * otherwise, "rmdir parent/child parent" may fail with -EBUSY. 4502 * otherwise, "rmdir parent/child parent" may fail with -EBUSY.
4489 */ 4503 */
4490 empty = true; 4504 if (cgroup_has_live_children(cgrp))
4491 rcu_read_lock();
4492 list_for_each_entry_rcu(child, &cgrp->children, sibling) {
4493 empty = cgroup_is_dead(child);
4494 if (!empty)
4495 break;
4496 }
4497 rcu_read_unlock();
4498 if (!empty)
4499 return -EBUSY; 4505 return -EBUSY;
4500 4506
4501 /* 4507 /*