Skip to content

Commit f8bf899

Browse files
authored
Merge pull request #761 from bratpiorka/rrudnick_proxy_tracking_flag
enable tracker in ProxyLib by default
2 parents d69a241 + 09ee70e commit f8bf899

9 files changed

+325
-29
lines changed

.github/workflows/reusable_basic.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ jobs:
210210
--build-type ${{matrix.build_type}}
211211
--disjoint-pool
212212
--jemalloc-pool
213-
${{ matrix.install_tbb == 'ON' && matrix.disable_hwloc != 'ON' && matrix.link_hwloc_statically != 'ON' && '--proxy' || '' }}
213+
${{ matrix.install_tbb == 'ON' && matrix.disable_hwloc != 'ON' && matrix.shared_library == 'ON' && '--proxy' || '' }}
214214
--umf-version ${{env.UMF_VERSION}}
215215
${{ matrix.shared_library == 'ON' && '--shared-library' || '' }}
216216
@@ -300,7 +300,7 @@ jobs:
300300
--build-type ${{matrix.build_type}}
301301
--disjoint-pool
302302
--jemalloc-pool
303-
--proxy
303+
${{matrix.shared_library == 'ON' && '--proxy' || '' }}
304304
--umf-version ${{env.UMF_VERSION}}
305305
${{ matrix.shared_library == 'ON' && '--shared-library' || ''}}
306306
@@ -310,7 +310,7 @@ jobs:
310310
shell: pwsh
311311

