mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
cpusets: prevent PF_THREAD_BOUND tasks from attaching to non-root cpusets
Kthreads that have the PF_THREAD_BOUND bit set in their flags are bound to a specific cpu. Thus, their set of allowed cpus shall not change. This patch prevents such threads from attaching to non-root cpusets. They do not have mempolicies that restrict them to a subset of system nodes and, since their cpumask may never change, they cannot use any of the features of cpusets. The tasks will forever be a member of the root cpuset and will be returned when listing the tasks attached to that cpuset. Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Dhaval Giani <dhaval@linux.vnet.ibm.com> Signed-off-by: David Rientjes <rientjes@google.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
db7f47cf48
commit
6d7b2f5f9e
1 changed files with 11 additions and 8 deletions
|
@ -1342,19 +1342,22 @@ static int cpuset_can_attach(struct cgroup_subsys *ss,
|
|||
struct cgroup *cont, struct task_struct *tsk)
|
||||
{
|
||||
struct cpuset *cs = cgroup_cs(cont);
|
||||
int ret = 0;
|
||||
|
||||
if (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))
|
||||
return -ENOSPC;
|
||||
|
||||
if (tsk->flags & PF_THREAD_BOUND) {
|
||||
mutex_lock(&callback_mutex);
|
||||
if (!cpumask_equal(&tsk->cpus_allowed, cs->cpus_allowed))
|
||||
ret = -EINVAL;
|
||||
mutex_unlock(&callback_mutex);
|
||||
}
|
||||
/*
|
||||
* Kthreads bound to specific cpus cannot be moved to a new cpuset; we
|
||||
* cannot change their cpu affinity and isolating such threads by their
|
||||
* set of allowed nodes is unnecessary. Thus, cpusets are not
|
||||
* applicable for such threads. This prevents checking for success of
|
||||
* set_cpus_allowed_ptr() on all attached tasks before cpus_allowed may
|
||||
* be changed.
|
||||
*/
|
||||
if (tsk->flags & PF_THREAD_BOUND)
|
||||
return -EINVAL;
|
||||
|
||||
return ret < 0 ? ret : security_task_setscheduler(tsk, 0, NULL);
|
||||
return security_task_setscheduler(tsk, 0, NULL);
|
||||
}
|
||||
|
||||
static void cpuset_attach(struct cgroup_subsys *ss,
|
||||
|
|
Loading…
Reference in a new issue