Skip to content

Commit 7723d1f

Browse files
committed
Minimum size of allocation in case of /dev/dax device is 2 MB
The minimum size of an allocation in case of a /dev/dax device is 2 MB. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 0eddbd9 commit 7723d1f

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

test/ipcFixtures.hpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "pool.hpp"
1111
#include "test_helpers.h"
1212

13+
#include "umf/providers/provider_devdax_memory.h"
1314
#include <umf/ipc.h>
1415
#include <umf/memory_pool.h>
1516
#include <umf/memory_provider.h>
@@ -62,6 +63,13 @@ struct umfIpcTest : umf_test::test,
6263
providerOps = provider_ops;
6364
providerParams = provider_params;
6465
memAccessor = accessor;
66+
67+
if (provider_ops == umfDevDaxMemoryProviderOps()) {
68+
// the minimum size for a /dev/dax device is the page size == 2MB
69+
COMMON_SIZE = 2 * 1024 * 1024; // 2MB
70+
} else {
71+
COMMON_SIZE = 100;
72+
}
6573
}
6674

6775
void TearDown() override { test::TearDown(); }
@@ -120,6 +128,7 @@ struct umfIpcTest : umf_test::test,
120128
void *poolParams = nullptr;
121129
umf_memory_provider_ops_t *providerOps = nullptr;
122130
void *providerParams = nullptr;
131+
size_t COMMON_SIZE;
123132
};
124133

125134
TEST_P(umfIpcTest, GetIPCHandleSize) {
@@ -142,7 +151,7 @@ TEST_P(umfIpcTest, GetIPCHandleSizeInvalidArgs) {
142151
}
143152

144153
TEST_P(umfIpcTest, GetIPCHandleInvalidArgs) {
145-
constexpr size_t SIZE = 100;
154+
size_t SIZE = COMMON_SIZE;
146155
umf_ipc_handle_t ipcHandle = nullptr;
147156
size_t handleSize = 0;
148157
umf_result_t ret = umfGetIPCHandle(nullptr, &ipcHandle, &handleSize);
@@ -167,7 +176,7 @@ TEST_P(umfIpcTest, GetIPCHandleInvalidArgs) {
167176
}
168177

169178
TEST_P(umfIpcTest, BasicFlow) {
170-
constexpr size_t SIZE = 100;
179+
size_t SIZE = COMMON_SIZE;
171180
std::vector<int> expected_data(SIZE);
172181
umf::pool_unique_handle_t pool = makePool();
173182
int *ptr = (int *)umfPoolMalloc(pool.get(), SIZE * sizeof(int));
@@ -229,7 +238,7 @@ TEST_P(umfIpcTest, BasicFlow) {
229238
}
230239

231240
TEST_P(umfIpcTest, GetPoolByOpenedHandle) {
232-
constexpr size_t SIZE = 100;
241+
size_t SIZE = COMMON_SIZE;
233242
constexpr size_t NUM_ALLOCS = 100;
234243
constexpr size_t NUM_POOLS = 4;
235244
void *ptrs[NUM_ALLOCS];
@@ -287,7 +296,7 @@ TEST_P(umfIpcTest, GetPoolByOpenedHandle) {
287296
}
288297

289298
TEST_P(umfIpcTest, AllocFreeAllocTest) {
290-
constexpr size_t SIZE = 64 * 1024;
299+
size_t SIZE = (64 * 1024 > COMMON_SIZE) ? 64 * 1024 : COMMON_SIZE;
291300
umf::pool_unique_handle_t pool = makePool();
292301
void *ptr = umfPoolMalloc(pool.get(), SIZE);
293302
EXPECT_NE(ptr, nullptr);
@@ -340,7 +349,7 @@ TEST_P(umfIpcTest, AllocFreeAllocTest) {
340349
}
341350

342351
TEST_P(umfIpcTest, openInTwoPools) {
343-
constexpr size_t SIZE = 100;
352+
size_t SIZE = COMMON_SIZE;
344353
std::vector<int> expected_data(SIZE);
345354
umf::pool_unique_handle_t pool1 = makePool();
346355
umf::pool_unique_handle_t pool2 = makePool();
@@ -394,7 +403,7 @@ TEST_P(umfIpcTest, openInTwoPools) {
394403

395404
TEST_P(umfIpcTest, ConcurrentGetPutHandles) {
396405
std::vector<void *> ptrs;
397-
constexpr size_t ALLOC_SIZE = 100;
406+
size_t ALLOC_SIZE = COMMON_SIZE;
398407
constexpr size_t NUM_POINTERS = 100;
399408
umf::pool_unique_handle_t pool = makePool();
400409

@@ -442,7 +451,7 @@ TEST_P(umfIpcTest, ConcurrentGetPutHandles) {
442451

443452
TEST_P(umfIpcTest, ConcurrentOpenCloseHandles) {
444453
std::vector<void *> ptrs;
445-
constexpr size_t ALLOC_SIZE = 100;
454+
size_t ALLOC_SIZE = COMMON_SIZE;
446455
constexpr size_t NUM_POINTERS = 100;
447456
umf::pool_unique_handle_t pool = makePool();
448457

0 commit comments

Comments
 (0)