Skip to content

Commit 03cfaa1

Browse files
committed
Add devdax memory provider
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 720c8a2 commit 03cfaa1

11 files changed

+1112
-0
lines changed

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ option(UMF_FORMAT_CODE_STYLE
5757
OFF)
5858
# Only a part of skips is treated as a failure now. TODO: extend to all tests
5959
option(UMF_TESTS_FAIL_ON_SKIP "Treat skips in tests as fail" OFF)
60+
set(UMF_TESTS_DEVDAX_PATH
61+
""
62+
CACHE
63+
PATH
64+
"Path of the devdax used in tests. The test is skipped if it is not set or empty."
65+
)
66+
set(UMF_TESTS_DEVDAX_SIZE
67+
""
68+
CACHE
69+
STRING
70+
"Size of the devdax used in tests. The test is skipped if it is not set or empty."
71+
)
6072
option(UMF_USE_ASAN "Enable AddressSanitizer checks" OFF)
6173
option(UMF_USE_UBSAN "Enable UndefinedBehaviorSanitizer checks" OFF)
6274
option(UMF_USE_TSAN "Enable ThreadSanitizer checks" OFF)
@@ -401,11 +413,20 @@ endif()
401413

402414
if(NOT UMF_DISABLE_HWLOC)
403415
add_optional_symbol(umfOsMemoryProviderOps)
416+
if(LINUX)
417+
add_optional_symbol(umfDevDaxMemoryProviderOps)
418+
endif()
404419
endif()
405420

406421
add_subdirectory(src)
407422

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

README.md

Lines changed: 2 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 devdax used in tests. The test is skipped if it is not set or empty. | path | "" |
116+
| UMF_TESTS_DEVDAX_SIZE | Size of the devdax 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 |
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 devdax
25+
char *path;
26+
/// size of the devdax
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 devdax */
49+
size, /* size of the devdax */
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)