aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cpuset.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-01-07 21:08:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-08 11:31:11 -0500
commit2341d1b6598c7146d64a5050b53a72a5a819617f (patch)
tree1e278566d5fea4d2c02826b9ac0713ccd146fd92 /kernel/cpuset.c
parent5771f0a2236df69683e9abea87f35f522c97ff94 (diff)
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: Li Zefan <lizf@cn.fujitsu.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Mike Travis <travis@sgi.com> Cc: Paul Menage <menage@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r--kernel/cpuset.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index afa29cfc5bbb..1e32e6b380af 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1306,6 +1306,9 @@ static int fmeter_getrate(struct fmeter *fmp)
1306 return val; 1306 return val;
1307} 1307}
1308 1308
1309/* Protected by cgroup_lock */
1310static cpumask_var_t cpus_attach;
1311
1309/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */ 1312/* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */
1310static int cpuset_can_attach(struct cgroup_subsys *ss, 1313static int cpuset_can_attach(struct cgroup_subsys *ss,
1311 struct cgroup *cont, struct task_struct *tsk) 1314 struct cgroup *cont, struct task_struct *tsk)
@@ -1330,7 +1333,6 @@ static void cpuset_attach(struct cgroup_subsys *ss,
1330 struct cgroup *cont, struct cgroup *oldcont, 1333 struct cgroup *cont, struct cgroup *oldcont,
1331 struct task_struct *tsk) 1334 struct task_struct *tsk)
1332{ 1335{
1333 cpumask_t cpus;
1334 nodemask_t from, to; 1336 nodemask_t from, to;
1335 struct mm_struct *mm; 1337 struct mm_struct *mm;
1336 struct cpuset *cs = cgroup_cs(cont); 1338 struct cpuset *cs = cgroup_cs(cont);
@@ -1338,13 +1340,13 @@ static void cpuset_attach(struct cgroup_subsys *ss,
1338 int err; 1340 int err;
1339 1341
1340 if (cs == &top_cpuset) { 1342 if (cs == &top_cpuset) {
1341 cpus = cpu_possible_map; 1343 cpumask_copy(cpus_attach, cpu_possible_mask);
1342 } else { 1344 } else {
1343 mutex_lock(&callback_mutex); 1345 mutex_lock(&callback_mutex);
1344 guarantee_online_cpus(cs, &cpus); 1346 guarantee_online_cpus(cs, cpus_attach);
1345 mutex_unlock(&callback_mutex); 1347 mutex_unlock(&callback_mutex);
1346 } 1348 }
1347 err = set_cpus_allowed_ptr(tsk, &cpus); 1349 err = set_cpus_allowed_ptr(tsk, cpus_attach);
1348 if (err) 1350 if (err)
1349 return; 1351 return;
1350 1352
@@ -1357,7 +1359,6 @@ static void cpuset_attach(struct cgroup_subsys *ss,
1357 cpuset_migrate_mm(mm, &from, &to); 1359 cpuset_migrate_mm(mm, &from, &to);
1358 mmput(mm); 1360 mmput(mm);
1359 } 1361 }
1360
1361} 1362}
1362 1363
1363/* The various types of files and directories in a cpuset file system */ 1364/* The various types of files and directories in a cpuset file system */
@@ -1838,6 +1839,9 @@ int __init cpuset_init(void)
1838 if (err < 0) 1839 if (err < 0)
1839 return err; 1840 return err;
1840 1841
1842 if (!alloc_cpumask_var(&cpus_attach, GFP_KERNEL))
1843 BUG();
1844
1841 number_of_cpusets = 1; 1845 number_of_cpusets = 1;
1842 return 0; 1846 return 0;
1843} 1847}