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 | |
parent | 07bc356ed2950048d33d667e933e1b913c6e6b6d (diff) |
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>
-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, | |||
2850 | return 0; | 2850 | return 0; |
2851 | } | 2851 | } |
2852 | 2852 | ||
2853 | static void cgroup_transfer_one_task(struct task_struct *task, void *data) | ||
2854 | { | ||
2855 | struct cgroup *new_cgroup = data; | ||
2856 | |||
2857 | mutex_lock(&cgroup_mutex); | ||
2858 | cgroup_attach_task(new_cgroup, task, false); | ||
2859 | mutex_unlock(&cgroup_mutex); | ||
2860 | } | ||
2861 | |||
2862 | /** | 2853 | /** |
2863 | * cgroup_trasnsfer_tasks - move tasks from one cgroup to another | 2854 | * cgroup_trasnsfer_tasks - move tasks from one cgroup to another |
2864 | * @to: cgroup to which the tasks will be moved | 2855 | * @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) | |||
2866 | */ | 2857 | */ |
2867 | int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from) | 2858 | int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from) |
2868 | { | 2859 | { |
2869 | return css_scan_tasks(&from->dummy_css, NULL, cgroup_transfer_one_task, | 2860 | struct css_task_iter it; |
2870 | to, NULL); | 2861 | struct task_struct *task; |
2862 | int ret = 0; | ||
2863 | |||
2864 | do { | ||
2865 | css_task_iter_start(&from->dummy_css, &it); | ||
2866 | task = css_task_iter_next(&it); | ||
2867 | if (task) | ||
2868 | get_task_struct(task); | ||
2869 | css_task_iter_end(&it); | ||
2870 | |||
2871 | if (task) { | ||
2872 | mutex_lock(&cgroup_mutex); | ||
2873 | ret = cgroup_attach_task(to, task, false); | ||
2874 | mutex_unlock(&cgroup_mutex); | ||
2875 | put_task_struct(task); | ||
2876 | } | ||
2877 | } while (task && !ret); | ||
2878 | |||
2879 | return ret; | ||
2871 | } | 2880 | } |
2872 | 2881 | ||
2873 | /* | 2882 | /* |