Skip to content

Commit 7ca67f7

Browse files
committed
Add devdax memory provider
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 4f57234 commit 7ca67f7

11 files changed

+1125
-0
lines changed

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ option(UMF_FORMAT_CODE_STYLE
6161
OFF)
6262
# Only a part of skips is treated as a failure now. TODO: extend to all tests
6363
option(UMF_TESTS_FAIL_ON_SKIP "Treat skips in tests as fail" OFF)
64+
set(UMF_TESTS_DEVDAX_PATH
65+
""
66+
CACHE
67+
PATH
68+
"Path of the device DAX used in tests. The test is skipped if it is not set or empty."
69+
)
70+
set(UMF_TESTS_DEVDAX_SIZE
71+
""
72+
CACHE
73+
STRING
74+
"Size of the device DAX used in tests. The test is skipped if it is not set or empty."
75+
)
6476
option(UMF_USE_ASAN "Enable AddressSanitizer checks" OFF)
6577
option(UMF_USE_UBSAN "Enable UndefinedBehaviorSanitizer checks" OFF)
6678
option(UMF_USE_TSAN "Enable ThreadSanitizer checks" OFF)
@@ -402,11 +414,20 @@ endif()
402414

403415
if(NOT UMF_DISABLE_HWLOC)
404416
add_optional_symbol(umfOsMemoryProviderOps)
417+
if(LINUX)
418+
add_optional_symbol(umfDevDaxMemoryProviderOps)
419+
endif()
405420
endif()
406421

407422
add_subdirectory(src)
408423

409424
if(UMF_BUILD_TESTS)
425+
if(UMF_TESTS_DEVDAX_PATH OR UMF_TESTS_DEVDAX_SIZE)
426+
message(
427+
STATUS "UMF_TESTS_DEVDAX_PATH is set to: ${UMF_TESTS_DEVDAX_PATH}")
428+
message(
429+
STATUS "UMF_TESTS_DEVDAX_SIZE is set to: ${UMF_TESTS_DEVDAX_SIZE}")
430+
endif()
410431
add_subdirectory(test)
411432
endif()
412433

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ List of options provided by CMake:
112112
| UMF_DEVELOPER_MODE | Enable additional developer checks | ON/OFF | OFF |
113113
| UMF_FORMAT_CODE_STYLE | Add clang, cmake, and black -format-check and -format-apply targets to make | ON/OFF | OFF |
114114
| UMF_TESTS_FAIL_ON_SKIP | Treat skips in tests as fail | ON/OFF | OFF |
115+
| UMF_TESTS_DEVDAX_PATH | Path of the device DAX used in tests. The test is skipped if it is not set or empty. | path | "" |
116+
| UMF_TESTS_DEVDAX_SIZE | Size of the device DAX used in tests. The test is skipped if it is not set or empty. | size | "" |
115117
| UMF_USE_ASAN | Enable AddressSanitizer checks | ON/OFF | OFF |
116118
| UMF_USE_UBSAN | Enable UndefinedBehaviorSanitizer checks | ON/OFF | OFF |
117119
| UMF_USE_TSAN | Enable ThreadSanitizer checks | ON/OFF | OFF |
@@ -172,6 +174,24 @@ Additionally, required for tests:
172174
5) Required packages:
173175
- liblevel-zero-dev (Linux) or level-zero-sdk (Windows)
174176

177+
#### DevDax memory provider (Linux only)
178+
179+
A memory provider that provides memory from a device DAX (a character device file /dev/daxX.Y).
180+
It can be used when gigantic memory mappings are needed.
181+
182+
The DevDax memory provider does not support the free operation
183+
(`umfMemoryProviderFree()` always returns `UMF_RESULT_ERROR_NOT_SUPPORTED`),
184+
so it should be used with a pool manager that will take over
185+
the managing of the provided memory - for example the jemalloc pool
186+
with the `disable_provider_free` parameter set to true.
187+
188+
##### Requirements
189+
190+
1) Linux OS
191+
2) A character device file /dev/daxX.Y created in the OS.
192+
3) `UMF_TESTS_DEVDAX_PATH` set to the path of the device DAX ("/dev/daxX.Y").
193+
4) `UMF_TESTS_DEVDAX_SIZE` set to the size of the "/dev/daxX.Y" device DAX.
194+
175195
### Memory pool managers
176196

177197
#### Proxy pool (part of libumf)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (C) 2024 Intel Corporation
3+
*
4+
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
5+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
*/
7+
8+
#ifndef UMF_DEVDAX_MEMORY_PROVIDER_H
9+
#define UMF_DEVDAX_MEMORY_PROVIDER_H
10+
11+
#include "umf/memory_provider.h"
12+
#include <umf/providers/provider_os_memory.h>
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#endif
17+
18+
/// @cond
19+
#define UMF_DEVDAX_RESULTS_START_FROM 2000
20+
/// @endcond
21+
22+
/// @brief Memory provider settings struct
23+
typedef struct umf_devdax_memory_provider_params_t {
24+
/// path of the device DAX
25+
char *path;
26+
/// size of the device DAX
27+
size_t size;
28+
/// combination of 'umf_mem_protection_flags_t' flags
29+
unsigned protection;
30+
} umf_devdax_memory_provider_params_t;
31+
32+
/// @brief Devdax Memory Provider operation results
33+
typedef enum umf_devdax_memory_provider_native_error {
34+
UMF_DEVDAX_RESULT_SUCCESS = UMF_DEVDAX_RESULTS_START_FROM, ///< Success
35+
UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED, ///< Memory allocation failed
36+
UMF_DEVDAX_RESULT_ERROR_ADDRESS_NOT_ALIGNED, ///< Allocated address is not aligned
37+
UMF_DEVDAX_RESULT_ERROR_FREE_FAILED, ///< Memory deallocation failed
38+
UMF_DEVDAX_RESULT_ERROR_PURGE_LAZY_FAILED, ///< Lazy purging failed
39+
UMF_DEVDAX_RESULT_ERROR_PURGE_FORCE_FAILED, ///< Force purging failed
40+
} umf_devdax_memory_provider_native_error_t;
41+
42+
umf_memory_provider_ops_t *umfDevDaxMemoryProviderOps(void);
43+
44+
/// @brief Create default params for os memory provider
45+
static inline umf_devdax_memory_provider_params_t
46+
umfDevDaxMemoryProviderParamsDefault(char *path, size_t size) {
47+
umf_devdax_memory_provider_params_t params = {
48+
path, /* path of the device DAX */
49+
size, /* size of the device DAX */
50+
UMF_PROTECTION_READ | UMF_PROTECTION_WRITE, /* protection */
51+
};
52+
53+
return params;
54+
}
55+
56+
#ifdef __cplusplus
57+
}
58+
#endif
59+
60+
#endif /* UMF_DEVDAX_MEMORY_PROVIDER_H */

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ set(UMF_SOURCES_MACOSX libumf_linux.c)
8989
set(UMF_SOURCES_WINDOWS libumf_windows.c)
9090

9191
set(UMF_SOURCES_COMMON_LINUX_MACOSX
92+
provider/provider_devdax_memory.c
9293
provider/provider_os_memory.c
9394
provider/provider_os_memory_posix.c
9495
memtargets/memtarget_numa.c

0 commit comments

Comments
 (0)