From ef80099dea85ebc0a26a2e381a5aa692d279a16e Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Thu, 14 Nov 2024 12:30:49 +0100 Subject: [PATCH] Fix trackingFree() for providers not supporting free() op Fix trackingFree() for providers not supporting free() op: do not add memory back to the tracker, if the provider does not support the free() operation. Signed-off-by: Lukasz Dorau --- src/provider/provider_tracking.c | 6 ++++++ test/provider_devdax_memory_ipc.cpp | 2 +- test/provider_file_memory_ipc.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/provider/provider_tracking.c b/src/provider/provider_tracking.c index 769ed6a94..bb6cbac70 100644 --- a/src/provider/provider_tracking.c +++ b/src/provider/provider_tracking.c @@ -382,6 +382,12 @@ static umf_result_t trackingFree(void *hProvider, void *ptr, size_t size) { ret = umfMemoryProviderFree(p->hUpstream, ptr, size); if (ret != UMF_RESULT_SUCCESS) { LOG_ERR("upstream provider failed to free the memory"); + // Do not add memory back to the tracker, + // if the provider does not support the free() op. + if (ret == UMF_RESULT_ERROR_NOT_SUPPORTED) { + return ret_remove; + } + // Do not add memory back to the tracker, // if it had not been removed. if (ret_remove != UMF_RESULT_SUCCESS) { diff --git a/test/provider_devdax_memory_ipc.cpp b/test/provider_devdax_memory_ipc.cpp index 071196c94..6c2608317 100644 --- a/test/provider_devdax_memory_ipc.cpp +++ b/test/provider_devdax_memory_ipc.cpp @@ -39,7 +39,7 @@ static std::vector getIpcProxyPoolTestParamsList(void) { ipcProxyPoolTestParamsList = { {umfProxyPoolOps(), nullptr, umfDevDaxMemoryProviderOps(), - &defaultDevDaxParams, &hostAccessor, true}, + &defaultDevDaxParams, &hostAccessor, false}, #ifdef UMF_POOL_JEMALLOC_ENABLED {umfJemallocPoolOps(), nullptr, umfDevDaxMemoryProviderOps(), &defaultDevDaxParams, &hostAccessor, false}, diff --git a/test/provider_file_memory_ipc.cpp b/test/provider_file_memory_ipc.cpp index 619c13b05..83374bf79 100644 --- a/test/provider_file_memory_ipc.cpp +++ b/test/provider_file_memory_ipc.cpp @@ -32,7 +32,7 @@ HostMemoryAccessor hostAccessor; static std::vector ipcManyPoolsTestParamsList = { // TODO: enable it when sizes of allocations in ipcFixtures.hpp are fixed // {umfProxyPoolOps(), nullptr, umfFileMemoryProviderOps(), -// &file_params_shared, &hostAccessor, true}, +// &file_params_shared, &hostAccessor, false}, #ifdef UMF_POOL_JEMALLOC_ENABLED {umfJemallocPoolOps(), nullptr, umfFileMemoryProviderOps(), &file_params_shared, &hostAccessor, false},