aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cpuset.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-12-12 21:12:22 -0500
committerTejun Heo <tj@kernel.org>2011-12-12 21:12:22 -0500
commit94196f51c1ee5bbad674de28c682b17d78adb8e6 (patch)
treea4965645000e9766f06ee7b5eb2bab098cde0f8c /kernel/cpuset.c
parentbb9d97b6dffa10cec5e1ce9adbce60f3c2b5eabc (diff)
cgroup, cpuset: don't use ss->pre_attach()
->pre_attach() is supposed to be called before migration, which is observed during process migration but task migration does it the other way around. The only ->pre_attach() user is cpuset which can do the same operaitons in ->can_attach(). Collapse cpuset_pre_attach() into cpuset_can_attach(). -v2: Patch contamination from later patch removed. Spotted by Paul Menage. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Paul Menage <paul@paulmenage.org> Cc: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r--kernel/cpuset.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 9a8a61301524..42e568306382 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1370,6 +1370,15 @@ static int fmeter_getrate(struct fmeter *fmp)
1370 return val; 1370 return val;
1371} 1371}
1372 1372
1373/*
1374 * Protected by cgroup_lock. The nodemasks must be stored globally because
1375 * dynamically allocating them is not allowed in can_attach, and they must
1376 * persist until attach.
1377 */
1378static cpumask_var_t cpus_attach;
1379static nodemask_t cpuset_attach_nodemask_from;
1380static nodemask_t cpuset_attach_nodemask_to;
1381
1373/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */ 1382/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */
1374static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 1383static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
1375 struct cgroup_taskset *tset) 1384 struct cgroup_taskset *tset)
@@ -1396,29 +1405,16 @@ static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
1396 if ((ret = security_task_setscheduler(task))) 1405 if ((ret = security_task_setscheduler(task)))
1397 return ret; 1406 return ret;
1398 } 1407 }
1399 return 0;
1400}
1401
1402/*
1403 * Protected by cgroup_lock. The nodemasks must be stored globally because
1404 * dynamically allocating them is not allowed in pre_attach, and they must
1405 * persist among pre_attach, and attach.
1406 */
1407static cpumask_var_t cpus_attach;
1408static nodemask_t cpuset_attach_nodemask_from;
1409static nodemask_t cpuset_attach_nodemask_to;
1410
1411/* Set-up work for before attaching each task. */
1412static void cpuset_pre_attach(struct cgroup *cont)
1413{
1414 struct cpuset *cs = cgroup_cs(cont);
1415 1408
1409 /* prepare for attach */
1416 if (cs == &top_cpuset) 1410 if (cs == &top_cpuset)
1417 cpumask_copy(cpus_attach, cpu_possible_mask); 1411 cpumask_copy(cpus_attach, cpu_possible_mask);
1418 else 1412 else
1419 guarantee_online_cpus(cs, cpus_attach); 1413 guarantee_online_cpus(cs, cpus_attach);
1420 1414
1421 guarantee_online_mems(cs, &cpuset_attach_nodemask_to); 1415 guarantee_online_mems(cs, &cpuset_attach_nodemask_to);
1416
1417 return 0;
1422} 1418}
1423 1419
1424static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 1420static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
@@ -1904,7 +1900,6 @@ struct cgroup_subsys cpuset_subsys = {
1904 .create = cpuset_create, 1900 .create = cpuset_create,
1905 .destroy = cpuset_destroy, 1901 .destroy = cpuset_destroy,
1906 .can_attach = cpuset_can_attach, 1902 .can_attach = cpuset_can_attach,
1907 .pre_attach = cpuset_pre_attach,
1908 .attach = cpuset_attach, 1903 .attach = cpuset_attach,
1909 .populate = cpuset_populate, 1904 .populate = cpuset_populate,
1910 .post_clone = cpuset_post_clone, 1905 .post_clone = cpuset_post_clone,