From 29c4aacce09c48f85fec620ed90a979fd2884918 Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Mon, 21 Oct 2024 11:03:50 +0200 Subject: [PATCH 1/2] Add umfCoarseMemoryProviderParamsDefault() Signed-off-by: Lukasz Dorau --- include/umf/providers/provider_coarse.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/umf/providers/provider_coarse.h b/include/umf/providers/provider_coarse.h index 22b59a61bf..6ed6e0fbc9 100644 --- a/include/umf/providers/provider_coarse.h +++ b/include/umf/providers/provider_coarse.h @@ -9,6 +9,8 @@ #define UMF_COARSE_PROVIDER_H #include +#include + #include #ifdef __cplusplus @@ -98,6 +100,15 @@ umf_memory_provider_ops_t *umfCoarseMemoryProviderOps(void); coarse_memory_provider_stats_t umfCoarseMemoryProviderGetStats(umf_memory_provider_handle_t provider); +/// @brief Create default params for the coarse memory provider +static inline coarse_memory_provider_params_t +umfCoarseMemoryProviderParamsDefault(void) { + coarse_memory_provider_params_t coarse_memory_provider_params; + memset(&coarse_memory_provider_params, 0, + sizeof(coarse_memory_provider_params)); + return coarse_memory_provider_params; +} + #ifdef __cplusplus } #endif From 9c91404e4be101a275a6066d39aee213d708c806 Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Mon, 21 Oct 2024 21:02:12 +0200 Subject: [PATCH 2/2] Add the jemalloc_coarse_file and scalable_coarse_file tests Add the jemalloc_coarse_file and scalable_coarse_file tests that test the coarse provider with upstream file provider and two pool managers: jemalloc and scalable pool. Signed-off-by: Lukasz Dorau --- test/CMakeLists.txt | 23 +++++++-- test/pools/jemalloc_coarse_file.cpp | 16 ++++++ test/pools/pool_coarse_file.hpp | 19 +++++++ test/pools/scalable_coarse_file.cpp | 16 ++++++ .../drd-umf_test-jemalloc_coarse_file.supp | 34 +++++++++++++ .../drd-umf_test-scalable_coarse_file.supp | 49 +++++++++++++++++++ ...elgrind-umf_test-jemalloc_coarse_file.supp | 34 +++++++++++++ ...elgrind-umf_test-scalable_coarse_file.supp | 49 +++++++++++++++++++ 8 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 test/pools/jemalloc_coarse_file.cpp create mode 100644 test/pools/pool_coarse_file.hpp create mode 100644 test/pools/scalable_coarse_file.cpp create mode 100644 test/supp/drd-umf_test-jemalloc_coarse_file.supp create mode 100644 test/supp/drd-umf_test-scalable_coarse_file.supp create mode 100644 test/supp/helgrind-umf_test-jemalloc_coarse_file.supp create mode 100644 test/supp/helgrind-umf_test-scalable_coarse_file.supp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8a03fd195f..6c2e5d591a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -168,7 +168,7 @@ if(UMF_BUILD_LIBUMF_POOL_DISJOINT) endif() if(UMF_BUILD_LIBUMF_POOL_DISJOINT - AND UMF_BUILD_LIBUMF_POOL_JEMALLOC + AND UMF_POOL_JEMALLOC_ENABLED AND UMF_POOL_SCALABLE_ENABLED AND (NOT UMF_DISABLE_HWLOC)) add_umf_test( @@ -177,7 +177,7 @@ if(UMF_BUILD_LIBUMF_POOL_DISJOINT LIBS disjoint_pool jemalloc_pool ${JEMALLOC_LIBRARIES}) endif() -if(UMF_BUILD_LIBUMF_POOL_JEMALLOC AND (NOT UMF_DISABLE_HWLOC)) +if(UMF_POOL_JEMALLOC_ENABLED AND (NOT UMF_DISABLE_HWLOC)) add_umf_test( NAME jemalloc_pool SRCS pools/jemalloc_pool.cpp malloc_compliance_tests.cpp @@ -190,8 +190,7 @@ if(UMF_POOL_SCALABLE_ENABLED AND (NOT UMF_DISABLE_HWLOC)) endif() if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented - # only for - # Linux now + # only for Linux now if(PkgConfig_FOUND) pkg_check_modules(LIBNUMA numa) endif() @@ -257,6 +256,22 @@ if(LINUX AND (NOT UMF_DISABLE_HWLOC)) # OS-specific functions are implemented NAME provider_file_memory SRCS provider_file_memory.cpp LIBS ${UMF_UTILS_FOR_TEST}) + + # This test requires Linux-only file memory provider + if(UMF_POOL_JEMALLOC_ENABLED) + add_umf_test( + NAME jemalloc_coarse_file + SRCS pools/jemalloc_coarse_file.cpp malloc_compliance_tests.cpp + LIBS jemalloc_pool) + endif() + + # This test requires Linux-only file memory provider + if(UMF_POOL_SCALABLE_ENABLED) + add_umf_test( + NAME scalable_coarse_file SRCS pools/scalable_coarse_file.cpp + malloc_compliance_tests.cpp) + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UMF_BUILD_FUZZTESTS) add_subdirectory(fuzz) endif() diff --git a/test/pools/jemalloc_coarse_file.cpp b/test/pools/jemalloc_coarse_file.cpp new file mode 100644 index 0000000000..4c38082c06 --- /dev/null +++ b/test/pools/jemalloc_coarse_file.cpp @@ -0,0 +1,16 @@ +// 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 "pool_coarse_file.hpp" + +auto coarseParams = umfCoarseMemoryProviderParamsDefault(); +auto fileParams = umfFileMemoryProviderParamsDefault(FILE_PATH); + +INSTANTIATE_TEST_SUITE_P(jemallocCoarseFileTest, umfPoolTest, + ::testing::Values(poolCreateExtParams{ + umfJemallocPoolOps(), nullptr, + umfFileMemoryProviderOps(), &fileParams, + &coarseParams})); diff --git a/test/pools/pool_coarse_file.hpp b/test/pools/pool_coarse_file.hpp new file mode 100644 index 0000000000..0ec48f2fba --- /dev/null +++ b/test/pools/pool_coarse_file.hpp @@ -0,0 +1,19 @@ +// 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 + +#ifndef UMF_TEST_POOL_COARSE_FILE_HPP +#define UMF_TEST_POOL_COARSE_FILE_HPP 1 + +#include "umf/providers/provider_coarse.h" +#include "umf/providers/provider_file_memory.h" + +#include "pool.hpp" +#include "poolFixtures.hpp" + +using umf_test::test; +using namespace umf_test; + +#define FILE_PATH ((char *)"/tmp/file_provider") + +#endif /* UMF_TEST_POOL_COARSE_FILE_HPP */ diff --git a/test/pools/scalable_coarse_file.cpp b/test/pools/scalable_coarse_file.cpp new file mode 100644 index 0000000000..c6687c79ea --- /dev/null +++ b/test/pools/scalable_coarse_file.cpp @@ -0,0 +1,16 @@ +// 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 "pool_coarse_file.hpp" + +auto coarseParams = umfCoarseMemoryProviderParamsDefault(); +auto fileParams = umfFileMemoryProviderParamsDefault(FILE_PATH); + +INSTANTIATE_TEST_SUITE_P(scalableCoarseFileTest, umfPoolTest, + ::testing::Values(poolCreateExtParams{ + umfScalablePoolOps(), nullptr, + umfFileMemoryProviderOps(), &fileParams, + &coarseParams})); diff --git a/test/supp/drd-umf_test-jemalloc_coarse_file.supp b/test/supp/drd-umf_test-jemalloc_coarse_file.supp new file mode 100644 index 0000000000..fd071432b6 --- /dev/null +++ b/test/supp/drd-umf_test-jemalloc_coarse_file.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_file.supp b/test/supp/drd-umf_test-scalable_coarse_file.supp new file mode 100644 index 0000000000..65640f6c3a --- /dev/null +++ b/test/supp/drd-umf_test-scalable_coarse_file.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_file.supp b/test/supp/helgrind-umf_test-jemalloc_coarse_file.supp new file mode 100644 index 0000000000..18774f387c --- /dev/null +++ b/test/supp/helgrind-umf_test-jemalloc_coarse_file.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_file.supp b/test/supp/helgrind-umf_test-scalable_coarse_file.supp new file mode 100644 index 0000000000..650edf5142 --- /dev/null +++ b/test/supp/helgrind-umf_test-scalable_coarse_file.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 + ... +}