Skip to content

Commit

Permalink
restrict: reorder children when modified
Browse files Browse the repository at this point in the history
If we first bit of the cpuset of some children increases during restrict(),
these children might become out-of-order.

Example:
  Core P#0
    PU P#0
    PU P#2
  Core P#1
    PU P#1
    PU P#3
If restrict() removes PU P#0, Cores must be swapped because of
their updated cpusets.

In v2.x, reordering might also be needed for memory children
but it's so unlikely and harmless that we don't do it yet.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Oct 12, 2018
1 parent fabd649 commit a0cf079
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hwloc/topology.c
Expand Up @@ -3683,8 +3683,13 @@ restrict_object_by_cpuset(hwloc_topology_t topology, unsigned long flags, hwloc_
if (modified) {
for_each_child_safe(child, obj, pchild)
restrict_object_by_cpuset(topology, flags, pchild, droppedcpuset, droppednodeset);
/* if some hwloc_bitmap_first(child->complete_cpuset) changed, children might need to be reordered */
hwloc__reorder_children(obj);

for_each_memory_child_safe(child, obj, pchild)
restrict_object_by_cpuset(topology, flags, pchild, droppedcpuset, droppednodeset);
/* local NUMA nodes have the same cpusets, no need to reorder them */

/* Nothing to restrict under I/O or Misc */
}

Expand Down Expand Up @@ -3744,8 +3749,15 @@ restrict_object_by_nodeset(hwloc_topology_t topology, unsigned long flags, hwloc
if (modified) {
for_each_child_safe(child, obj, pchild)
restrict_object_by_nodeset(topology, flags, pchild, droppedcpuset, droppednodeset);
if (flags & HWLOC_RESTRICT_FLAG_REMOVE_MEMLESS)
/* cpuset may have changed above where some NUMA nodes were removed.
* if some hwloc_bitmap_first(child->complete_cpuset) changed, children might need to be reordered */
hwloc__reorder_children(obj);

for_each_memory_child_safe(child, obj, pchild)
restrict_object_by_nodeset(topology, flags, pchild, droppedcpuset, droppednodeset);
/* FIXME: we may have to reorder CPU-less groups of NUMA nodes if some of their nodes were removed */

/* Nothing to restrict under I/O or Misc */
}

Expand Down

0 comments on commit a0cf079

Please sign in to comment.