Skip to content

Commit 1e91899

Browse files
committed
x
1 parent e59eee4 commit 1e91899

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

src/ipc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ umf_result_t umfGetIPCHandle(const void *ptr, umf_ipc_handle_t *umfIPCHandle,
5858
}
5959

6060
size_t ipcHandleSize = 0;
61-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
61+
umf_alloc_info_t allocInfo = {NULL};
6262
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
6363
if (ret != UMF_RESULT_SUCCESS) {
6464
LOG_ERR("cannot get alloc info for ptr = %p.", ptr);
@@ -92,8 +92,8 @@ umf_result_t umfGetIPCHandle(const void *ptr, umf_ipc_handle_t *umfIPCHandle,
9292
}
9393
umf_memory_provider_handle_t provider = allocInfo.props->pool->provider;
9494

95-
ret = umfMemoryProviderGetIPCHandle(provider, allocInfo.base,
96-
allocInfo.baseSize,
95+
ret = umfMemoryProviderGetIPCHandle(provider, allocInfo.props->base,
96+
allocInfo.props->base_size,
9797
(void *)ipcData->providerIpcData);
9898
if (ret != UMF_RESULT_SUCCESS) {
9999
LOG_ERR("failed to get IPC handle.");
@@ -102,10 +102,10 @@ umf_result_t umfGetIPCHandle(const void *ptr, umf_ipc_handle_t *umfIPCHandle,
102102
}
103103

104104
// ipcData->handle_id is filled by tracking provider
105-
ipcData->base = allocInfo.base;
105+
ipcData->base = allocInfo.props->base;
106106
ipcData->pid = utils_getpid();
107-
ipcData->baseSize = allocInfo.baseSize;
108-
ipcData->offset = (uintptr_t)ptr - (uintptr_t)allocInfo.base;
107+
ipcData->baseSize = allocInfo.props->base_size;
108+
ipcData->offset = (uintptr_t)ptr - (uintptr_t)allocInfo.props->base;
109109

110110
*umfIPCHandle = ipcData;
111111
*size = ipcHandleSize;

src/memory_props.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ umfGetMemoryPropertiesHandle(const void *ptr,
2323
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
2424
}
2525

26-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
26+
umf_alloc_info_t allocInfo = {NULL};
2727
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
2828
if (ret != UMF_RESULT_SUCCESS) {
2929
return UMF_RESULT_ERROR_INVALID_ARGUMENT;

src/pool/pool_disjoint.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,13 +884,19 @@ size_t disjoint_pool_malloc_usable_size(void *pool, const void *ptr) {
884884
critnib_release(disjoint_pool->known_slabs, ref_slab);
885885
}
886886

887-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
887+
umf_alloc_info_t allocInfo = {NULL};
888888
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
889889
if (ret != UMF_RESULT_SUCCESS) {
890890
return 0;
891891
}
892892

893-
return allocInfo.baseSize;
893+
if (allocInfo.props == NULL) {
894+
TLS_last_allocation_error = UMF_RESULT_ERROR_UNKNOWN;
895+
LOG_ERR("failed to get allocation info from the memory tracker");
896+
return 0;
897+
}
898+
899+
return allocInfo.props->base_size;
894900
}
895901

896902
// Get the unaligned pointer
@@ -925,15 +931,15 @@ umf_result_t disjoint_pool_free(void *pool, void *ptr) {
925931
critnib_release(disjoint_pool->known_slabs, ref_slab);
926932
}
927933

928-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
934+
umf_alloc_info_t allocInfo = {NULL};
929935
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
930936
if (ret != UMF_RESULT_SUCCESS) {
931937
TLS_last_allocation_error = ret;
932938
LOG_ERR("failed to get allocation info from the memory tracker");
933939
return ret;
934940
}
935941

936-
size_t size = allocInfo.baseSize;
942+
size_t size = allocInfo.props->base_size;
937943
umf_memory_provider_handle_t provider = disjoint_pool->provider;
938944
ret = umfMemoryProviderFree(provider, ptr, size);
939945
if (ret != UMF_RESULT_SUCCESS) {

src/pool/pool_proxy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ static umf_result_t proxy_free(void *pool, void *ptr) {
9797
struct proxy_memory_pool *hPool = (struct proxy_memory_pool *)pool;
9898

9999
if (ptr) {
100-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
100+
umf_alloc_info_t allocInfo = {NULL};
101101
umf_result_t umf_result = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
102102
if (umf_result == UMF_RESULT_SUCCESS) {
103-
size = allocInfo.baseSize;
103+
size = allocInfo.props->base_size;
104104
}
105105
}
106106

src/provider/provider_tracking.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ umfMemoryTrackerRemoveIpcSegment(umf_memory_tracker_handle_t hTracker,
471471
}
472472

473473
umf_memory_pool_handle_t umfMemoryTrackerGetPool(const void *ptr) {
474-
umf_alloc_info_t allocInfo = {NULL, 0, NULL};
474+
umf_alloc_info_t allocInfo = {NULL};
475475
umf_result_t ret = umfMemoryTrackerGetAllocInfo(ptr, &allocInfo);
476476
if (ret != UMF_RESULT_SUCCESS || allocInfo.props == NULL) {
477477
return NULL;
@@ -500,7 +500,7 @@ umf_result_t umfMemoryTrackerGetAllocInfo(const void *ptr,
500500

501501
tracker_alloc_info_t *top_most_value = NULL;
502502
tracker_alloc_info_t *rvalue = NULL;
503-
uintptr_t top_most_key = 0;
503+
//uintptr_t top_most_key = 0;
504504
uintptr_t rkey = 0;
505505
uint64_t rsize = 0;
506506
size_t n_children = 0;
@@ -526,7 +526,7 @@ umf_result_t umfMemoryTrackerGetAllocInfo(const void *ptr,
526526
critnib_release(TRACKER->alloc_segments_map[level], ref_value);
527527
}
528528
top_most_value = NULL;
529-
top_most_key = 0;
529+
//top_most_key = 0;
530530
rkey = 0;
531531
rsize = 0;
532532
level = 0;
@@ -541,7 +541,7 @@ umf_result_t umfMemoryTrackerGetAllocInfo(const void *ptr,
541541
&rsize);
542542
utils_atomic_load_acquire_size_t(&rvalue->n_children, &n_children);
543543
if (found && (uintptr_t)ptr < rkey + rsize) {
544-
top_most_key = rkey;
544+
//top_most_key = rkey;
545545
top_most_value = rvalue;
546546
if (ref_top_most_value) {
547547
assert(level >= 1);
@@ -568,8 +568,6 @@ umf_result_t umfMemoryTrackerGetAllocInfo(const void *ptr,
568568
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
569569
}
570570

571-
pAllocInfo->base = (void *)top_most_key;
572-
pAllocInfo->baseSize = top_most_value->props.base_size;
573571
pAllocInfo->props = &top_most_value->props;
574572

575573
assert(ref_top_most_value);

src/provider/provider_tracking.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ void umfMemoryTrackerDestroy(umf_memory_tracker_handle_t handle);
3838
umf_memory_pool_handle_t umfMemoryTrackerGetPool(const void *ptr);
3939

4040
typedef struct umf_alloc_info_t {
41-
void *base;
42-
size_t baseSize;
43-
4441
umf_memory_properties_handle_t props;
4542
} umf_alloc_info_t;
4643

0 commit comments

Comments
 (0)