aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cpuset.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-03-19 16:45:20 -0400
committerTejun Heo <tj@kernel.org>2013-03-19 16:45:20 -0400
commit14a40ffccd6163bbcd1d6f32b28a88ffe6149fc6 (patch)
treeeb61e5bf7b64c3e67f3e33fe6b07fde4ee1d4d43 /kernel/cpuset.c
parent2e109a2855bf6cf675a8b74dbd89b6492e8def42 (diff)
sched: replace PF_THREAD_BOUND with PF_NO_SETAFFINITY
PF_THREAD_BOUND was originally used to mark kernel threads which were bound to a specific CPU using kthread_bind() and a task with the flag set allows cpus_allowed modifications only to itself. Workqueue is currently abusing it to prevent userland from meddling with cpus_allowed of workqueue workers. What we need is a flag to prevent userland from messing with cpus_allowed of certain kernel tasks. In kernel, anyone can (incorrectly) squash the flag, and, for worker-type usages, restricting cpus_allowed modification to the task itself doesn't provide meaningful extra proection as other tasks can inject work items to the task anyway. This patch replaces PF_THREAD_BOUND with PF_NO_SETAFFINITY. sched_setaffinity() checks the flag and return -EINVAL if set. set_cpus_allowed_ptr() is no longer affected by the flag. This will allow simplifying workqueue worker CPU affinity management. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r--kernel/cpuset.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 4f9dfe43ecbd..f22e94792707 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1388,16 +1388,16 @@ static int cpuset_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
1388 1388
1389 cgroup_taskset_for_each(task, cgrp, tset) { 1389 cgroup_taskset_for_each(task, cgrp, tset) {
1390 /* 1390 /*
1391 * Kthreads bound to specific cpus cannot be moved to a new 1391 * Kthreads which disallow setaffinity shouldn't be moved
1392 * cpuset; we cannot change their cpu affinity and 1392 * to a new cpuset; we don't want to change their cpu
1393 * isolating such threads by their set of allowed nodes is 1393 * affinity and isolating such threads by their set of
1394 * unnecessary. Thus, cpusets are not applicable for such 1394 * allowed nodes is unnecessary. Thus, cpusets are not
1395 * threads. This prevents checking for success of 1395 * applicable for such threads. This prevents checking for
1396 * set_cpus_allowed_ptr() on all attached tasks before 1396 * success of set_cpus_allowed_ptr() on all attached tasks
1397 * cpus_allowed may be changed. 1397 * before cpus_allowed may be changed.
1398 */ 1398 */
1399 ret = -EINVAL; 1399 ret = -EINVAL;
1400 if (task->flags & PF_THREAD_BOUND) 1400 if (task->flags & PF_NO_SETAFFINITY)
1401 goto out_unlock; 1401 goto out_unlock;
1402 ret = security_task_setscheduler(task); 1402 ret = security_task_setscheduler(task);
1403 if (ret) 1403 if (ret)