diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-09 15:59:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-09 15:59:24 -0500 |
commit | db0c2bf69aa095d4a6de7b1145f29fe9a7c0f6a3 (patch) | |
tree | 8f38957c01b18edddd44d49ecc3beeac08a20b4e /kernel/cpuset.c | |
parent | ac69e0928054ff29a5049902fb477f9c7605c773 (diff) | |
parent | 0d19ea866562e46989412a0676412fa0983c9ce7 (diff) |
Merge branch 'for-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
* 'for-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: (21 commits)
cgroup: fix to allow mounting a hierarchy by name
cgroup: move assignement out of condition in cgroup_attach_proc()
cgroup: Remove task_lock() from cgroup_post_fork()
cgroup: add sparse annotation to cgroup_iter_start() and cgroup_iter_end()
cgroup: mark cgroup_rmdir_waitq and cgroup_attach_proc() as static
cgroup: only need to check oldcgrp==newgrp once
cgroup: remove redundant get/put of task struct
cgroup: remove redundant get/put of old css_set from migrate
cgroup: Remove unnecessary task_lock before fetching css_set on migration
cgroup: Drop task_lock(parent) on cgroup_fork()
cgroups: remove redundant get/put of css_set from css_set_check_fetched()
resource cgroups: remove bogus cast
cgroup: kill subsys->can_attach_task(), pre_attach() and attach_task()
cgroup, cpuset: don't use ss->pre_attach()
cgroup: don't use subsys->can_attach_task() or ->attach_task()
cgroup: introduce cgroup_taskset and use it in subsys->can_attach(), cancel_attach() and attach()
cgroup: improve old cgroup handling in cgroup_attach_proc()
cgroup: always lock threadgroup during migration
threadgroup: extend threadgroup_lock() to cover exit and exec
threadgroup: rename signal->threadgroup_fork_lock to ->group_rwsem
...
Fix up conflict in kernel/cgroup.c due to commit e0197aae59e5: "cgroups:
fix a css_set not found bug in cgroup_attach_proc" that already
mentioned that the bug is fixed (differently) in Tejun's cgroup
patchset. This one, in other words.
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r-- | kernel/cpuset.c | 105 |
1 files changed, 48 insertions, 57 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 0b1712dba587..a09ac2b9a661 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -1389,79 +1389,73 @@ static int fmeter_getrate(struct fmeter *fmp) | |||
1389 | return val; | 1389 | return val; |
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | /* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */ | ||
1393 | static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cont, | ||
1394 | struct task_struct *tsk) | ||
1395 | { | ||
1396 | struct cpuset *cs = cgroup_cs(cont); | ||
1397 | |||
1398 | if (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed)) | ||
1399 | return -ENOSPC; | ||
1400 | |||
1401 | /* | ||
1402 | * Kthreads bound to specific cpus cannot be moved to a new cpuset; we | ||
1403 | * cannot change their cpu affinity and isolating such threads by their | ||
1404 | * set of allowed nodes is unnecessary. Thus, cpusets are not | ||
1405 | * applicable for such threads. This prevents checking for success of | ||
1406 | * set_cpus_allowed_ptr() on all attached tasks before cpus_allowed may | ||
1407 | * be changed. | ||
1408 | */ | ||
1409 | if (tsk->flags & PF_THREAD_BOUND) | ||
1410 | return -EINVAL; | ||
1411 | |||
1412 | return 0; | ||
1413 | } | ||
1414 | |||
1415 | static int cpuset_can_attach_task(struct cgroup *cgrp, struct task_struct *task) | ||
1416 | { | ||
1417 | return security_task_setscheduler(task); | ||
1418 | } | ||
1419 | |||
1420 | /* | 1392 | /* |
1421 | * Protected by cgroup_lock. The nodemasks must be stored globally because | 1393 | * Protected by cgroup_lock. The nodemasks must be stored globally because |
1422 | * dynamically allocating them is not allowed in pre_attach, and they must | 1394 | * dynamically allocating them is not allowed in can_attach, and they must |
1423 | * persist among pre_attach, attach_task, and attach. | 1395 | * persist until attach. |
1424 | */ | 1396 | */ |
1425 | static cpumask_var_t cpus_attach; | 1397 | static cpumask_var_t cpus_attach; |
1426 | static nodemask_t cpuset_attach_nodemask_from; | 1398 | static nodemask_t cpuset_attach_nodemask_from; |
1427 | static nodemask_t cpuset_attach_nodemask_to; | 1399 | static nodemask_t cpuset_attach_nodemask_to; |
1428 | 1400 | ||
1429 | /* Set-up work for before attaching each task. */ | 1401 | /* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */ |
1430 | static void cpuset_pre_attach(struct cgroup *cont) | 1402 | static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
1403 | struct cgroup_taskset *tset) | ||
1431 | { | 1404 | { |
1432 | struct cpuset *cs = cgroup_cs(cont); | 1405 | struct cpuset *cs = cgroup_cs(cgrp); |
1406 | struct task_struct *task; | ||
1407 | int ret; | ||
1408 | |||
1409 | if (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed)) | ||
1410 | return -ENOSPC; | ||
1411 | |||
1412 | cgroup_taskset_for_each(task, cgrp, tset) { | ||
1413 | /* | ||
1414 | * Kthreads bound to specific cpus cannot be moved to a new | ||
1415 | * cpuset; we cannot change their cpu affinity and | ||
1416 | * isolating such threads by their set of allowed nodes is | ||
1417 | * unnecessary. Thus, cpusets are not applicable for such | ||
1418 | * threads. This prevents checking for success of | ||
1419 | * set_cpus_allowed_ptr() on all attached tasks before | ||
1420 | * cpus_allowed may be changed. | ||
1421 | */ | ||
1422 | if (task->flags & PF_THREAD_BOUND) | ||
1423 | return -EINVAL; | ||
1424 | if ((ret = security_task_setscheduler(task))) | ||
1425 | return ret; | ||
1426 | } | ||
1433 | 1427 | ||
1428 | /* prepare for attach */ | ||
1434 | if (cs == &top_cpuset) | 1429 | if (cs == &top_cpuset) |
1435 | cpumask_copy(cpus_attach, cpu_possible_mask); | 1430 | cpumask_copy(cpus_attach, cpu_possible_mask); |
1436 | else | 1431 | else |
1437 | guarantee_online_cpus(cs, cpus_attach); | 1432 | guarantee_online_cpus(cs, cpus_attach); |
1438 | 1433 | ||
1439 | guarantee_online_mems(cs, &cpuset_attach_nodemask_to); | 1434 | guarantee_online_mems(cs, &cpuset_attach_nodemask_to); |
1440 | } | ||
1441 | |||
1442 | /* Per-thread attachment work. */ | ||
1443 | static void cpuset_attach_task(struct cgroup *cont, struct task_struct *tsk) | ||
1444 | { | ||
1445 | int err; | ||
1446 | struct cpuset *cs = cgroup_cs(cont); | ||
1447 | 1435 | ||
1448 | /* | 1436 | return 0; |
1449 | * can_attach beforehand should guarantee that this doesn't fail. | ||
1450 | * TODO: have a better way to handle failure here | ||
1451 | */ | ||
1452 | err = set_cpus_allowed_ptr(tsk, cpus_attach); | ||
1453 | WARN_ON_ONCE(err); | ||
1454 | |||
1455 | cpuset_change_task_nodemask(tsk, &cpuset_attach_nodemask_to); | ||
1456 | cpuset_update_task_spread_flag(cs, tsk); | ||
1457 | } | 1437 | } |
1458 | 1438 | ||
1459 | static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cont, | 1439 | static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
1460 | struct cgroup *oldcont, struct task_struct *tsk) | 1440 | struct cgroup_taskset *tset) |
1461 | { | 1441 | { |
1462 | struct mm_struct *mm; | 1442 | struct mm_struct *mm; |
1463 | struct cpuset *cs = cgroup_cs(cont); | 1443 | struct task_struct *task; |
1464 | struct cpuset *oldcs = cgroup_cs(oldcont); | 1444 | struct task_struct *leader = cgroup_taskset_first(tset); |
1445 | struct cgroup *oldcgrp = cgroup_taskset_cur_cgroup(tset); | ||
1446 | struct cpuset *cs = cgroup_cs(cgrp); | ||
1447 | struct cpuset *oldcs = cgroup_cs(oldcgrp); | ||
1448 | |||
1449 | cgroup_taskset_for_each(task, cgrp, tset) { | ||
1450 | /* | ||
1451 | * can_attach beforehand should guarantee that this doesn't | ||
1452 | * fail. TODO: have a better way to handle failure here | ||
1453 | */ | ||
1454 | WARN_ON_ONCE(set_cpus_allowed_ptr(task, cpus_attach)); | ||
1455 | |||
1456 | cpuset_change_task_nodemask(task, &cpuset_attach_nodemask_to); | ||
1457 | cpuset_update_task_spread_flag(cs, task); | ||
1458 | } | ||
1465 | 1459 | ||
1466 | /* | 1460 | /* |
1467 | * Change mm, possibly for multiple threads in a threadgroup. This is | 1461 | * Change mm, possibly for multiple threads in a threadgroup. This is |
@@ -1469,7 +1463,7 @@ static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cont, | |||
1469 | */ | 1463 | */ |
1470 | cpuset_attach_nodemask_from = oldcs->mems_allowed; | 1464 | cpuset_attach_nodemask_from = oldcs->mems_allowed; |
1471 | cpuset_attach_nodemask_to = cs->mems_allowed; | 1465 | cpuset_attach_nodemask_to = cs->mems_allowed; |
1472 | mm = get_task_mm(tsk); | 1466 | mm = get_task_mm(leader); |
1473 | if (mm) { | 1467 | if (mm) { |
1474 | mpol_rebind_mm(mm, &cpuset_attach_nodemask_to); | 1468 | mpol_rebind_mm(mm, &cpuset_attach_nodemask_to); |
1475 | if (is_memory_migrate(cs)) | 1469 | if (is_memory_migrate(cs)) |
@@ -1925,9 +1919,6 @@ struct cgroup_subsys cpuset_subsys = { | |||
1925 | .create = cpuset_create, | 1919 | .create = cpuset_create, |
1926 | .destroy = cpuset_destroy, | 1920 | .destroy = cpuset_destroy, |
1927 | .can_attach = cpuset_can_attach, | 1921 | .can_attach = cpuset_can_attach, |
1928 | .can_attach_task = cpuset_can_attach_task, | ||
1929 | .pre_attach = cpuset_pre_attach, | ||
1930 | .attach_task = cpuset_attach_task, | ||
1931 | .attach = cpuset_attach, | 1922 | .attach = cpuset_attach, |
1932 | .populate = cpuset_populate, | 1923 | .populate = cpuset_populate, |
1933 | .post_clone = cpuset_post_clone, | 1924 | .post_clone = cpuset_post_clone, |