312312
- name: check /DEPENDENTLOADFLAG in umf_proxy.dll
313-
if: ${{matrix.compiler.cxx == 'cl'}}
313+
if: ${{matrix.shared_library == 'ON' && matrix.compiler.cxx == 'cl'}}
314314
run: ${{github.workspace}}/.github/scripts/check_dll_flags.ps1 ${{env.BUILD_DIR}}/src/proxy_lib/${{matrix.build_type}}/umf_proxy.dll
315315
shell: pwsh
316316

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,17 @@ if(WINDOWS)
432432
)
433433
endif()
434434
endif()
435+
435436
# set UMF_PROXY_LIB_ENABLED
436-
if(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
437+
if(UMF_DISABLE_HWLOC)
438+
message(STATUS "Disabling the proxy library, because HWLOC is disabled")
439+
elseif(NOT UMF_BUILD_SHARED_LIBRARY)
440+
# TODO enable this scenario
441+
message(
442+
STATUS
443+
"Disabling the proxy library, because UMF is built as static library"
444+
)
445+
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
437446
if(UMF_POOL_SCALABLE_ENABLED)
438447
set(UMF_PROXY_LIB_ENABLED ON)
439448
set(PROXY_LIB_USES_SCALABLE_POOL ON)

src/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ install(TARGETS umf EXPORT ${PROJECT_NAME}-targets)
195195

196196
add_subdirectory(pool)
197197

198-
if(UMF_PROXY_LIB_ENABLED
199-
AND NOT UMF_LINK_HWLOC_STATICALLY
200-
AND NOT UMF_DISABLE_HWLOC)
198+
if(UMF_PROXY_LIB_ENABLED)
201199
add_subdirectory(proxy_lib)
202200
endif()

src/provider/provider_devdax_memory.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,9 @@ static umf_result_t devdax_allocation_split(void *provider, void *ptr,
360360

361361
static umf_result_t devdax_allocation_merge(void *provider, void *lowPtr,
362362
void *highPtr, size_t totalSize) {
363-
(void)provider;
364-
365-
if ((uintptr_t)highPtr <= (uintptr_t)lowPtr) {
366-
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
367-
}
368-
369-
if ((uintptr_t)highPtr - (uintptr_t)lowPtr <= totalSize) {
363+
if (provider == NULL || lowPtr == NULL || highPtr == NULL ||
364+
((uintptr_t)highPtr <= (uintptr_t)lowPtr) ||
365+
((uintptr_t)highPtr - (uintptr_t)lowPtr >= totalSize)) {
370366
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
371367
}
372368

src/provider/provider_tracking.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ static umf_result_t umfMemoryTrackerAdd(umf_memory_tracker_handle_t hTracker,
4848
int ret = critnib_insert(hTracker->map, (uintptr_t)ptr, value, 0);
4949

5050
if (ret == 0) {
51-
LOG_DEBUG("memory region is added, tracker=%p, ptr=%p, size=%zu",
52-
(void *)hTracker, ptr, size);
51+
LOG_DEBUG(
52+
"memory region is added, tracker=%p, ptr=%p, pool=%p, size=%zu",
53+
(void *)hTracker, ptr, (void *)pool, size);
5354
return UMF_RESULT_SUCCESS;
5455
}
5556

56-
LOG_ERR("failed to insert tracker value, ret=%d, ptr=%p, size=%zu", ret,
57-
ptr, size);
57+
LOG_ERR("failed to insert tracker value, ret=%d, ptr=%p, pool=%p, size=%zu",
58+
ret, ptr, (void *)pool, size);
5859

5960
umf_ba_free(hTracker->tracker_allocator, value);
6061

@@ -303,8 +304,8 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr,
303304
ret = umfMemoryProviderAllocationMerge(provider->hUpstream, lowPtr, highPtr,
304305
totalSize);
305306
if (ret != UMF_RESULT_SUCCESS) {
306-
LOG_ERR("upstream provider failed to merge regions");
307-
goto err;
307+
LOG_WARN("upstream provider failed to merge regions");
308+
goto not_merged;
308309
}
309310

310311
// We'll have a duplicate entry for the range [highPtr, highValue->size] but this is fine,
@@ -329,7 +330,11 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr,
329330
return UMF_RESULT_SUCCESS;
330331

331332
err:
333+
assert(0);
334+
335+
not_merged:
332336
utils_mutex_unlock(&provider->hTracker->splitMergeMutex);
337+
333338
err_lock:
334339
umf_ba_free(provider->hTracker->tracker_allocator, mergedValue);
335340
return ret;

src/proxy_lib/proxy_lib.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ void proxy_lib_create_common(void) {
124124

125125
} else if (utils_env_var_has_str("UMF_PROXY",
126126
"page.disposition=shared-shm")) {
127-
LOG_DEBUG("proxy_lib: using the MAP_SHARED visibility mode with the "
128-
"named shared memory");
129127
os_params.visibility = UMF_MEM_MAP_SHARED;
130128

131129
memset(shm_name, 0, NAME_MAX);
@@ -145,9 +143,8 @@ void proxy_lib_create_common(void) {
145143
exit(-1);
146144
}
147145

148-
umf_result =
149-
umfPoolCreate(umfPoolManagerOps(), OS_memory_provider, NULL,
150-
UMF_POOL_CREATE_FLAG_DISABLE_TRACKING, &Proxy_pool);
146+
umf_result = umfPoolCreate(umfPoolManagerOps(), OS_memory_provider, NULL, 0,
147+
&Proxy_pool);
151148
if (umf_result != UMF_RESULT_SUCCESS) {
152149
LOG_ERR("creating UMF pool manager failed");
153150
exit(-1);

test/CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,7 @@ add_umf_test(
408408
LIBS ${UMF_UTILS_FOR_TEST})
409409

410410
# tests for the proxy library
411-
if(UMF_PROXY_LIB_ENABLED
412-
AND UMF_BUILD_SHARED_LIBRARY
413-
AND NOT UMF_DISABLE_HWLOC
414-
AND NOT UMF_LINK_HWLOC_STATICALLY)
411+
if(UMF_PROXY_LIB_ENABLED AND UMF_BUILD_SHARED_LIBRARY)
415412
add_umf_test(
416413
NAME proxy_lib_basic
417414
SRCS ${BA_SOURCES_FOR_TEST} test_proxy_lib.cpp
@@ -486,6 +483,18 @@ if(LINUX)
486483
add_umf_ipc_test(TEST ipc_os_prov_anon_fd)
487484
add_umf_ipc_test(TEST ipc_os_prov_shm)
488485

486+
if(UMF_PROXY_LIB_ENABLED AND UMF_BUILD_SHARED_LIBRARY)
487+
build_umf_test(
488+
NAME
489+
ipc_os_prov_proxy
490+
SRCS
491+
ipc_os_prov_proxy.c
492+
common/ipc_common.c
493+
LIBS
494+
${UMF_UTILS_FOR_TEST})
495+
add_umf_ipc_test(TEST ipc_os_prov_proxy)
496+
endif()
497+
489498
build_umf_test(
490499
NAME
491500
ipc_devdax_prov_consumer

0 commit comments

Comments
 (0)