aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 4936d8886b4f..82288088f6a5 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1850,14 +1850,12 @@ static int cgroup_task_migrate(struct cgroup *cgrp, struct cgroup *oldcgrp,
1850 struct css_set *newcg; 1850 struct css_set *newcg;
1851 1851
1852 /* 1852 /*
1853 * get old css_set. We are synchronized through threadgroup_lock() 1853 * We are synchronized through threadgroup_lock() against PF_EXITING
1854 * against PF_EXITING setting such that we can't race against 1854 * setting such that we can't race against cgroup_exit() changing the
1855 * cgroup_exit() changing the css_set to init_css_set and dropping the 1855 * css_set to init_css_set and dropping the old one.
1856 * old one.
1857 */ 1856 */
1858 WARN_ON_ONCE(tsk->flags & PF_EXITING); 1857 WARN_ON_ONCE(tsk->flags & PF_EXITING);
1859 oldcg = tsk->cgroups; 1858 oldcg = tsk->cgroups;
1860 get_css_set(oldcg);
1861 1859
1862 /* locate or allocate a new css_set for this task. */ 1860 /* locate or allocate a new css_set for this task. */
1863 if (guarantee) { 1861 if (guarantee) {
@@ -1872,12 +1870,9 @@ static int cgroup_task_migrate(struct cgroup *cgrp, struct cgroup *oldcgrp,
1872 might_sleep(); 1870 might_sleep();
1873 /* find_css_set will give us newcg already referenced. */ 1871 /* find_css_set will give us newcg already referenced. */
1874 newcg = find_css_set(oldcg, cgrp); 1872 newcg = find_css_set(oldcg, cgrp);
1875 if (!newcg) { 1873 if (!newcg)
1876 put_css_set(oldcg);
1877 return -ENOMEM; 1874 return -ENOMEM;
1878 }
1879 } 1875 }
1880 put_css_set(oldcg);
1881 1876
1882 task_lock(tsk); 1877 task_lock(tsk);
1883 rcu_assign_pointer(tsk->cgroups, newcg); 1878 rcu_assign_pointer(tsk->cgroups, newcg);
@@ -2186,18 +2181,11 @@ int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
2186 * init_css_set. 2181 * init_css_set.
2187 */ 2182 */
2188 oldcg = tc->task->cgroups; 2183 oldcg = tc->task->cgroups;
2189 get_css_set(oldcg); 2184
2190 /* see if the new one for us is already in the list? */ 2185 /* if we don't already have it in the list get a new one */
2191 if (css_set_check_fetched(cgrp, tc->task, oldcg, &newcg_list)) { 2186 if (!css_set_check_fetched(cgrp, tc->task, oldcg, &newcg_list))
2192 /* was already there, nothing to do. */ 2187 if (retval = css_set_prefetch(cgrp, oldcg, &newcg_list))
2193 put_css_set(oldcg);
2194 } else {
2195 /* we don't already have it. get new one. */
2196 retval = css_set_prefetch(cgrp, oldcg, &newcg_list);
2197 put_css_set(oldcg);
2198 if (retval)
2199 goto out_list_teardown; 2188 goto out_list_teardown;
2200 }
2201 } 2189 }
2202 2190
2203 /* 2191 /*