Skip to content

Commit 02eaabc

Browse files
committed
core: fix the updating of total_memory in hwloc_topology_insert_group_object()
Objects might get merged, update the remaining one, not the original one. If merged with another group, there's no need to save total_memory during the merge because we'll recompute it in hwloc_topology_insert_group_object() anyway. Fixes 577b327 Signed-off-by: Brice Goglin <[email protected]>
1 parent c160398 commit 02eaabc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

hwloc/topology.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ hwloc_replace_linked_object(hwloc_obj_t old, hwloc_obj_t new)
646646
new->memory_first_child = old->memory_first_child;
647647
new->io_first_child = old->io_first_child;
648648
new->misc_first_child = old->misc_first_child;
649-
new->total_memory = old->total_memory;
650649
/* copy new contents to old now that tree pointers are OK */
651650
memcpy(old, new, sizeof(*old));
652651
/* clear new to that we may free it */
@@ -2025,11 +2024,11 @@ hwloc_topology_insert_group_object(struct hwloc_topology *topology, hwloc_obj_t
20252024
return NULL;
20262025

20272026
/* Compute group total_memory. */
2028-
obj->total_memory = 0;
2029-
for_each_child(child, obj)
2030-
obj->total_memory += child->total_memory;
2031-
for_each_memory_child(child, obj)
2032-
obj->total_memory += child->total_memory;
2027+
res->total_memory = 0;
2028+
for_each_child(child, res)
2029+
res->total_memory += child->total_memory;
2030+
for_each_memory_child(child, res)
2031+
res->total_memory += child->total_memory;
20332032

20342033
hwloc_propagate_symmetric_subtree(topology, topology->levels[0][0]);
20352034
hwloc_set_group_depth(topology);

0 commit comments

Comments
 (0)