diff options
author | Tejun Heo <tj@kernel.org> | 2014-05-13 12:10:59 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-05-13 12:10:59 -0400 |
commit | 0cee8b7786467907e12d1d8f872e6dc73bc95204 (patch) | |
tree | ef6db71c2426ce12ed2f558790d0efe76bffd4a7 /kernel/cgroup.c | |
parent | f21a4f7594a122dcaabc08ce03bfb63fdc34de1b (diff) |
cgroup: fix offlining child waiting in cgroup_subtree_control_write()
cgroup_subtree_control_write() waits for offline to complete
child-by-child before enabling a controller; however, it has a couple
bugs.
* It doesn't initialize the wait_queue_t. This can lead to infinite
hang on the following schedule() among other things.
* It forgets to pin the child before releasing cgroup_tree_mutex and
performing schedule(). The child may already be gone by the time it
wakes up and invokes finish_wait(). Pin the child being waited on.
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.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 9db1a9629a5c..95fc66b16091 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2594,16 +2594,18 @@ retry: | |||
2594 | * cases, wait till it's gone using offline_waitq. | 2594 | * cases, wait till it's gone using offline_waitq. |
2595 | */ | 2595 | */ |
2596 | cgroup_for_each_live_child(child, cgrp) { | 2596 | cgroup_for_each_live_child(child, cgrp) { |
2597 | wait_queue_t wait; | 2597 | DEFINE_WAIT(wait); |
2598 | 2598 | ||
2599 | if (!cgroup_css(child, ss)) | 2599 | if (!cgroup_css(child, ss)) |
2600 | continue; | 2600 | continue; |
2601 | 2601 | ||
2602 | cgroup_get(child); | ||
2602 | prepare_to_wait(&child->offline_waitq, &wait, | 2603 | prepare_to_wait(&child->offline_waitq, &wait, |
2603 | TASK_UNINTERRUPTIBLE); | 2604 | TASK_UNINTERRUPTIBLE); |
2604 | mutex_unlock(&cgroup_tree_mutex); | 2605 | mutex_unlock(&cgroup_tree_mutex); |
2605 | schedule(); | 2606 | schedule(); |
2606 | finish_wait(&child->offline_waitq, &wait); | 2607 | finish_wait(&child->offline_waitq, &wait); |
2608 | cgroup_put(child); | ||
2607 | goto retry; | 2609 | goto retry; |
2608 | } | 2610 | } |
2609 | 2611 | ||