Skip to content

Remove allocsSpreadAcrossAllNumaNodes test case #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions test/memspaces/memspace_host_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,91 +152,3 @@ TEST_F(memspaceHostAllProviderTest, hostAllDefaults) {
UT_ASSERTeq(ret, UMF_RESULT_SUCCESS);
umfMemoryProviderDestroy(hProvider);
}

TEST_F(memspaceHostAllProviderTest, allocsSpreadAcrossAllNumaNodes) {
// This testcase is unsuitable for TSan.
#ifdef __SANITIZE_THREAD__
GTEST_SKIP();
#endif

// Arbitrary allocation size, should be big enough to avoid unnecessarily
// prolonging the test execution.
size_t size = SIZE_4M;
size_t alignment = 0;
// Unallocated memory space that has to be left in an attempt to avoid OOM
// killer - 512MB.
size_t remainingSpace = SIZE_4M * 128;

long long numaCombinedFreeSize = 0;
// Gather free size of all numa nodes.
for (auto &id : nodeIds) {
long long numaFreeSize = 0;
long long numaSize = numa_node_size64(id, &numaFreeSize);
UT_ASSERTne(numaSize, -1);
UT_ASSERT(numaFreeSize >= (long long)(remainingSpace + size));

numaCombinedFreeSize += numaFreeSize;
}

umf_result_t umf_ret = UMF_RESULT_SUCCESS;
// Create allocations until all the NUMA nodes until there's space only for
// one allocation.
std::vector<void *> allocs;
std::unordered_set<size_t> allocNodeIds;
while (numaCombinedFreeSize >= (long long)(remainingSpace + size)) {
void *ptr = nullptr;
umf_ret = umfMemoryProviderAlloc(hProvider, size, alignment, &ptr);
if (umf_ret != UMF_RESULT_SUCCESS) {
UT_ASSERTeq(umf_ret, UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC);
const char *msg = nullptr;
int32_t err = 0;
umfMemoryProviderGetLastNativeError(hProvider, &msg, &err);
// In this scenario, 'UMF_OS_RESULT_ERROR_ALLOC_FAILED' indicates OOM.
UT_ASSERTeq(err, UMF_OS_RESULT_ERROR_ALLOC_FAILED);
break;
}

UT_ASSERTne(ptr, nullptr);
// Access the allocation, so that all the pages associated with it are
// allocated on available NUMA nodes.
memset(ptr, 0xFF, size);

int mode = -1;
std::vector<size_t> boundNodeIds;
size_t allocNodeId = SIZE_MAX;
getAllocationPolicy(ptr, maxNodeId, mode, boundNodeIds, allocNodeId);

// In case of 'HOST ALL' memspace, the default set of nodes (that
// contains all available nodes) is used but get_mempolicy() would
// return an empty set of nodes.
UT_ASSERTeq(mode, MPOL_DEFAULT);
UT_ASSERTeq(boundNodeIds.size(), 0);

// Confirm that the memory is allocated on one of the nodes in
// 'HOST ALL' memspace.
auto it = std::find(nodeIds.begin(), nodeIds.end(), allocNodeId);
UT_ASSERT(it != nodeIds.end());

allocs.push_back(ptr);
allocNodeIds.insert(allocNodeId);

numaCombinedFreeSize -= size;
}

UT_ASSERT(allocs.size() >= nodeIds.size());
for (auto &ptr : allocs) {
umf_ret = umfMemoryProviderFree(hProvider, ptr, size);
UT_ASSERTeq(umf_ret, UMF_RESULT_SUCCESS);
}

// TODO: we want to enable this check only when tests are running under QEMU.
// Otherwise it might sporadically fail on a real system where other processes
// occupied all memory from a aparticular NUMA node.
#if 0
// Confirm that all the NUMA nodes bound to 'HOST ALL' memspace were exhausted.
for (auto &id : nodeIds) {
auto it = std::find(allocNodeIds.begin(), allocNodeIds.end(), id);
UT_ASSERT(it != allocNodeIds.end());
}
#endif
}
Loading