diff --git a/src/deps/miniasync/doc/CMakeLists.txt b/src/deps/miniasync/doc/CMakeLists.txt index f2bdec497afa1784ce681a4e437fb46a810aaa5d..fcf0d157ca4930beb17616cdc53fd49704e4a389 100644 --- a/src/deps/miniasync/doc/CMakeLists.txt +++ b/src/deps/miniasync/doc/CMakeLists.txt @@ -68,8 +68,11 @@ if(PANDOC) runtime_wait_multiple) # install manpages - install(FILES ${MAN_DIR}/miniasync.7 - DESTINATION ${CMAKE_INSTALL_MANDIR}/man7) + install(DIRECTORY ${MAN_DIR}/ + DESTINATION ${CMAKE_INSTALL_MANDIR}/man7 + FILES_MATCHING + PATTERN "*.7" + PATTERN "tmp" EXCLUDE) install(DIRECTORY ${MAN_DIR}/ DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 FILES_MATCHING diff --git a/src/deps/miniasync/doc/vdm_is_supported.3.md b/src/deps/miniasync/doc/vdm_is_supported.3.md new file mode 100644 index 0000000000000000000000000000000000000000..94480ec3d6241ec2df892325e89aeb5ae1c1ee2f --- /dev/null +++ b/src/deps/miniasync/doc/vdm_is_supported.3.md @@ -0,0 +1,50 @@ +--- +layout: manual +Content-Style: 'text/css' +title: _MP(VDM_IS_SUPPORTED, 3) +collection: miniasync +header: VDM_IS_SUPPORTED +secondary_title: miniasync +... + +[comment]: <> (SPDX-License-Identifier: BSD-3-Clause) +[comment]: <> (Copyright 2022, Intel Corporation) + +[comment]: <> (vdm_is_supported.3 -- man page for miniasync vdm_is_supported operation) + +[NAME](#name)<br /> +[SYNOPSIS](#synopsis)<br /> +[DESCRIPTION](#description)<br /> +[RETURN VALUE](#return-value)<br /> +[SEE ALSO](#see-also)<br /> + +# NAME # + +**vdm_is_supported**() - returns information if a given capability is supported + +# SYNOPSIS # + +```c +#include <libminiasync.h> + +static inline int vdm_is_supported(struct vdm *vdm, unsigned capability); + +``` + +# DESCRIPTION # +**vdm_is_supported**() verifies if the given *vdm* supports a given flag, or other capability. + +Currently vdm defines the following capabilities: +- **VDM_F_NO_CACHE_HINT** - If supported, user can pass this flag to the **vdm_memcpy**(), **vdm_memset**(), **vdm_memmove**() +functions, to hint vdm to bypass CPU cache, and write the data directly to the memory. If not supported vdm will ignore this flag. +- **VDM_F_MEM_DURABLE** -- If supported, user can pass this flag **vdm_memcpy**(), **vdm_memset**(), **vdm_memmove**() functions +to ensure that the data written has become persistent, when a future completes. + +## RETURN VALUE ## + +The **vdm_is_supported**() function returns nonzero if the given capability is supported, or zero otherwise. + +# SEE ALSO # + +**vdm_memmove**(3), **vdm_memset**(3), **miniasync**(7), **miniasync_vdm**(7), +**miniasync_vdm_dml**(7) and **<https://pmem.io>** diff --git a/src/deps/miniasync/extras/dml/data_mover_dml.c b/src/deps/miniasync/extras/dml/data_mover_dml.c index d088cadf97c4eb3c0692d95ac52fcb83eabd73a8..67384af3404dc5576f3a283dd72efaf3df67a7ce 100644 --- a/src/deps/miniasync/extras/dml/data_mover_dml.c +++ b/src/deps/miniasync/extras/dml/data_mover_dml.c @@ -11,6 +11,8 @@ #include "core/util.h" #include "libminiasync-vdm-dml.h" +#define SUPPORTED_FLAGS VDM_F_MEM_DURABLE | VDM_F_NO_CACHE_HINT + struct data_mover_dml { struct vdm base; /* must be first */ dml_path_t path; @@ -23,9 +25,9 @@ struct data_mover_dml { static void data_mover_dml_translate_flags(uint64_t flags, uint64_t *dml_flags) { - ASSERTeq((flags & ~MINIASYNC_DML_F_VALID_FLAGS), 0); + ASSERTeq((flags & ~VDM_F_VALID_FLAGS), 0); - *dml_flags = 0; + *dml_flags = DML_FLAG_PREFETCH_CACHE; for (uint64_t iflag = 1; flags > 0; iflag = iflag << 1) { if ((flags & iflag) == 0) continue; @@ -35,9 +37,11 @@ data_mover_dml_translate_flags(uint64_t flags, uint64_t *dml_flags) * write to destination is identified as write to * durable memory */ - case MINIASYNC_DML_F_MEM_DURABLE: + case VDM_F_MEM_DURABLE: *dml_flags |= DML_FLAG_DST1_DURABLE; break; + case VDM_F_NO_CACHE_HINT: + *dml_flags &= ~DML_FLAG_PREFETCH_CACHE; default: /* shouldn't be possible */ ASSERT(0); } @@ -217,6 +221,7 @@ static struct vdm data_mover_dml_vdm = { .op_delete = data_mover_dml_operation_delete, .op_check = data_mover_dml_operation_check, .op_start = data_mover_dml_operation_start, + .capabilities = SUPPORTED_FLAGS, }; /* diff --git a/src/deps/miniasync/extras/dml/include/libminiasync-vdm-dml.h b/src/deps/miniasync/extras/dml/include/libminiasync-vdm-dml.h index f4c5e68998e6e5ea96732fb3538cb2d5c90a7705..2132e0172a7dc3a3dbd192da31e1a6396926cdfb 100644 --- a/src/deps/miniasync/extras/dml/include/libminiasync-vdm-dml.h +++ b/src/deps/miniasync/extras/dml/include/libminiasync-vdm-dml.h @@ -18,12 +18,6 @@ extern "C" { #endif -/* MINIASYNC_DML flags */ -/* XXX: these flags need to be unified across all vdms */ - -#define MINIASYNC_DML_F_MEM_DURABLE (1U << 0) -#define MINIASYNC_DML_F_VALID_FLAGS (MINIASYNC_DML_F_MEM_DURABLE) - #ifdef __cplusplus } #endif diff --git a/src/deps/miniasync/src/data_mover_sync.c b/src/deps/miniasync/src/data_mover_sync.c index 3c558002f184eaf55eeea2cc6cb5db218c833124..0f4ceef1f2a3e0b02cadadf3ca952419a4ca6c76 100644 --- a/src/deps/miniasync/src/data_mover_sync.c +++ b/src/deps/miniasync/src/data_mover_sync.c @@ -11,6 +11,8 @@ #include "core/membuf.h" #include "core/out.h" +#define SUPPORTED_FLAGS 0 + struct data_mover_sync { struct vdm base; /* must be first */ @@ -134,6 +136,7 @@ static struct vdm data_mover_sync_vdm = { .op_delete = sync_operation_delete, .op_check = sync_operation_check, .op_start = sync_operation_start, + .capabilities = SUPPORTED_FLAGS, }; /* diff --git a/src/deps/miniasync/src/data_mover_threads.c b/src/deps/miniasync/src/data_mover_threads.c index 302b0a6c7a1b157e0ecc1ede1d20eda3feddbf8b..5350ce651b904346f42259a457e00b55a70a1474 100644 --- a/src/deps/miniasync/src/data_mover_threads.c +++ b/src/deps/miniasync/src/data_mover_threads.c @@ -18,6 +18,8 @@ #define DATA_MOVER_THREADS_DEFAULT_NTHREADS 12 #define DATA_MOVER_THREADS_DEFAULT_RINGBUF_SIZE 128 +#define SUPPORTED_FLAGS 0 + struct data_mover_threads_op_fns { memcpy_fn op_memcpy; memmove_fn op_memmove; @@ -271,6 +273,7 @@ static struct vdm data_mover_threads_vdm = { .op_delete = data_mover_threads_operation_delete, .op_check = data_mover_threads_operation_check, .op_start = data_mover_threads_operation_start, + .capabilities = SUPPORTED_FLAGS, }; /* diff --git a/src/deps/miniasync/src/include/libminiasync/vdm.h b/src/deps/miniasync/src/include/libminiasync/vdm.h index cbfea82a123d9bbe2247cd2281bd8e0361310a39..609b0dfcf7d349ca583f438fb1fbeace3cae1d96 100644 --- a/src/deps/miniasync/src/include/libminiasync/vdm.h +++ b/src/deps/miniasync/src/include/libminiasync/vdm.h @@ -124,6 +124,7 @@ struct vdm { vdm_operation_delete op_delete; vdm_operation_start op_start; vdm_operation_check op_check; + unsigned capabilities; }; struct vdm *vdm_synchronous_new(void); @@ -162,6 +163,19 @@ vdm_operation_impl(struct future_context *context, struct future_notifier *n) return state; } +#define VDM_F_MEM_DURABLE (1U << 0) +#define VDM_F_NO_CACHE_HINT (1U << 1) +#define VDM_F_VALID_FLAGS (VDM_F_MEM_DURABLE | VDM_F_NO_CACHE_HINT) + +/* + * vdm_is_supported -- returns if the given flag or feature is supported + */ +static inline int +vdm_is_supported(struct vdm *vdm, unsigned capability) +{ + return (vdm->capabilities && capability) == capability; +} + /* * vdm_generic_operation -- creates a new vdm future for a given generic * operation @@ -193,6 +207,7 @@ vdm_memcpy(struct vdm *vdm, void *dest, void *src, size_t n, uint64_t flags) future.data.operation.data.memcpy.flags = flags; future.data.operation.data.memcpy.n = n; future.data.operation.data.memcpy.src = src; + future.data.operation.padding = 0; future.output.type = VDM_OPERATION_MEMCPY; future.output.result = VDM_SUCCESS; future.output.output.memcpy.dest = NULL; @@ -214,6 +229,7 @@ vdm_memmove(struct vdm *vdm, void *dest, void *src, size_t n, uint64_t flags) future.data.operation.data.memmove.flags = flags; future.data.operation.data.memmove.n = n; future.data.operation.data.memmove.src = src; + future.data.operation.padding = 0; future.output.type = VDM_OPERATION_MEMMOVE; future.output.result = VDM_SUCCESS; future.output.output.memmove.dest = NULL; @@ -235,6 +251,7 @@ vdm_memset(struct vdm *vdm, void *str, int c, size_t n, uint64_t flags) future.data.operation.data.memset.flags = flags; future.data.operation.data.memset.n = n; future.data.operation.data.memset.c = c; + future.data.operation.padding = 0; future.output.type = VDM_OPERATION_MEMSET; future.output.result = VDM_SUCCESS; future.output.output.memset.str = NULL; diff --git a/src/deps/miniasync/tests/CMakeLists.txt b/src/deps/miniasync/tests/CMakeLists.txt index d1300ba51e1aaecacf9c5e5bb7e35b0cfee6d291..93e0d096f13c40815461acf38c5c35fe95179f86 100644 --- a/src/deps/miniasync/tests/CMakeLists.txt +++ b/src/deps/miniasync/tests/CMakeLists.txt @@ -59,9 +59,11 @@ add_custom_target(tests) add_flag(-Wall) add_cstyle(tests-all - ${CMAKE_CURRENT_SOURCE_DIR}/*/*.[ch]) + ${CMAKE_CURRENT_SOURCE_DIR}/*/*.[ch] + ${CMAKE_CURRENT_SOURCE_DIR}/*.[ch]) add_check_whitespace(tests-all ${CMAKE_CURRENT_SOURCE_DIR}/*/*.[ch] + ${CMAKE_CURRENT_SOURCE_DIR}/*.[ch] ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt "${CMAKE_CURRENT_SOURCE_DIR}/*/*[.cmake]" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/*[.cmake]") diff --git a/src/deps/miniasync/tests/data_mover_dml/data_mover_dml.c b/src/deps/miniasync/tests/data_mover_dml/data_mover_dml.c index 86b2b04691b716b72ce30d5f88c3681176b35a32..3d66ec05106d7ddf28986595b560e81e93020dc6 100644 --- a/src/deps/miniasync/tests/data_mover_dml/data_mover_dml.c +++ b/src/deps/miniasync/tests/data_mover_dml/data_mover_dml.c @@ -7,6 +7,7 @@ #include <libminiasync.h> #include <libminiasync-vdm-dml.h> +#include "test_helpers.h" #include "util_dml.h" static int @@ -46,7 +47,7 @@ test_dml_basic_memcpy() static int test_dml_durable_flag_memcpy() { - return dml_memcpy(DATA_MOVER_DML_SOFTWARE, MINIASYNC_DML_F_MEM_DURABLE); + return dml_memcpy(DATA_MOVER_DML_SOFTWARE, VDM_F_MEM_DURABLE); } static int @@ -55,6 +56,20 @@ test_dml_hw_path_flag_memcpy() return dml_memcpy(DATA_MOVER_DML_HARDWARE, 0); } +/* + * test_supported_flags -- test if data_mover_threads support correct flags + */ +int test_supported_flags() { + struct data_mover_dml *dmd = + data_mover_dml_new(DATA_MOVER_DML_SOFTWARE); + struct vdm *dml_mover = data_mover_dml_get_vdm(dmd); + int ret = test_flag(dml_mover, VDM_F_MEM_DURABLE, 1); + ret += test_flag(dml_mover, VDM_F_NO_CACHE_HINT, 1); + + data_mover_dml_delete(dmd); + return ret; +} + int main(void) { @@ -72,5 +87,9 @@ main(void) return ret; } + ret = test_supported_flags(); + if (ret) + return ret; + return 0; } diff --git a/src/deps/miniasync/tests/memmove_sync/memmove_sync.c b/src/deps/miniasync/tests/memmove_sync/memmove_sync.c index 31b7e72cfff15140007cb573fe9db2904d9e764f..6e059752be2f5d16ad8df5cfc683d5e0b93f598e 100644 --- a/src/deps/miniasync/tests/memmove_sync/memmove_sync.c +++ b/src/deps/miniasync/tests/memmove_sync/memmove_sync.c @@ -4,6 +4,7 @@ #include <stdlib.h> #include <string.h> #include "libminiasync.h" +#include "test_helpers.h" /* * test_basic_memmove -- tests memmove vdm operation @@ -159,6 +160,18 @@ test_memmove_overlapping(size_t size) return ret; } +/* + * test_supported_flags -- test if data_mover_sync support correct flags + */ +int test_supported_flags() { + struct data_mover_sync *dms = data_mover_sync_new(); + struct vdm *sync_mover = data_mover_sync_get_vdm(dms); + int ret = test_flag(sync_mover, VDM_F_MEM_DURABLE, 0); + ret += test_flag(sync_mover, VDM_F_NO_CACHE_HINT, 0); + data_mover_sync_delete(dms); + return ret; +} + int main(void) { @@ -166,5 +179,6 @@ main(void) test_basic_memmove() || test_memmove_overlapping(4) || test_memmove_overlapping(12) || - test_memmove_overlapping(1024); + test_memmove_overlapping(1024) || + test_supported_flags(); } diff --git a/src/deps/miniasync/tests/memmove_threads/memmove_threads.c b/src/deps/miniasync/tests/memmove_threads/memmove_threads.c index 33574ea7450b655febcf7712d4a186bd2d392ebe..86720dc748395eae7dc4f9748ac13c304e6addcf 100644 --- a/src/deps/miniasync/tests/memmove_threads/memmove_threads.c +++ b/src/deps/miniasync/tests/memmove_threads/memmove_threads.c @@ -141,6 +141,18 @@ test_thread_memmove_multiple(size_t str_len) return ret; } +/* + * test_supported_flags -- test if data_mover_threads support correct flags + */ +int test_supported_flags() { + struct data_mover_threads *dmt = data_mover_threads_default(); + struct vdm *thread_mover = data_mover_threads_get_vdm(dmt); + int ret = test_flag(thread_mover, VDM_F_MEM_DURABLE, 0); + data_mover_threads_delete(dmt); + + return ret; +} + int main(void) { @@ -150,5 +162,6 @@ main(void) test_thread_memmove_single(50000000) || test_thread_memmove_multiple(10000000) || test_thread_memmove_multiple(30000000) || - test_thread_memmove_multiple(50000000); + test_thread_memmove_multiple(50000000) || + test_supported_flags(); } diff --git a/src/deps/miniasync/tests/test_helpers.h b/src/deps/miniasync/tests/test_helpers.h index 7a2682967a1f0d3ea05cdbe3a0d3c7d98900408e..8d5464e9f2b908fb9258c1caf4ba74057650e55c 100644 --- a/src/deps/miniasync/tests/test_helpers.h +++ b/src/deps/miniasync/tests/test_helpers.h @@ -15,6 +15,7 @@ #include <limits.h> #include <assert.h> #include <errno.h> +#include "libminiasync/vdm.h" #define UT_ERR(...) do {\ fprintf(stderr, "ERROR: " __VA_ARGS__);\ @@ -45,4 +46,16 @@ (unsigned long long)(min), (unsigned long long)(max));\ } while (/*CONSTCOND*/0) +static inline int +test_flag(struct vdm *vdm, unsigned flag, int expected_value) +{ + int ret = vdm_is_supported(vdm, flag) != expected_value; + + if (ret) { + fprintf(stderr, + "vdm_is_flag_supported(%u) returned: %u, when expected: %u\n", + flag, ret, expected_value); + } + return ret; +} #endif /* TEST_HELPERS_H */