From a8096ca7ae1ee4e2d1fbf9a8c2c86003bd3a3278 Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Tue, 22 Oct 2024 15:21:57 +0200 Subject: [PATCH 1/3] Change FILE_PATH of a test file from /tmp/ to a local one Change FILE_PATH from /tmp/file_provider to ./tmp_file_provider, because it is safer (/tmp/ can be unavailable). Signed-off-by: Lukasz Dorau --- test/pools/pool_coarse_file.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pools/pool_coarse_file.hpp b/test/pools/pool_coarse_file.hpp index 0ec48f2fba..3d147b6875 100644 --- a/test/pools/pool_coarse_file.hpp +++ b/test/pools/pool_coarse_file.hpp @@ -14,6 +14,6 @@ using umf_test::test; using namespace umf_test; -#define FILE_PATH ((char *)"/tmp/file_provider") +#define FILE_PATH ((char *)"tmp_file_provider") #endif /* UMF_TEST_POOL_COARSE_FILE_HPP */ From 347b14bd05aa4756dae3640c48aed68407d1a552 Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Wed, 23 Oct 2024 09:34:12 +0200 Subject: [PATCH 2/3] Fix: do not allocate too much memory in calloc_compliance_test() Signed-off-by: Lukasz Dorau --- test/malloc_compliance_tests.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/malloc_compliance_tests.cpp b/test/malloc_compliance_tests.cpp index c3c67ae210..06e3b5dd78 100644 --- a/test/malloc_compliance_tests.cpp +++ b/test/malloc_compliance_tests.cpp @@ -85,12 +85,11 @@ void calloc_compliance_test(umf_memory_pool_handle_t hPool) { // Checking that the memory returned by calloc is zero filled for (int i = 0; i < ITERATIONS; i++) { alloc_size = rand_alloc_size(MAX_ALLOC_SIZE); - alloc_ptr[i] = umfPoolCalloc(hPool, i + 1, alloc_size); + alloc_ptr[i] = umfPoolCalloc(hPool, 2, alloc_size); ASSERT_NE(alloc_ptr[i], nullptr) << "calloc returned NULL, couldn't allocate much memory"; - ASSERT_NE(bufferIsFilledWithChar(alloc_ptr[i], alloc_size * (i + 1), 0), - 0) + ASSERT_NE(bufferIsFilledWithChar(alloc_ptr[i], 2 * alloc_size, 0), 0) << "Memory returned by calloc was not zeroed"; } free_memory(hPool, alloc_ptr); From a7f8c8f978e69996ca4d93f5d2fe186e0a023323 Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Wed, 23 Oct 2024 09:34:32 +0200 Subject: [PATCH 3/3] Add the jemalloc_coarse_devdax and scalable_coarse_devdax tests Add the jemalloc_coarse_devdax and scalable_coarse_devdax tests that test the coarse provider with upstream devdax provider and two pool managers: jemalloc and scalable pool. Signed-off-by: Lukasz Dorau --- test/CMakeLists.txt | 7 +++ test/poolFixtures.hpp | 18 +++++++ test/pools/jemalloc_coarse_devdax.cpp | 20 ++++++++ test/pools/jemalloc_coarse_file.cpp | 3 +- .../{pool_coarse_file.hpp => pool_coarse.hpp} | 7 ++- test/pools/scalable_coarse_devdax.cpp | 20 ++++++++ test/pools/scalable_coarse_file.cpp | 3 +- .../drd-umf_test-jemalloc_coarse_devdax.supp | 34 +++++++++++++ .../drd-umf_test-scalable_coarse_devdax.supp | 49 +++++++++++++++++++ ...grind-umf_test-jemalloc_coarse_devdax.supp | 34 +++++++++++++ ...grind-umf_test-scalable_coarse_devdax.supp | 49 +++++++++++++++++++ 11 files changed, 238 insertions(+), 6 deletions(-) create mode 100644 test/pools/jemalloc_coarse_devdax.cpp rename test/pools/{pool_coarse_file.hpp => pool_coarse.hpp} (68%) create mode 100644 test/pools/scalable_coarse_devdax.cpp create mode 100644 test/supp/drd-umf_test-jemalloc_coarse_devdax.supp create mode 100644 test/supp/drd-umf_test-scalable_coarse_devdax.supp create mode 100644 test/supp/helgrind-umf_test-jemalloc_coarse_devdax.supp create mode 100644 test/supp/helgrind-umf_test-scalable_coarse_devdax.supp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5d0f69da4c..c161734558 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -263,6 +263,10 @@ if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented NAME jemalloc_coarse_file SRCS pools/jemalloc_coarse_file.cpp malloc_compliance_tests.cpp LIBS jemalloc_pool) + add_umf_test( + NAME jemalloc_coarse_devdax + SRCS pools/jemalloc_coarse_devdax.cpp malloc_compliance_tests.cpp + LIBS jemalloc_pool) endif() # This test requires Linux-only file memory provider @@ -270,6 +274,9 @@ if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented add_umf_test( NAME scalable_coarse_file SRCS pools/scalable_coarse_file.cpp malloc_compliance_tests.cpp) + add_umf_test( + NAME scalable_coarse_devdax SRCS pools/scalable_coarse_devdax.cpp + malloc_compliance_tests.cpp) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UMF_BUILD_FUZZTESTS) diff --git a/test/poolFixtures.hpp b/test/poolFixtures.hpp index b2b580b263..93d8393916 100644 --- a/test/poolFixtures.hpp +++ b/test/poolFixtures.hpp @@ -8,6 +8,7 @@ #include "pool.hpp" #include "provider.hpp" #include "umf/providers/provider_coarse.h" +#include "umf/providers/provider_devdax_memory.h" #include #include @@ -66,6 +67,23 @@ struct umfPoolTest : umf_test::test, ::testing::WithParamInterface { void SetUp() override { test::SetUp(); + + auto [pool_ops, pool_params, provider_ops, provider_params, + coarse_params] = this->GetParam(); + if (provider_ops == umfDevDaxMemoryProviderOps()) { + char *path = getenv("UMF_TESTS_DEVDAX_PATH"); + if (path == nullptr || path[0] == 0) { + GTEST_SKIP() + << "Test skipped, UMF_TESTS_DEVDAX_PATH is not set"; + } + + char *size = getenv("UMF_TESTS_DEVDAX_SIZE"); + if (size == nullptr || size[0] == 0) { + GTEST_SKIP() + << "Test skipped, UMF_TESTS_DEVDAX_SIZE is not set"; + } + } + pool = poolCreateExtUnique(this->GetParam()); } diff --git a/test/pools/jemalloc_coarse_devdax.cpp b/test/pools/jemalloc_coarse_devdax.cpp new file mode 100644 index 0000000000..ae98ecf4b1 --- /dev/null +++ b/test/pools/jemalloc_coarse_devdax.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Intel Corporation +// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "umf/pools/pool_jemalloc.h" +#include "umf/providers/provider_devdax_memory.h" + +#include "pool_coarse.hpp" + +auto coarseParams = umfCoarseMemoryProviderParamsDefault(); +auto devdaxParams = umfDevDaxMemoryProviderParamsDefault( + getenv("UMF_TESTS_DEVDAX_PATH"), getenv("UMF_TESTS_DEVDAX_SIZE") + ? atol(getenv("UMF_TESTS_DEVDAX_SIZE")) + : 0); + +INSTANTIATE_TEST_SUITE_P(jemallocCoarseDevDaxTest, umfPoolTest, + ::testing::Values(poolCreateExtParams{ + umfJemallocPoolOps(), nullptr, + umfDevDaxMemoryProviderOps(), &devdaxParams, + &coarseParams})); diff --git a/test/pools/jemalloc_coarse_file.cpp b/test/pools/jemalloc_coarse_file.cpp index 4c38082c06..7eb9049037 100644 --- a/test/pools/jemalloc_coarse_file.cpp +++ b/test/pools/jemalloc_coarse_file.cpp @@ -3,8 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "umf/pools/pool_jemalloc.h" +#include "umf/providers/provider_file_memory.h" -#include "pool_coarse_file.hpp" +#include "pool_coarse.hpp" auto coarseParams = umfCoarseMemoryProviderParamsDefault(); auto fileParams = umfFileMemoryProviderParamsDefault(FILE_PATH); diff --git a/test/pools/pool_coarse_file.hpp b/test/pools/pool_coarse.hpp similarity index 68% rename from test/pools/pool_coarse_file.hpp rename to test/pools/pool_coarse.hpp index 3d147b6875..7baa612f1e 100644 --- a/test/pools/pool_coarse_file.hpp +++ b/test/pools/pool_coarse.hpp @@ -2,11 +2,10 @@ // Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef UMF_TEST_POOL_COARSE_FILE_HPP -#define UMF_TEST_POOL_COARSE_FILE_HPP 1 +#ifndef UMF_TEST_POOL_COARSE_HPP +#define UMF_TEST_POOL_COARSE_HPP 1 #include "umf/providers/provider_coarse.h" -#include "umf/providers/provider_file_memory.h" #include "pool.hpp" #include "poolFixtures.hpp" @@ -16,4 +15,4 @@ using namespace umf_test; #define FILE_PATH ((char *)"tmp_file_provider") -#endif /* UMF_TEST_POOL_COARSE_FILE_HPP */ +#endif /* UMF_TEST_POOL_COARSE_HPP */ diff --git a/test/pools/scalable_coarse_devdax.cpp b/test/pools/scalable_coarse_devdax.cpp new file mode 100644 index 0000000000..b5da7d2422 --- /dev/null +++ b/test/pools/scalable_coarse_devdax.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Intel Corporation +// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "umf/pools/pool_scalable.h" +#include "umf/providers/provider_devdax_memory.h" + +#include "pool_coarse.hpp" + +auto coarseParams = umfCoarseMemoryProviderParamsDefault(); +auto devdaxParams = umfDevDaxMemoryProviderParamsDefault( + getenv("UMF_TESTS_DEVDAX_PATH"), getenv("UMF_TESTS_DEVDAX_SIZE") + ? atol(getenv("UMF_TESTS_DEVDAX_SIZE")) + : 0); + +INSTANTIATE_TEST_SUITE_P(scalableCoarseDevDaxTest, umfPoolTest, + ::testing::Values(poolCreateExtParams{ + umfScalablePoolOps(), nullptr, + umfDevDaxMemoryProviderOps(), &devdaxParams, + &coarseParams})); diff --git a/test/pools/scalable_coarse_file.cpp b/test/pools/scalable_coarse_file.cpp index c6687c79ea..b83a123389 100644 --- a/test/pools/scalable_coarse_file.cpp +++ b/test/pools/scalable_coarse_file.cpp @@ -3,8 +3,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "umf/pools/pool_scalable.h" +#include "umf/providers/provider_file_memory.h" -#include "pool_coarse_file.hpp" +#include "pool_coarse.hpp" auto coarseParams = umfCoarseMemoryProviderParamsDefault(); auto fileParams = umfFileMemoryProviderParamsDefault(FILE_PATH); diff --git a/test/supp/drd-umf_test-jemalloc_coarse_devdax.supp b/test/supp/drd-umf_test-jemalloc_coarse_devdax.supp new file mode 100644 index 0000000000..fd071432b6 --- /dev/null +++ b/test/supp/drd-umf_test-jemalloc_coarse_devdax.supp @@ -0,0 +1,34 @@ +{ + False-positive ConflictingAccess in libjemalloc.so + drd:ConflictingAccess + obj:*/libjemalloc.so* + ... + fun:mallocx + ... +} + +{ + False-positive ConflictingAccess in libjemalloc.so + drd:ConflictingAccess + obj:*/libjemalloc.so* + ... + fun:op_free + ... +} + +{ + False-positive ConflictingAccess in libjemalloc.so + drd:ConflictingAccess + obj:*/libjemalloc.so* + ... + fun:__nptl_deallocate_tsd + ... +} + +{ + False-positive ConflictingAccess in critnib_insert + drd:ConflictingAccess + fun:store + fun:critnib_insert + ... +} diff --git a/test/supp/drd-umf_test-scalable_coarse_devdax.supp b/test/supp/drd-umf_test-scalable_coarse_devdax.supp new file mode 100644 index 0000000000..65640f6c3a --- /dev/null +++ b/test/supp/drd-umf_test-scalable_coarse_devdax.supp @@ -0,0 +1,49 @@ +{ + False-positive ConflictingAccess in libtbbmalloc.so + drd:ConflictingAccess + obj:*/libtbbmalloc.so* +} + +{ + False-positive ConflictingAccess in libtbbmalloc.so + drd:ConflictingAccess + obj:*/libtbbmalloc.so* + ... + fun:tbb_malloc + ... +} + +{ + False-positive ConflictingAccess in libtbbmalloc.so + drd:ConflictingAccess + obj:*/libtbbmalloc.so* + ... + fun:tbb_aligned_malloc + ... +} + +{ + False-positive ConflictingAccess in libtbbmalloc.so + drd:ConflictingAccess + obj:*/libtbbmalloc.so* + ... + fun:tbb_free + ... +} + +{ + False-positive ConflictingAccess in libtbbmalloc.so + drd:ConflictingAccess + obj:*/libtbbmalloc.so* + ... + fun:__nptl_deallocate_tsd + ... +} + +{ + False-positive ConflictingAccess in _Z22pow2AlignedAllocHelperP17umf_memory_pool_t + drd:ConflictingAccess + fun:memset + fun:_Z22pow2AlignedAllocHelperP17umf_memory_pool_t + ... +} diff --git a/test/supp/helgrind-umf_test-jemalloc_coarse_devdax.supp b/test/supp/helgrind-umf_test-jemalloc_coarse_devdax.supp new file mode 100644 index 0000000000..18774f387c --- /dev/null +++ b/test/supp/helgrind-umf_test-jemalloc_coarse_devdax.supp @@ -0,0 +1,34 @@ +{ + False-positive Race in libjemalloc.so + Helgrind:Race + obj:*/libjemalloc.so* + ... + fun:mallocx + ... +} + +{ + False-positive Race in libjemalloc.so + Helgrind:Race + obj:*/libjemalloc.so* + ... + fun:op_free + ... +} + +{ + False-positive Race in libjemalloc.so + Helgrind:Race + obj:*/libjemalloc.so* + ... + fun:__nptl_deallocate_tsd + ... +} + +{ + False-positive Race in critnib_insert + Helgrind:Race + fun:store + fun:critnib_insert + ... +} diff --git a/test/supp/helgrind-umf_test-scalable_coarse_devdax.supp b/test/supp/helgrind-umf_test-scalable_coarse_devdax.supp new file mode 100644 index 0000000000..650edf5142 --- /dev/null +++ b/test/supp/helgrind-umf_test-scalable_coarse_devdax.supp @@ -0,0 +1,49 @@ +{ + False-positive Race in libtbbmalloc.so + Helgrind:Race + obj:*/libtbbmalloc.so* +} + +{ + False-positive Race in libtbbmalloc.so + Helgrind:Race + obj:*/libtbbmalloc.so* + ... + fun:tbb_malloc + ... +} + +{ + False-positive Race in libtbbmalloc.so + Helgrind:Race + obj:*/libtbbmalloc.so* + ... + fun:tbb_aligned_malloc + ... +} + +{ + False-positive Race in libtbbmalloc.so + Helgrind:Race + obj:*/libtbbmalloc.so* + ... + fun:tbb_free + ... +} + +{ + False-positive Race in libtbbmalloc.so + Helgrind:Race + obj:*/libtbbmalloc.so* + ... + fun:__nptl_deallocate_tsd + ... +} + +{ + False-positive Race in _Z22pow2AlignedAllocHelperP17umf_memory_pool_t + Helgrind:Race + fun:memset + fun:_Z22pow2AlignedAllocHelperP17umf_memory_pool_t + ... +}