aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cpuset.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-12-12 21:12:21 -0500
committerTejun Heo <tj@kernel.org>2011-12-12 21:12:21 -0500
commit2f7ee5691eecb67c8108b92001a85563ea336ac5 (patch)
tree18cf60ea8a463f4a6cd59c68926ba4357ae8ff4c /kernel/cpuset.c
parent134d33737f9015761c3832f6b268fae6274aac7f (diff)
cgroup: introduce cgroup_taskset and use it in subsys->can_attach(), cancel_attach() and attach()
Currently, there's no way to pass multiple tasks to cgroup_subsys methods necessitating the need for separate per-process and per-task methods. This patch introduces cgroup_taskset which can be used to pass multiple tasks and their associated cgroups to cgroup_subsys methods. Three methods - can_attach(), cancel_attach() and attach() - are converted to use cgroup_taskset. This unifies passed parameters so that all methods have access to all information. Conversions in this patchset are identical and don't introduce any behavior change. -v2: documentation updated as per Paul Menage's suggestion. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Paul Menage <paul@paulmenage.org> Acked-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: James Morris <jmorris@namei.org>
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r--kernel/cpuset.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 9fe58c46a42..512bd59e862 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1371,10 +1371,10 @@ static int fmeter_getrate(struct fmeter *fmp)
1371} 1371}
1372 1372
1373/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */ 1373/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */
1374static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cont, 1374static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
1375 struct task_struct *tsk) 1375 struct cgroup_taskset *tset)
1376{ 1376{
1377 struct cpuset *cs = cgroup_cs(cont); 1377 struct cpuset *cs = cgroup_cs(cgrp);
1378 1378
1379 if (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed)) 1379 if (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))
1380 return -ENOSPC; 1380 return -ENOSPC;
@@ -1387,7 +1387,7 @@ static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cont,
1387 * set_cpus_allowed_ptr() on all attached tasks before cpus_allowed may 1387 * set_cpus_allowed_ptr() on all attached tasks before cpus_allowed may
1388 * be changed. 1388 * be changed.
1389 */ 1389 */
1390 if (tsk->flags & PF_THREAD_BOUND) 1390 if (cgroup_taskset_first(tset)->flags & PF_THREAD_BOUND)
1391 return -EINVAL; 1391 return -EINVAL;
1392 1392
1393 return 0; 1393 return 0;
@@ -1437,12 +1437,14 @@ static void cpuset_attach_task(struct cgroup *cont, struct task_struct *tsk)
1437 cpuset_update_task_spread_flag(cs, tsk); 1437 cpuset_update_task_spread_flag(cs, tsk);
1438} 1438}
1439 1439
1440static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cont, 1440static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
1441 struct cgroup *oldcont, struct task_struct *tsk) 1441 struct cgroup_taskset *tset)
1442{ 1442{
1443 struct mm_struct *mm; 1443 struct mm_struct *mm;
1444 struct cpuset *cs = cgroup_cs(cont); 1444 struct task_struct *tsk = cgroup_taskset_first(tset);
1445 struct cpuset *oldcs = cgroup_cs(oldcont); 1445 struct cgroup *oldcgrp = cgroup_taskset_cur_cgroup(tset);
1446 struct cpuset *cs = cgroup_cs(cgrp);
1447 struct cpuset *oldcs = cgroup_cs(oldcgrp);
1446 1448
1447 /* 1449 /*
1448 * Change mm, possibly for multiple threads in a threadgroup. This is 1450 * Change mm, possibly for multiple threads in a threadgroup. This is