Skip to content

Commit 8319da7

Browse files
committed
Add devdax memory provider
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 8a74b8f commit 8319da7

11 files changed

+1114
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ endif()
419419

420420
if(NOT UMF_DISABLE_HWLOC)
421421
add_optional_symbol(umfOsMemoryProviderOps)
422+
if(LINUX)
423+
add_optional_symbol(umfDevDaxMemoryProviderOps)
424+
endif()
422425
endif()
423426

424427
add_subdirectory(src)

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,24 @@ Additionally, required for tests:
172172
5) Required packages:
173173
- liblevel-zero-dev (Linux) or level-zero-sdk (Windows)
174174

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

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

src/CMakeLists.txt

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

100100
set(UMF_SOURCES_COMMON_LINUX_MACOSX
101+
provider/provider_devdax_memory.c
101102
provider/provider_os_memory.c
102103
provider/provider_os_memory_posix.c
103104
memtargets/memtarget_numa.c

0 commit comments

Comments
 (0)