Commit 5771f0a2 authored by Li Zefan's avatar Li Zefan Committed by Linus Torvalds

cpuset: remove on stack cpumask_t in cpuset_can_attach()

Impact: reduce stack usage

Just use cs->cpus_allowed, and no need to allocate a cpumask_var_t.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujistu.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: default avatarMike Travis <travis@sgi.com>
Cc: Paul Menage <menage@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5a7625df
...@@ -1311,20 +1311,19 @@ static int cpuset_can_attach(struct cgroup_subsys *ss, ...@@ -1311,20 +1311,19 @@ static int cpuset_can_attach(struct cgroup_subsys *ss,
struct cgroup *cont, struct task_struct *tsk) struct cgroup *cont, struct task_struct *tsk)
{ {
struct cpuset *cs = cgroup_cs(cont); struct cpuset *cs = cgroup_cs(cont);
int ret = 0;
if (cpus_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed)) if (cpus_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))
return -ENOSPC; return -ENOSPC;
if (tsk->flags & PF_THREAD_BOUND) {
cpumask_t mask;
if (tsk->flags & PF_THREAD_BOUND) {
mutex_lock(&callback_mutex); mutex_lock(&callback_mutex);
mask = cs->cpus_allowed; if (!cpus_equal(tsk->cpus_allowed, cs->cpus_allowed))
ret = -EINVAL;
mutex_unlock(&callback_mutex); mutex_unlock(&callback_mutex);
if (!cpus_equal(tsk->cpus_allowed, mask))
return -EINVAL;
} }
return security_task_setscheduler(tsk, 0, NULL); return ret < 0 ? ret : security_task_setscheduler(tsk, 0, NULL);
} }
static void cpuset_attach(struct cgroup_subsys *ss, static void cpuset_attach(struct cgroup_subsys *ss,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment