Skip to content

Commit 8fb3275

Browse files
committed
Fix numa_get_capacity
Id stored in memory target is physcial, not logical id so use hwloc_get_numanode_obj_by_os_index
1 parent 2a2680e commit 8fb3275

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/memory_targets/memory_target_numa.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "topology.h"
2222

2323
struct numa_memory_target_t {
24-
size_t id;
24+
size_t physical_id;
2525
};
2626

2727
static umf_result_t numa_initialize(void *params, void **memTarget) {
@@ -38,7 +38,7 @@ static umf_result_t numa_initialize(void *params, void **memTarget) {
3838
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
3939
}
4040

41-
numaTarget->id = config->id;
41+
numaTarget->physical_id = config->physical_id;
4242
*memTarget = numaTarget;
4343
return UMF_RESULT_SUCCESS;
4444
}
@@ -60,7 +60,7 @@ numa_targets_create_nodemask(struct numa_memory_target_t **targets,
6060
}
6161

6262
for (size_t i = 0; i < numTargets; i++) {
63-
if (hwloc_bitmap_set(bitmap, targets[i]->id)) {
63+
if (hwloc_bitmap_set(bitmap, targets[i]->physical_id)) {
6464
hwloc_bitmap_free(bitmap);
6565
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
6666
}
@@ -170,7 +170,7 @@ static umf_result_t numa_clone(void *memTarget, void **outMemTarget) {
170170
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
171171
}
172172

173-
newNumaTarget->id = numaTarget->id;
173+
newNumaTarget->physical_id = numaTarget->physical_id;
174174
*outMemTarget = newNumaTarget;
175175
return UMF_RESULT_SUCCESS;
176176
}
@@ -181,9 +181,8 @@ static umf_result_t numa_get_capacity(void *memTarget, size_t *capacity) {
181181
return UMF_RESULT_ERROR_NOT_SUPPORTED;
182182
}
183183

184-
hwloc_obj_t numaNode =
185-
hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE,
186-
((struct numa_memory_target_t *)memTarget)->id);
184+
hwloc_obj_t numaNode = hwloc_get_numanode_obj_by_os_index(
185+
topology, ((struct numa_memory_target_t *)memTarget)->physical_id);
187186
if (!numaNode) {
188187
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
189188
}

src/memory_targets/memory_target_numa.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern "C" {
2121
#endif
2222

2323
struct umf_numa_memory_target_config_t {
24-
size_t id;
24+
size_t physical_id;
2525
};
2626

2727
extern struct umf_memory_target_ops_t UMF_MEMORY_TARGET_NUMA_OPS;

test/memspaces/memspace_host_all.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ TEST_F(numaNodesTest, memspaceGet) {
2828
struct umf_numa_memory_target_config_t *numaTargetCfg =
2929
(struct umf_numa_memory_target_config_t *)hMemspace->nodes[i]->priv;
3030
UT_ASSERT(std::find(nodeIds.begin(), nodeIds.end(),
31-
numaTargetCfg->id) != nodeIds.end());
31+
numaTargetCfg->physical_id) != nodeIds.end());
3232
}
3333
}
3434

0 commit comments

Comments
 (0)