Skip to content

Commit f0eeb3a

Browse files
committed
utils/calc: fix searching CPU objects below heterogeneous NUMA
socket:0.numa:0.core:0 looks for first core whose cpuset and nodeset are included in socket:0.numa:0. This fails on heterogeneous memory machines since this core may have 2 local NUMAs in its nodeset, hence not included in socket:0.numa:0's nodeset. Fix this by checking if the nodeset intersects instead of being included. Note that the empty bitmap is isincluded in any bitmap, while it doesn't intersect with anything, hence we have to check empty nodesets too. Thanks to Antoine Morvan for the report. Signed-off-by: Brice Goglin <[email protected]>
1 parent c129793 commit f0eeb3a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

utils/hwloc/hwloc-calc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2009 CNRS
3-
* Copyright © 2009-2022 Inria. All rights reserved.
3+
* Copyright © 2009-2023 Inria. All rights reserved.
44
* Copyright © 2009-2012 Université Bordeaux
55
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
66
* See COPYING in top-level directory.
@@ -88,7 +88,7 @@ hwloc_calc_get_nbobjs_inside_sets_by_depth(struct hwloc_calc_location_context_s
8888
while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) {
8989
if (!hwloc_bitmap_isincluded(obj->cpuset, cpuset))
9090
continue;
91-
if (!hwloc_bitmap_isincluded(obj->nodeset, nodeset))
91+
if (!hwloc_bitmap_iszero(obj->nodeset) && !hwloc_bitmap_intersects(obj->nodeset, nodeset))
9292
continue;
9393
if (hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_iszero(obj->nodeset))
9494
/* ignore objects with empty sets (both can be empty when outside of cgroup) */
@@ -117,7 +117,7 @@ hwloc_calc_get_obj_inside_sets_by_depth(struct hwloc_calc_location_context_s *lc
117117
while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) {
118118
if (!hwloc_bitmap_isincluded(obj->cpuset, cpuset))
119119
continue;
120-
if (!hwloc_bitmap_isincluded(obj->nodeset, nodeset))
120+
if (!hwloc_bitmap_iszero(obj->nodeset) && !hwloc_bitmap_intersects(obj->nodeset, nodeset))
121121
continue;
122122
if (hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_iszero(obj->nodeset))
123123
/* ignore objects with empty sets (both can be empty when outside of cgroup) */

utils/hwloc/test-hwloc-calc.output

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ PU:22_PU:23_Core:6_Core:7_Group0:2
130130
# Converting NUMA Nodes from logical to physical
131131
0,2
132132

133+
# Search cores within single NUMA when they have multiple local NUMA nodes
134+
0x00000060
135+
133136
# Physical output of NUMA Nodes when out-of-order in the topology
134137
2,1
135138

utils/hwloc/test-hwloc-calc.sh.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ set -e
181181
$calc --if synthetic --input "node:4 core:4 pu:4" --ni 0x5 -I node --po
182182
echo
183183

184+
echo "# Search cores within single NUMA when they have multiple local NUMA nodes"
185+
$calc --if synthetic --input "pack:2 [numa] [numa] core:4 pu:1" sock:1.numa:1.core:1-2
186+
echo
187+
184188
echo "# Physical output of NUMA Nodes when out-of-order in the topology"
185189
$calc --if synthetic --input "node:4(indexes=3,2,1,0) pu:2" node:1-2 --po -I node
186190
echo

0 commit comments

Comments
 (0)