Commit 2341d1b6 authored by Li Zefan's avatar Li Zefan Committed by Linus Torvalds

cpuset: convert cpuset_attach() to use cpumask_var_t

Impact: reduce stack usage

Allocate a global cpumask_var_t at boot, and use it in cpuset_attach(), so
we won't fail cpuset_attach().
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.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 5771f0a2
...@@ -1306,6 +1306,9 @@ static int fmeter_getrate(struct fmeter *fmp) ...@@ -1306,6 +1306,9 @@ static int fmeter_getrate(struct fmeter *fmp)
return val; return val;
} }
/* Protected by cgroup_lock */
static cpumask_var_t cpus_attach;
/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */ /* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */
static int cpuset_can_attach(struct cgroup_subsys *ss, static int cpuset_can_attach(struct cgroup_subsys *ss,
struct cgroup *cont, struct task_struct *tsk) struct cgroup *cont, struct task_struct *tsk)
...@@ -1330,7 +1333,6 @@ static void cpuset_attach(struct cgroup_subsys *ss, ...@@ -1330,7 +1333,6 @@ static void cpuset_attach(struct cgroup_subsys *ss,
struct cgroup *cont, struct cgroup *oldcont, struct cgroup *cont, struct cgroup *oldcont,
struct task_struct *tsk) struct task_struct *tsk)
{ {
cpumask_t cpus;
nodemask_t from, to; nodemask_t from, to;
struct mm_struct *mm; struct mm_struct *mm;
struct cpuset *cs = cgroup_cs(cont); struct cpuset *cs = cgroup_cs(cont);
...@@ -1338,13 +1340,13 @@ static void cpuset_attach(struct cgroup_subsys *ss, ...@@ -1338,13 +1340,13 @@ static void cpuset_attach(struct cgroup_subsys *ss,
int err; int err;
if (cs == &top_cpuset) { if (cs == &top_cpuset) {
cpus = cpu_possible_map; cpumask_copy(cpus_attach, cpu_possible_mask);
} else { } else {
mutex_lock(&callback_mutex); mutex_lock(&callback_mutex);
guarantee_online_cpus(cs, &cpus); guarantee_online_cpus(cs, cpus_attach);
mutex_unlock(&callback_mutex); mutex_unlock(&callback_mutex);
} }
err = set_cpus_allowed_ptr(tsk, &cpus); err = set_cpus_allowed_ptr(tsk, cpus_attach);
if (err) if (err)
return; return;
...@@ -1357,7 +1359,6 @@ static void cpuset_attach(struct cgroup_subsys *ss, ...@@ -1357,7 +1359,6 @@ static void cpuset_attach(struct cgroup_subsys *ss,
cpuset_migrate_mm(mm, &from, &to); cpuset_migrate_mm(mm, &from, &to);
mmput(mm); mmput(mm);
} }
} }
/* The various types of files and directories in a cpuset file system */ /* The various types of files and directories in a cpuset file system */
...@@ -1838,6 +1839,9 @@ int __init cpuset_init(void) ...@@ -1838,6 +1839,9 @@ int __init cpuset_init(void)
if (err < 0) if (err < 0)
return err; return err;
if (!alloc_cpumask_var(&cpus_attach, GFP_KERNEL))
BUG();
number_of_cpusets = 1; number_of_cpusets = 1;
return 0; return 0;
} }
......
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