diff --git a/src/ipc_cache.c b/src/ipc_cache.c index 60072d4df..ccb296d5b 100644 --- a/src/ipc_cache.c +++ b/src/ipc_cache.c @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -22,41 +22,41 @@ #pragma warning(disable : 4702) #endif -struct ipc_handle_cache_entry_t; +struct ipc_opened_cache_entry_t; -typedef struct ipc_handle_cache_entry_t *hash_map_t; -typedef struct ipc_handle_cache_entry_t *lru_list_t; +typedef struct ipc_opened_cache_entry_t *hash_map_t; +typedef struct ipc_opened_cache_entry_t *lru_list_t; -typedef struct ipc_handle_cache_entry_t { +typedef struct ipc_opened_cache_entry_t { UT_hash_handle hh; - struct ipc_handle_cache_entry_t *next, *prev; - ipc_mapped_handle_cache_key_t key; + struct ipc_opened_cache_entry_t *next, *prev; + ipc_opened_cache_key_t key; uint64_t ref_count; uint64_t handle_id; hash_map_t *hash_table; // pointer to the hash table to which the entry belongs - ipc_mapped_handle_cache_value_t value; -} ipc_handle_cache_entry_t; + ipc_opened_cache_value_t value; +} ipc_opened_cache_entry_t; -typedef struct ipc_mapped_handle_cache_global_t { +typedef struct ipc_opened_cache_global_t { utils_mutex_t cache_lock; umf_ba_pool_t *cache_allocator; size_t max_size; size_t cur_size; lru_list_t lru_list; -} ipc_mapped_handle_cache_global_t; +} ipc_opened_cache_global_t; -typedef struct ipc_mapped_handle_cache_t { - ipc_mapped_handle_cache_global_t *global; +typedef struct ipc_opened_cache_t { + ipc_opened_cache_global_t *global; hash_map_t hash_table; - ipc_mapped_handle_cache_eviction_cb_t eviction_cb; -} ipc_mapped_handle_cache_t; + ipc_opened_cache_eviction_cb_t eviction_cb; +} ipc_opened_cache_t; -ipc_mapped_handle_cache_global_t *IPC_MAPPED_CACHE_GLOBAL = NULL; +ipc_opened_cache_global_t *IPC_OPENED_CACHE_GLOBAL = NULL; umf_result_t umfIpcCacheGlobalInit(void) { umf_result_t ret = UMF_RESULT_SUCCESS; - ipc_mapped_handle_cache_global_t *cache_global = + ipc_opened_cache_global_t *cache_global = umf_ba_global_alloc(sizeof(*cache_global)); if (!cache_global) { LOG_ERR("Failed to allocate memory for the IPC cache global data"); @@ -71,7 +71,7 @@ umf_result_t umfIpcCacheGlobalInit(void) { } cache_global->cache_allocator = - umf_ba_create(sizeof(ipc_handle_cache_entry_t)); + umf_ba_create(sizeof(ipc_opened_cache_entry_t)); if (!cache_global->cache_allocator) { LOG_ERR("Failed to create IPC cache allocator"); ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; @@ -83,7 +83,7 @@ umf_result_t umfIpcCacheGlobalInit(void) { cache_global->cur_size = 0; cache_global->lru_list = NULL; - IPC_MAPPED_CACHE_GLOBAL = cache_global; + IPC_OPENED_CACHE_GLOBAL = cache_global; goto err_exit; err_mutex_destroy: @@ -97,15 +97,15 @@ umf_result_t umfIpcCacheGlobalInit(void) { #ifndef NDEBUG static size_t getGlobalLruListSize(lru_list_t lru_list) { size_t size = 0; - ipc_handle_cache_entry_t *tmp; + ipc_opened_cache_entry_t *tmp; DL_COUNT(lru_list, tmp, size); return size; } #endif /* NDEBUG */ void umfIpcCacheGlobalTearDown(void) { - ipc_mapped_handle_cache_global_t *cache_global = IPC_MAPPED_CACHE_GLOBAL; - IPC_MAPPED_CACHE_GLOBAL = NULL; + ipc_opened_cache_global_t *cache_global = IPC_OPENED_CACHE_GLOBAL; + IPC_OPENED_CACHE_GLOBAL = NULL; if (!cache_global) { return; @@ -119,31 +119,31 @@ void umfIpcCacheGlobalTearDown(void) { umf_ba_global_free(cache_global); } -ipc_mapped_handle_cache_handle_t umfIpcHandleMappedCacheCreate( - ipc_mapped_handle_cache_eviction_cb_t eviction_cb) { +ipc_opened_cache_handle_t +umfIpcOpenedCacheCreate(ipc_opened_cache_eviction_cb_t eviction_cb) { if (eviction_cb == NULL) { LOG_ERR("Eviction callback is NULL"); return NULL; } - ipc_mapped_handle_cache_t *cache = umf_ba_global_alloc(sizeof(*cache)); + ipc_opened_cache_t *cache = umf_ba_global_alloc(sizeof(*cache)); if (!cache) { LOG_ERR("Failed to allocate memory for the IPC cache"); return NULL; } - assert(IPC_MAPPED_CACHE_GLOBAL != NULL); + assert(IPC_OPENED_CACHE_GLOBAL != NULL); - cache->global = IPC_MAPPED_CACHE_GLOBAL; + cache->global = IPC_OPENED_CACHE_GLOBAL; cache->hash_table = NULL; cache->eviction_cb = eviction_cb; return cache; } -void umfIpcHandleMappedCacheDestroy(ipc_mapped_handle_cache_handle_t cache) { - ipc_handle_cache_entry_t *entry, *tmp; +void umfIpcOpenedCacheDestroy(ipc_opened_cache_handle_t cache) { + ipc_opened_cache_entry_t *entry, *tmp; HASH_ITER(hh, cache->hash_table, entry, tmp) { DL_DELETE(cache->global->lru_list, entry); HASH_DEL(cache->hash_table, entry); @@ -157,15 +157,14 @@ void umfIpcHandleMappedCacheDestroy(ipc_mapped_handle_cache_handle_t cache) { umf_ba_global_free(cache); } -umf_result_t -umfIpcHandleMappedCacheGet(ipc_mapped_handle_cache_handle_t cache, - const ipc_mapped_handle_cache_key_t *key, - uint64_t handle_id, - ipc_mapped_handle_cache_value_t **retEntry) { - ipc_handle_cache_entry_t *entry = NULL; +umf_result_t umfIpcOpenedCacheGet(ipc_opened_cache_handle_t cache, + const ipc_opened_cache_key_t *key, + uint64_t handle_id, + ipc_opened_cache_value_t **retEntry) { + ipc_opened_cache_entry_t *entry = NULL; umf_result_t ret = UMF_RESULT_SUCCESS; bool evicted = false; - ipc_mapped_handle_cache_value_t evicted_value; + ipc_opened_cache_value_t evicted_value; if (!cache || !key || !retEntry) { LOG_ERR("Some arguments are NULL, cache=%p, key=%p, retEntry=%p", diff --git a/src/ipc_cache.h b/src/ipc_cache.h index 59ae28787..80870d373 100644 --- a/src/ipc_cache.h +++ b/src/ipc_cache.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -14,39 +14,37 @@ #include "utils_concurrency.h" -typedef struct ipc_mapped_handle_cache_key_t { +typedef struct ipc_opened_cache_key_t { void *remote_base_ptr; umf_memory_provider_handle_t local_provider; int remote_pid; -} ipc_mapped_handle_cache_key_t; +} ipc_opened_cache_key_t; -typedef struct ipc_mapped_handle_cache_value_t { +typedef struct ipc_opened_cache_value_t { void *mapped_base_ptr; size_t mapped_size; utils_mutex_t mmap_lock; -} ipc_mapped_handle_cache_value_t; +} ipc_opened_cache_value_t; -struct ipc_mapped_handle_cache_t; +struct ipc_opened_cache_t; -typedef struct ipc_mapped_handle_cache_t *ipc_mapped_handle_cache_handle_t; +typedef struct ipc_opened_cache_t *ipc_opened_cache_handle_t; umf_result_t umfIpcCacheGlobalInit(void); void umfIpcCacheGlobalTearDown(void); // define pointer to the eviction callback function -typedef void (*ipc_mapped_handle_cache_eviction_cb_t)( - const ipc_mapped_handle_cache_key_t *key, - const ipc_mapped_handle_cache_value_t *value); +typedef void (*ipc_opened_cache_eviction_cb_t)( + const ipc_opened_cache_key_t *key, const ipc_opened_cache_value_t *value); -ipc_mapped_handle_cache_handle_t umfIpcHandleMappedCacheCreate( - ipc_mapped_handle_cache_eviction_cb_t eviction_cb); +ipc_opened_cache_handle_t +umfIpcOpenedCacheCreate(ipc_opened_cache_eviction_cb_t eviction_cb); -void umfIpcHandleMappedCacheDestroy(ipc_mapped_handle_cache_handle_t cache); +void umfIpcOpenedCacheDestroy(ipc_opened_cache_handle_t cache); -umf_result_t -umfIpcHandleMappedCacheGet(ipc_mapped_handle_cache_handle_t cache, - const ipc_mapped_handle_cache_key_t *key, - uint64_t handle_id, - ipc_mapped_handle_cache_value_t **retEntry); +umf_result_t umfIpcOpenedCacheGet(ipc_opened_cache_handle_t cache, + const ipc_opened_cache_key_t *key, + uint64_t handle_id, + ipc_opened_cache_value_t **retEntry); #endif /* UMF_IPC_CACHE_H */ diff --git a/src/provider/provider_tracking.c b/src/provider/provider_tracking.c index c4fff4133..b27b858d4 100644 --- a/src/provider/provider_tracking.c +++ b/src/provider/provider_tracking.c @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -28,17 +28,23 @@ uint64_t IPC_HANDLE_ID = 0; -typedef struct tracker_value_t { +struct umf_memory_tracker_t { + umf_ba_pool_t *alloc_info_allocator; + critnib *alloc_segments_map; + utils_mutex_t splitMergeMutex; +}; + +typedef struct tracker_alloc_info_t { umf_memory_pool_handle_t pool; size_t size; -} tracker_value_t; +} tracker_alloc_info_t; static umf_result_t umfMemoryTrackerAdd(umf_memory_tracker_handle_t hTracker, umf_memory_pool_handle_t pool, const void *ptr, size_t size) { assert(ptr); - tracker_value_t *value = umf_ba_alloc(hTracker->tracker_allocator); + tracker_alloc_info_t *value = umf_ba_alloc(hTracker->alloc_info_allocator); if (value == NULL) { LOG_ERR("failed to allocate tracker value, ptr=%p, size=%zu", ptr, size); @@ -48,7 +54,8 @@ static umf_result_t umfMemoryTrackerAdd(umf_memory_tracker_handle_t hTracker, value->pool = pool; value->size = size; - int ret = critnib_insert(hTracker->map, (uintptr_t)ptr, value, 0); + int ret = + critnib_insert(hTracker->alloc_segments_map, (uintptr_t)ptr, value, 0); if (ret == 0) { LOG_DEBUG( @@ -60,7 +67,7 @@ static umf_result_t umfMemoryTrackerAdd(umf_memory_tracker_handle_t hTracker, LOG_ERR("failed to insert tracker value, ret=%d, ptr=%p, pool=%p, size=%zu", ret, ptr, (void *)pool, size); - umf_ba_free(hTracker->tracker_allocator, value); + umf_ba_free(hTracker->alloc_info_allocator, value); if (ret == ENOMEM) { return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; @@ -78,18 +85,18 @@ static umf_result_t umfMemoryTrackerRemove(umf_memory_tracker_handle_t hTracker, // Every umfMemoryTrackerAdd(..., ptr, ...) should have a corresponding // umfMemoryTrackerRemove call with the same ptr value. - void *value = critnib_remove(hTracker->map, (uintptr_t)ptr); + void *value = critnib_remove(hTracker->alloc_segments_map, (uintptr_t)ptr); if (!value) { - LOG_ERR("pointer %p not found in the map", ptr); + LOG_ERR("pointer %p not found in the alloc_segments_map", ptr); return UMF_RESULT_ERROR_UNKNOWN; } - tracker_value_t *v = value; + tracker_alloc_info_t *v = value; LOG_DEBUG("memory region removed: tracker=%p, ptr=%p, size=%zu", (void *)hTracker, ptr, v->size); - umf_ba_free(hTracker->tracker_allocator, value); + umf_ba_free(hTracker->alloc_info_allocator, value); return UMF_RESULT_SUCCESS; } @@ -117,15 +124,15 @@ umf_result_t umfMemoryTrackerGetAllocInfo(const void *ptr, return UMF_RESULT_ERROR_NOT_SUPPORTED; } - if (TRACKER->map == NULL) { - LOG_ERR("tracker's map does not exist"); + if (TRACKER->alloc_segments_map == NULL) { + LOG_ERR("tracker's alloc_segments_map does not exist"); return UMF_RESULT_ERROR_NOT_SUPPORTED; } uintptr_t rkey; - tracker_value_t *rvalue; - int found = critnib_find(TRACKER->map, (uintptr_t)ptr, FIND_LE, - (void *)&rkey, (void **)&rvalue); + tracker_alloc_info_t *rvalue; + int found = critnib_find(TRACKER->alloc_segments_map, (uintptr_t)ptr, + FIND_LE, (void *)&rkey, (void **)&rvalue); if (!found || (uintptr_t)ptr >= rkey + rvalue->size) { LOG_DEBUG("pointer %p not found in the tracker, TRACKER=%p", ptr, (void *)TRACKER); @@ -153,7 +160,7 @@ typedef struct umf_tracking_memory_provider_t { umf_memory_tracker_handle_t hTracker; umf_memory_pool_handle_t pool; critnib *ipcCache; - ipc_mapped_handle_cache_handle_t hIpcMappedCache; + ipc_opened_cache_handle_t hIpcMappedCache; } umf_tracking_memory_provider_t; typedef struct umf_tracking_memory_provider_t umf_tracking_memory_provider_t; @@ -188,8 +195,8 @@ static umf_result_t trackingAllocationSplit(void *hProvider, void *ptr, umf_tracking_memory_provider_t *provider = (umf_tracking_memory_provider_t *)hProvider; - tracker_value_t *splitValue = - umf_ba_alloc(provider->hTracker->tracker_allocator); + tracker_alloc_info_t *splitValue = + umf_ba_alloc(provider->hTracker->alloc_info_allocator); if (!splitValue) { return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; } @@ -202,8 +209,8 @@ static umf_result_t trackingAllocationSplit(void *hProvider, void *ptr, goto err_lock; } - tracker_value_t *value = - (tracker_value_t *)critnib_get(provider->hTracker->map, (uintptr_t)ptr); + tracker_alloc_info_t *value = (tracker_alloc_info_t *)critnib_get( + provider->hTracker->alloc_segments_map, (uintptr_t)ptr); if (!value) { LOG_ERR("region for split is not found in the tracker"); ret = UMF_RESULT_ERROR_INVALID_ARGUMENT; @@ -240,14 +247,15 @@ static umf_result_t trackingAllocationSplit(void *hProvider, void *ptr, goto err; } - int cret = critnib_insert(provider->hTracker->map, (uintptr_t)ptr, - (void *)splitValue, 1 /* update */); + int cret = + critnib_insert(provider->hTracker->alloc_segments_map, (uintptr_t)ptr, + (void *)splitValue, 1 /* update */); // this cannot fail since we know the element exists (nothing to allocate) assert(cret == 0); (void)cret; // free the original value - umf_ba_free(provider->hTracker->tracker_allocator, value); + umf_ba_free(provider->hTracker->alloc_info_allocator, value); utils_mutex_unlock(&provider->hTracker->splitMergeMutex); return UMF_RESULT_SUCCESS; @@ -255,7 +263,7 @@ static umf_result_t trackingAllocationSplit(void *hProvider, void *ptr, err: utils_mutex_unlock(&provider->hTracker->splitMergeMutex); err_lock: - umf_ba_free(provider->hTracker->tracker_allocator, splitValue); + umf_ba_free(provider->hTracker->alloc_info_allocator, splitValue); return ret; } @@ -265,8 +273,8 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr, umf_tracking_memory_provider_t *provider = (umf_tracking_memory_provider_t *)hProvider; - tracker_value_t *mergedValue = - umf_ba_alloc(provider->hTracker->tracker_allocator); + tracker_alloc_info_t *mergedValue = + umf_ba_alloc(provider->hTracker->alloc_info_allocator); if (!mergedValue) { return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; @@ -280,15 +288,15 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr, goto err_lock; } - tracker_value_t *lowValue = (tracker_value_t *)critnib_get( - provider->hTracker->map, (uintptr_t)lowPtr); + tracker_alloc_info_t *lowValue = (tracker_alloc_info_t *)critnib_get( + provider->hTracker->alloc_segments_map, (uintptr_t)lowPtr); if (!lowValue) { LOG_ERR("no left value"); ret = UMF_RESULT_ERROR_INVALID_ARGUMENT; goto err; } - tracker_value_t *highValue = (tracker_value_t *)critnib_get( - provider->hTracker->map, (uintptr_t)highPtr); + tracker_alloc_info_t *highValue = (tracker_alloc_info_t *)critnib_get( + provider->hTracker->alloc_segments_map, (uintptr_t)highPtr); if (!highValue) { LOG_ERR("no right value"); ret = UMF_RESULT_ERROR_INVALID_ARGUMENT; @@ -314,20 +322,21 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr, // We'll have a duplicate entry for the range [highPtr, highValue->size] but this is fine, // the value is the same anyway and we forbid removing that range concurrently - int cret = critnib_insert(provider->hTracker->map, (uintptr_t)lowPtr, - (void *)mergedValue, 1 /* update */); + int cret = + critnib_insert(provider->hTracker->alloc_segments_map, + (uintptr_t)lowPtr, (void *)mergedValue, 1 /* update */); // this cannot fail since we know the element exists (nothing to allocate) assert(cret == 0); (void)cret; // free old value that we just replaced with mergedValue - umf_ba_free(provider->hTracker->tracker_allocator, lowValue); + umf_ba_free(provider->hTracker->alloc_info_allocator, lowValue); - void *erasedhighValue = - critnib_remove(provider->hTracker->map, (uintptr_t)highPtr); + void *erasedhighValue = critnib_remove( + provider->hTracker->alloc_segments_map, (uintptr_t)highPtr); assert(erasedhighValue == highValue); - umf_ba_free(provider->hTracker->tracker_allocator, erasedhighValue); + umf_ba_free(provider->hTracker->alloc_info_allocator, erasedhighValue); utils_mutex_unlock(&provider->hTracker->splitMergeMutex); @@ -340,7 +349,7 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr, utils_mutex_unlock(&provider->hTracker->splitMergeMutex); err_lock: - umf_ba_free(provider->hTracker->tracker_allocator, mergedValue); + umf_ba_free(provider->hTracker->alloc_info_allocator, mergedValue); return ret; } @@ -425,9 +434,9 @@ static void clear_tracker_for_the_pool(umf_memory_tracker_handle_t hTracker, size_t n_items = 0; uintptr_t last_key = 0; - while (1 == critnib_find((critnib *)hTracker->map, last_key, FIND_G, &rkey, - &rvalue)) { - tracker_value_t *value = (tracker_value_t *)rvalue; + while (1 == critnib_find((critnib *)hTracker->alloc_segments_map, last_key, + FIND_G, &rkey, &rvalue)) { + tracker_alloc_info_t *value = (tracker_alloc_info_t *)rvalue; if (value->pool != pool && pool != NULL) { last_key = rkey; continue; @@ -435,9 +444,10 @@ static void clear_tracker_for_the_pool(umf_memory_tracker_handle_t hTracker, n_items++; - void *removed_value = critnib_remove(hTracker->map, rkey); + void *removed_value = + critnib_remove(hTracker->alloc_segments_map, rkey); assert(removed_value == rvalue); - umf_ba_free(hTracker->tracker_allocator, removed_value); + umf_ba_free(hTracker->alloc_info_allocator, removed_value); last_key = rkey; } @@ -467,7 +477,7 @@ static void trackingFinalize(void *provider) { umf_tracking_memory_provider_t *p = (umf_tracking_memory_provider_t *)provider; - umfIpcHandleMappedCacheDestroy(p->hIpcMappedCache); + umfIpcOpenedCacheDestroy(p->hIpcMappedCache); critnib_delete(p->ipcCache); @@ -619,8 +629,8 @@ static umf_result_t trackingPutIpcHandle(void *provider, } static void -ipcMappedCacheEvictionCallback(const ipc_mapped_handle_cache_key_t *key, - const ipc_mapped_handle_cache_value_t *value) { +ipcOpenedCacheEvictionCallback(const ipc_opened_cache_key_t *key, + const ipc_opened_cache_value_t *value) { umf_tracking_memory_provider_t *p = (umf_tracking_memory_provider_t *)key->local_provider; // umfMemoryTrackerRemove should be called before umfMemoryProviderCloseIPCHandle @@ -690,16 +700,16 @@ static umf_result_t trackingOpenIpcHandle(void *provider, void *providerIpcData, umf_ipc_data_t *ipcUmfData = getIpcDataFromIpcHandle(providerIpcData); - // Compiler may add paddings to the ipc_mapped_handle_cache_key_t structure + // Compiler may add paddings to the ipc_opened_cache_key_t structure // so we need to zero it out to avoid false cache miss. - ipc_mapped_handle_cache_key_t key = {0}; + ipc_opened_cache_key_t key = {0}; key.remote_base_ptr = ipcUmfData->base; key.local_provider = provider; key.remote_pid = ipcUmfData->pid; - ipc_mapped_handle_cache_value_t *cache_entry = NULL; - ret = umfIpcHandleMappedCacheGet(p->hIpcMappedCache, &key, - ipcUmfData->handle_id, &cache_entry); + ipc_opened_cache_value_t *cache_entry = NULL; + ret = umfIpcOpenedCacheGet(p->hIpcMappedCache, &key, ipcUmfData->handle_id, + &cache_entry); if (ret != UMF_RESULT_SUCCESS) { LOG_ERR("failed to get cache entry"); return ret; @@ -788,7 +798,7 @@ umf_result_t umfTrackingMemoryProviderCreate( } params.hIpcMappedCache = - umfIpcHandleMappedCacheCreate(ipcMappedCacheEvictionCallback); + umfIpcOpenedCacheCreate(ipcOpenedCacheEvictionCallback); LOG_DEBUG("upstream=%p, tracker=%p, " "pool=%p, ipcCache=%p, hIpcMappedCache=%p", @@ -816,33 +826,33 @@ umf_memory_tracker_handle_t umfMemoryTrackerCreate(void) { return NULL; } - umf_ba_pool_t *tracker_allocator = - umf_ba_create(sizeof(struct tracker_value_t)); - if (!tracker_allocator) { + umf_ba_pool_t *alloc_info_allocator = + umf_ba_create(sizeof(struct tracker_alloc_info_t)); + if (!alloc_info_allocator) { goto err_free_handle; } - handle->tracker_allocator = tracker_allocator; + handle->alloc_info_allocator = alloc_info_allocator; void *mutex_ptr = utils_mutex_init(&handle->splitMergeMutex); if (!mutex_ptr) { - goto err_destroy_tracker_allocator; + goto err_destroy_alloc_info_allocator; } - handle->map = critnib_new(); - if (!handle->map) { + handle->alloc_segments_map = critnib_new(); + if (!handle->alloc_segments_map) { goto err_destroy_mutex; } - LOG_DEBUG("tracker created, handle=%p, segment map=%p", (void *)handle, - (void *)handle->map); + LOG_DEBUG("tracker created, handle=%p, alloc_segments_map=%p", + (void *)handle, (void *)handle->alloc_segments_map); return handle; err_destroy_mutex: utils_mutex_destroy_not_free(&handle->splitMergeMutex); -err_destroy_tracker_allocator: - umf_ba_destroy(tracker_allocator); +err_destroy_alloc_info_allocator: + umf_ba_destroy(alloc_info_allocator); err_free_handle: umf_ba_global_free(handle); return NULL; @@ -865,10 +875,10 @@ void umfMemoryTrackerDestroy(umf_memory_tracker_handle_t handle) { // We have to zero all inner pointers, // because the tracker handle can be copied // and used in many places. - critnib_delete(handle->map); - handle->map = NULL; + critnib_delete(handle->alloc_segments_map); + handle->alloc_segments_map = NULL; utils_mutex_destroy_not_free(&handle->splitMergeMutex); - umf_ba_destroy(handle->tracker_allocator); - handle->tracker_allocator = NULL; + umf_ba_destroy(handle->alloc_info_allocator); + handle->alloc_info_allocator = NULL; umf_ba_global_free(handle); } diff --git a/src/provider/provider_tracking.h b/src/provider/provider_tracking.h index 2abc36505..9e868cf31 100644 --- a/src/provider/provider_tracking.h +++ b/src/provider/provider_tracking.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2023-2024 Intel Corporation + * Copyright (C) 2023-2025 Intel Corporation * * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -26,12 +26,7 @@ extern "C" { #endif -struct umf_memory_tracker_t { - umf_ba_pool_t *tracker_allocator; - critnib *map; - utils_mutex_t splitMergeMutex; -}; - +struct umf_memory_tracker_t; typedef struct umf_memory_tracker_t *umf_memory_tracker_handle_t; extern umf_memory_tracker_handle_t TRACKER;