]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
core: fix support for Misc objects added by par...
authorBrice Goglin <brice.goglin@inria.fr>
Mon, 24 Jun 2013 09:59:38 +0000 (09:59 +0000)
committerBrice Goglin <brice.goglin@inria.fr>
Mon, 24 Jun 2013 09:59:38 +0000 (09:59 +0000)
core: fix support for Misc objects added by parent

Looks like nobody ever tried to load a XML that contains a Misc
added by parent, it has been broken for ever.

When added by cpuset, Misc get a cpuset as any object. Nothing to do.
When added by parent, they become a new leaf, so they need either empty
or NULL sets. Empty sets require lots of hacks to be properly handled by
the core (so that they don't get ignored). So we keep using NULL sets
instead and just fix a couple places to properly handle them (like I/O).

By the way, cleanup the addition of default object sets.

Thanks to Jirka Hladky for the report.

This commit was SVN r5710.

src/topology.c

index e48bb8110fe6906c37f2980c2f85aa1b7822815c..8fad8dc213053c0171a8eab356c519730696bbc7 100644 (file)
@@ -1205,11 +1205,18 @@ add_default_object_sets(hwloc_obj_t obj, int parent_has_sets)
   if (hwloc_obj_type_is_io(obj->type))
     return;
 
-  if (parent_has_sets || obj->cpuset) {
-    /* if the parent has non-NULL sets, or if the object has non-NULL cpusets,
-     * it must have non-NULL nodesets
-     */
+  if (parent_has_sets && obj->type != HWLOC_OBJ_MISC) {
+    /* non-MISC object must have cpuset if parent has one. */
     assert(obj->cpuset);
+  }
+
+  /* other sets must be consistent with main cpuset:
+   * check cpusets and add nodesets if needed.
+   *
+   * MISC may have no sets at all (if added by parent), or usual ones (if added by cpuset),
+   * but that's not easy to detect, so just make sure sets are consistent as usual.
+   */
+  if (obj->cpuset) {
     assert(obj->online_cpuset);
     assert(obj->complete_cpuset);
     assert(obj->allowed_cpuset);
@@ -1220,9 +1227,9 @@ add_default_object_sets(hwloc_obj_t obj, int parent_has_sets)
     if (!obj->allowed_nodeset)
       obj->allowed_nodeset = hwloc_bitmap_alloc_full();
   } else {
-    /* parent has no sets and object has NULL cpusets,
-     * it must have NULL nodesets
-     */
+    assert(!obj->online_cpuset);
+    assert(!obj->complete_cpuset);
+    assert(!obj->allowed_cpuset);
     assert(!obj->nodeset);
     assert(!obj->complete_nodeset);
     assert(!obj->allowed_nodeset);
@@ -1516,7 +1523,7 @@ remove_empty(hwloc_topology_t topology, hwloc_obj_t *pobj)
 
   if (obj->type != HWLOC_OBJ_NODE
       && !obj->first_child /* only remove if all children were removed above, so that we don't remove parents of NUMAnode */
-      && !hwloc_obj_type_is_io(obj->type)
+      && !hwloc_obj_type_is_io(obj->type) && obj->type != HWLOC_OBJ_MISC
       && obj->cpuset /* don't remove if no cpuset at all, there's likely a good reason why it's different from having an empty cpuset */
       && hwloc_bitmap_iszero(obj->cpuset)) {
     /* Remove empty children */