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 */
 static int cpuset_can_attach(struct cgroup_subsys *ss,
                             struct cgroup *cont, struct task_struct *tsk)
                          struct cgroup *cont, struct cgroup *oldcont,
                          struct task_struct *tsk)
 {
-       cpumask_t cpus;
        nodemask_t from, to;
        struct mm_struct *mm;
        struct cpuset *cs = cgroup_cs(cont);
        int err;
 
        if (cs == &top_cpuset) {
-               cpus = cpu_possible_map;
+               cpumask_copy(cpus_attach, cpu_possible_mask);
        } else {
                mutex_lock(&callback_mutex);
-               guarantee_online_cpus(cs, &cpus);
+               guarantee_online_cpus(cs, cpus_attach);
                mutex_unlock(&callback_mutex);
        }
-       err = set_cpus_allowed_ptr(tsk, &cpus);
+       err = set_cpus_allowed_ptr(tsk, cpus_attach);
        if (err)
                return;
 
                        cpuset_migrate_mm(mm, &from, &to);
                mmput(mm);
        }
-
 }
 
 /* The various types of files and directories in a cpuset file system */
        if (err < 0)
                return err;
 
+       if (!alloc_cpumask_var(&cpus_attach, GFP_KERNEL))
+               BUG();
+
        number_of_cpusets = 1;
        return 0;
 }