Commit b4501295 authored by Paul Jackson's avatar Paul Jackson Committed by Linus Torvalds

hotplug cpu move tasks in empty cpusets - refinements

- Narrow the scope of callback_mutex in scan_for_empty_cpusets().

- Avoid rewriting the cpus, mems of cpusets except when it is likely that
  we'll be changing them.

- Have remove_tasks_in_empty_cpuset() also check for empty mems.
Signed-off-by: default avatarPaul Jackson <pj@sgi.com>
Acked-by: default avatarCliff Wickman <cpw@sgi.com>
Cc: David Rientjes <rientjes@google.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 c8d9c90c
...@@ -1709,7 +1709,8 @@ static void remove_tasks_in_empty_cpuset(struct cpuset *cs) ...@@ -1709,7 +1709,8 @@ static void remove_tasks_in_empty_cpuset(struct cpuset *cs)
* has online cpus, so can't be empty). * has online cpus, so can't be empty).
*/ */
parent = cs->parent; parent = cs->parent;
while (cpus_empty(parent->cpus_allowed)) while (cpus_empty(parent->cpus_allowed) ||
nodes_empty(parent->mems_allowed))
parent = parent->parent; parent = parent->parent;
move_member_tasks_to_cpuset(cs, parent); move_member_tasks_to_cpuset(cs, parent);
...@@ -1741,7 +1742,6 @@ static void scan_for_empty_cpusets(const struct cpuset *root) ...@@ -1741,7 +1742,6 @@ static void scan_for_empty_cpusets(const struct cpuset *root)
list_add_tail((struct list_head *)&root->stack_list, &queue); list_add_tail((struct list_head *)&root->stack_list, &queue);
mutex_lock(&callback_mutex);
while (!list_empty(&queue)) { while (!list_empty(&queue)) {
cp = container_of(queue.next, struct cpuset, stack_list); cp = container_of(queue.next, struct cpuset, stack_list);
list_del(queue.next); list_del(queue.next);
...@@ -1750,19 +1750,24 @@ static void scan_for_empty_cpusets(const struct cpuset *root) ...@@ -1750,19 +1750,24 @@ static void scan_for_empty_cpusets(const struct cpuset *root)
list_add_tail(&child->stack_list, &queue); list_add_tail(&child->stack_list, &queue);
} }
cont = cp->css.cgroup; 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. */ /* Remove offline cpus and mems from this cpuset. */
mutex_lock(&callback_mutex);
cpus_and(cp->cpus_allowed, cp->cpus_allowed, cpu_online_map); cpus_and(cp->cpus_allowed, cp->cpus_allowed, cpu_online_map);
nodes_and(cp->mems_allowed, cp->mems_allowed, nodes_and(cp->mems_allowed, cp->mems_allowed,
node_states[N_HIGH_MEMORY]); node_states[N_HIGH_MEMORY]);
if (cpus_empty(cp->cpus_allowed) ||
nodes_empty(cp->mems_allowed)) {
/* Move tasks from the empty cpuset to a parent */
mutex_unlock(&callback_mutex); mutex_unlock(&callback_mutex);
/* Move tasks from the empty cpuset to a parent */
if (cpus_empty(cp->cpus_allowed) ||
nodes_empty(cp->mems_allowed))
remove_tasks_in_empty_cpuset(cp); remove_tasks_in_empty_cpuset(cp);
mutex_lock(&callback_mutex);
}
} }
mutex_unlock(&callback_mutex);
} }
/* /*
......
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