cpumask: Cleanup more uses of CPU_MASK and NODE_MASK
[pandora-kernel.git] / kernel / cpuset.c
index 6868c1e..a1b61f4 100644 (file)
@@ -322,8 +322,8 @@ static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
  * Call without callback_mutex or task_lock() held.  May be
  * called with or without cgroup_mutex held.  Thanks in part to
  * 'the_top_cpuset_hack', the task's cpuset pointer will never
- * be NULL.  This routine also might acquire callback_mutex and
- * current->mm->mmap_sem during call.
+ * be NULL.  This routine also might acquire callback_mutex during
+ * call.
  *
  * Reading current->cpuset->mems_generation doesn't need task_lock
  * to guard the current->cpuset derefence, because it is guarded
@@ -1709,7 +1709,8 @@ static void remove_tasks_in_empty_cpuset(struct cpuset *cs)
         * has online cpus, so can't be empty).
         */
        parent = cs->parent;
-       while (cpus_empty(parent->cpus_allowed))
+       while (cpus_empty(parent->cpus_allowed) ||
+                       nodes_empty(parent->mems_allowed))
                parent = parent->parent;
 
        move_member_tasks_to_cpuset(cs, parent);
@@ -1741,7 +1742,6 @@ static void scan_for_empty_cpusets(const struct cpuset *root)
 
        list_add_tail((struct list_head *)&root->stack_list, &queue);
 
-       mutex_lock(&callback_mutex);
        while (!list_empty(&queue)) {
                cp = container_of(queue.next, struct cpuset, stack_list);
                list_del(queue.next);
@@ -1750,19 +1750,24 @@ static void scan_for_empty_cpusets(const struct cpuset *root)
                        list_add_tail(&child->stack_list, &queue);
                }
                cont = cp->css.cgroup;
+
+               /* Continue past cpusets with all cpus, mems online */
+               if (cpus_subset(cp->cpus_allowed, cpu_online_map) &&
+                   nodes_subset(cp->mems_allowed, node_states[N_HIGH_MEMORY]))
+                       continue;
+
                /* Remove offline cpus and mems from this cpuset. */
+               mutex_lock(&callback_mutex);
                cpus_and(cp->cpus_allowed, cp->cpus_allowed, cpu_online_map);
                nodes_and(cp->mems_allowed, cp->mems_allowed,
                                                node_states[N_HIGH_MEMORY]);
+               mutex_unlock(&callback_mutex);
+
+               /* Move tasks from the empty cpuset to a parent */
                if (cpus_empty(cp->cpus_allowed) ||
-                    nodes_empty(cp->mems_allowed)) {
-                       /* Move tasks from the empty cpuset to a parent */
-                       mutex_unlock(&callback_mutex);
+                    nodes_empty(cp->mems_allowed))
                        remove_tasks_in_empty_cpuset(cp);
-                       mutex_lock(&callback_mutex);
-               }
        }
-       mutex_unlock(&callback_mutex);
 }
 
 /*
@@ -2250,13 +2255,14 @@ const struct file_operations proc_cpuset_operations = {
 #endif /* CONFIG_PROC_PID_CPUSET */
 
 /* Display task cpus_allowed, mems_allowed in /proc/<pid>/status file. */
-char *cpuset_task_status_allowed(struct task_struct *task, char *buffer)
-{
-       buffer += sprintf(buffer, "Cpus_allowed:\t");
-       buffer += cpumask_scnprintf(buffer, PAGE_SIZE, task->cpus_allowed);
-       buffer += sprintf(buffer, "\n");
-       buffer += sprintf(buffer, "Mems_allowed:\t");
-       buffer += nodemask_scnprintf(buffer, PAGE_SIZE, task->mems_allowed);
-       buffer += sprintf(buffer, "\n");
-       return buffer;
+void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)
+{
+       seq_printf(m, "Cpus_allowed:\t");
+       m->count += cpumask_scnprintf(m->buf + m->count, m->size - m->count,
+                                       task->cpus_allowed);
+       seq_printf(m, "\n");
+       seq_printf(m, "Mems_allowed:\t");
+       m->count += nodemask_scnprintf(m->buf + m->count, m->size - m->count,
+                                       task->mems_allowed);
+       seq_printf(m, "\n");
 }