Skip to content

Commit 608f7a4

Browse files
committed
Add free() to the devdax provider
1 parent b91149c commit 608f7a4

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/provider/provider_devdax_memory.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ static umf_result_t devdax_alloc(void *provider, size_t size, size_t alignment,
530530
return coarse_alloc(devdax_provider->coarse, size, alignment, resultPtr);
531531
}
532532

533+
static umf_result_t devdax_free(void *provider, void *ptr, size_t size) {
534+
devdax_memory_provider_t *devdax_provider =
535+
(devdax_memory_provider_t *)provider;
536+
return coarse_free(devdax_provider->coarse, ptr, size);
537+
}
538+
533539
static umf_result_t devdax_allocation_split(void *provider, void *ptr,
534540
size_t totalSize,
535541
size_t firstSize) {
@@ -554,6 +560,7 @@ static umf_memory_provider_ops_t UMF_DEVDAX_MEMORY_PROVIDER_OPS = {
554560
.get_recommended_page_size = devdax_get_recommended_page_size,
555561
.get_min_page_size = devdax_get_min_page_size,
556562
.get_name = devdax_get_name,
563+
.ext.free = devdax_free,
557564
.ext.purge_lazy = devdax_purge_lazy,
558565
.ext.purge_force = devdax_purge_force,
559566
.ext.allocation_merge = devdax_allocation_merge,

test/provider_devdax_memory.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static void test_alloc_free_success(umf_memory_provider_handle_t provider,
110110
}
111111

112112
umf_result = umfMemoryProviderFree(provider, ptr, size);
113-
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_NOT_SUPPORTED);
113+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
114114
}
115115

116116
static void verify_last_native_error(umf_memory_provider_handle_t provider,
@@ -169,7 +169,7 @@ TEST_F(test, test_if_mapped_with_MAP_SYNC) {
169169
bool flag_found = is_mapped_with_MAP_SYNC(path, buf, size);
170170

171171
umf_result = umfMemoryProviderFree(hProvider, buf, size);
172-
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_NOT_SUPPORTED);
172+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
173173

174174
umfMemoryProviderDestroy(hProvider);
175175

@@ -274,20 +274,20 @@ TEST_P(umfProviderTest, get_name) {
274274
TEST_P(umfProviderTest, free_size_0_ptr_not_null) {
275275
umf_result_t umf_result =
276276
umfMemoryProviderFree(provider.get(), INVALID_PTR, 0);
277-
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_NOT_SUPPORTED);
277+
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
278278
}
279279

280280
TEST_P(umfProviderTest, free_NULL) {
281281
umf_result_t umf_result = umfMemoryProviderFree(provider.get(), nullptr, 0);
282-
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_NOT_SUPPORTED);
282+
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
283283
}
284284

285285
// other negative tests
286286

287287
TEST_P(umfProviderTest, free_INVALID_POINTER_SIZE_GT_0) {
288288
umf_result_t umf_result =
289289
umfMemoryProviderFree(provider.get(), INVALID_PTR, page_plus_64);
290-
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_NOT_SUPPORTED);
290+
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
291291
}
292292

293293
TEST_P(umfProviderTest, purge_lazy_INVALID_POINTER) {

test/provider_devdax_memory_ipc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static std::vector<ipcTestParams> getIpcProxyPoolTestParamsList(void) {
3939

4040
ipcProxyPoolTestParamsList = {
4141
{umfProxyPoolOps(), nullptr, umfDevDaxMemoryProviderOps(),
42-
&defaultDevDaxParams, &hostAccessor, true},
42+
&defaultDevDaxParams, &hostAccessor, false},
4343
#ifdef UMF_POOL_JEMALLOC_ENABLED
4444
{umfJemallocPoolOps(), nullptr, umfDevDaxMemoryProviderOps(),
4545
&defaultDevDaxParams, &hostAccessor, false},

0 commit comments

Comments
 (0)