diff options
author | Tejun Heo <tj@kernel.org> | 2014-02-13 06:58:39 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-02-13 06:58:39 -0500 |
commit | e406d1cfff6ab189c8676072d211809c94fecaf0 (patch) | |
tree | d8c9771025242f6a3a1c0b3e430fdb0bba50ce16 /kernel/cgroup.c | |
parent | 07bc356ed2950048d33d667e933e1b913c6e6b6d (diff) | |
download | lwn-e406d1cfff6ab189c8676072d211809c94fecaf0.tar.gz lwn-e406d1cfff6ab189c8676072d211809c94fecaf0.zip |
cgroup: reimplement cgroup_transfer_tasks() without using css_scan_tasks()
Reimplement cgroup_transfer_tasks() so that it repeatedly fetches the
first task in the cgroup and then tranfers it. This achieves the same
result without using css_scan_tasks() which is scheduled to be
removed.
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 | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index ec7746e5ded1..893b7b502e18 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2850,15 +2850,6 @@ int css_scan_tasks(struct cgroup_subsys_state *css, return 0; } -static void cgroup_transfer_one_task(struct task_struct *task, void *data) -{ - struct cgroup *new_cgroup = data; - - mutex_lock(&cgroup_mutex); - cgroup_attach_task(new_cgroup, task, false); - mutex_unlock(&cgroup_mutex); -} - /** * cgroup_trasnsfer_tasks - move tasks from one cgroup to another * @to: cgroup to which the tasks will be moved @@ -2866,8 +2857,26 @@ static void cgroup_transfer_one_task(struct task_struct *task, void *data) */ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from) { - return css_scan_tasks(&from->dummy_css, NULL, cgroup_transfer_one_task, - to, NULL); + struct css_task_iter it; + struct task_struct *task; + int ret = 0; + + do { + css_task_iter_start(&from->dummy_css, &it); + task = css_task_iter_next(&it); + if (task) + get_task_struct(task); + css_task_iter_end(&it); + + if (task) { + mutex_lock(&cgroup_mutex); + ret = cgroup_attach_task(to, task, false); + mutex_unlock(&cgroup_mutex); + put_task_struct(task); + } + } while (task && !ret); + + return ret; } /* |