1717#include "memory_provider_internal.h"
1818#include "provider/provider_tracking.h"
1919
20+ // TODO flag - IPC?
2021umf_result_t
2122umfGetMemoryPropertiesHandle (const void * ptr ,
2223 umf_memory_properties_handle_t * props_handle ) {
2324
24- LOG_DEBUG ("umfGetMemoryPropertiesHandle: ptr=%p, props_handle=%p" , ptr ,
25- props_handle );
25+ // LOG_DEBUG("umfGetMemoryPropertiesHandle: ptr=%p, props_handle=%p", ptr,
26+ // props_handle);
2627
2728 if (props_handle == NULL ) {
2829 return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
2930 }
3031
3132 tracker_alloc_info_t * info = NULL ;
3233 umf_result_t ret = umfMemoryTrackerGetAllocInfo (ptr , & info );
33- if (ret != UMF_RESULT_SUCCESS ) {
34- return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
34+
35+ if (ret == UMF_RESULT_SUCCESS ) {
36+ * props_handle = & info -> props ;
37+ //LOG_DEBUG("umfGetMemoryPropertiesHandle: props_handle=%p, id=%" PRIu64,
38+ // *props_handle, (*props_handle)->id);
39+ return UMF_RESULT_SUCCESS ;
3540 }
3641
37- * props_handle = & info -> props ;
42+ // try to get IPC info
43+ umf_ipc_info_t ipc_info ;
44+ ret = umfMemoryTrackerGetIpcInfo (ptr , & ipc_info );
45+ if (ret != UMF_RESULT_SUCCESS ) {
46+ LOG_ERR ("Failed to get memory properties handle for ptr=%p" , ptr );
47+ return ret ;
48+ }
3849
39- LOG_DEBUG ("umfGetMemoryPropertiesHandle: props_handle=%p, id=%" PRIu64 ,
40- * props_handle , (* props_handle )-> id );
50+ * props_handle = ipc_info .props ;
51+ //LOG_DEBUG(
52+ // "umfGetMemoryPropertiesHandle (IPC info): props_handle=%p, id=%" PRIu64,
53+ // *props_handle, (*props_handle)->id);
4154
4255 return UMF_RESULT_SUCCESS ;
4356}
@@ -46,20 +59,24 @@ umf_result_t umfGetMemoryProperty(umf_memory_properties_handle_t props_handle,
4659 umf_memory_property_id_t memory_property_id ,
4760 size_t max_property_size , void * value ) {
4861
62+ /*
4963 LOG_DEBUG("umfGetMemoryProperty: props_handle=%p, memory_property_id=%d, "
5064 "max_property_size=%zu, value=%p",
5165 props_handle, memory_property_id, max_property_size, value);
66+ */
5267
5368 if ((value == NULL ) || (props_handle == NULL ) || (max_property_size == 0 )) {
5469 return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
5570 }
5671
5772 umf_memory_provider_t * provider = props_handle -> provider ;
5873
74+ /*
5975 LOG_DEBUG("umfGetMemoryProperty: provider=%p", provider);
6076 LOG_DEBUG("dereferencing value...");
6177
6278 LOG_DEBUG("value: %zu", *(size_t *)value);
79+ */
6380
6481 switch (memory_property_id ) {
6582 case UMF_MEMORY_PROPERTY_INVALID :
0 commit comments