Skip to content

Commit

Permalink
Fix trackingFree() for providers not supporting free() op
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ldorau committed Nov 14, 2024
1 parent 08ce30c commit ef80099
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/provider/provider_tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/provider_devdax_memory_ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static std::vector<ipcTestParams> getIpcProxyPoolTestParamsList(void) {

ipcProxyPoolTestParamsList = {
{umfProxyPoolOps(), nullptr, umfDevDaxMemoryProviderOps(),
&defaultDevDaxParams, &hostAccessor, true},
&defaultDevDaxParams, &hostAccessor, false},
#ifdef UMF_POOL_JEMALLOC_ENABLED
{umfJemallocPoolOps(), nullptr, umfDevDaxMemoryProviderOps(),
&defaultDevDaxParams, &hostAccessor, false},
Expand Down
2 changes: 1 addition & 1 deletion test/provider_file_memory_ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ HostMemoryAccessor hostAccessor;
static std::vector<ipcTestParams> 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},
Expand Down

0 comments on commit ef80099

Please sign in to comment.