From: Ziye Yang Date: Thu, 2 Dec 2021 02:15:28 +0000 (+0000) Subject: Add the support to use DML library for PMEM device. X-Git-Tag: v18.0.0~1032^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F44230%2Fhead;p=ceph.git Add the support to use DML library for PMEM device. The purpose of this patch is to add the initial support to offload memory/pmem operations by sync usage through hardware path in DML library. Signed-off-by: Ziye Yang --- diff --git a/CMakeLists.txt b/CMakeLists.txt index da6098a4262d2..42ab137775d73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,6 +163,7 @@ if(LINUX) elseif(FREEBSD) set(HAVE_UDEV OFF) set(HAVE_LIBAIO OFF) + set(HAVE_LIBDML OFF) set(HAVE_BLKID OFF) set(HAVE_KEYUTILS OFF) else() @@ -211,6 +212,11 @@ if(WITH_BLUESTORE) # POSIX AIO is integrated into FreeBSD kernel, and exposed by libc. set(HAVE_POSIXAIO ON) endif() + + if(LINUX) + find_package(dml) + set(HAVE_LIBDML ${DML_FOUND}) + endif() endif() # libcryptsetup is only available on linux diff --git a/cmake/modules/Finddml.cmake b/cmake/modules/Finddml.cmake new file mode 100644 index 0000000000000..8e94ad26d6c36 --- /dev/null +++ b/cmake/modules/Finddml.cmake @@ -0,0 +1,58 @@ +# - Find libdml +# Find the dml and dmlhl libraries and includes +# +# DML_INCLUDE_DIR - where to find dml.hpp etc. +# DML_LIBRARIES - List of libraries when using dml. +# DML_HL_LIBRARIES - List of libraries when using dmlhl. +# DML_FOUND - True if DML found. + + +find_path(DML_INCLUDE_DIR + dml/dml.hpp + PATHS + /usr/include + /usr/local/include) + +find_library(DML_LIBRARIES NAMES dml libdml PATHS + /usr/local/ + /usr/local/lib64 + /usr/lib64 + /usr/lib) + +find_library(DML_HL_LIBRARIES NAMES dmlhl libdmlhl PATHS + /usr/local/ + /usr/local/lib64 + /usr/lib64 + /usr/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(dml DEFAULT_MSG + DML_LIBRARIES + DML_INCLUDE_DIR + DML_HL_LIBRARIES) + +mark_as_advanced( + DML_LIBRARIES + DML_INCLUDE_DIR + DML_HL_LIBRARIES) + +if(DML_FOUND) + if(NOT (TARGET dml::dml)) + add_library(dml::dml UNKNOWN IMPORTED) + set_target_properties(dml::dml PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${DML_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${DML_LIBRARIES}") + endif() + + if(NOT (TARGET dml::dmlhl)) + add_library(dml::dmlhl UNKNOWN IMPORTED) + set_target_properties(dml::dmlhl PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${DML_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} + INTERFACE_COMPILE_FEATURES cxx_std_17 + INTERFACE_COMPILE_DEFINITIONS "DML_HW" + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${DML_HL_LIBRARIES}") + endif() +endif() diff --git a/doc/rados/configuration/bluestore-config-ref.rst b/doc/rados/configuration/bluestore-config-ref.rst index ce703055cfaa8..d3f5ba994abe4 100644 --- a/doc/rados/configuration/bluestore-config-ref.rst +++ b/doc/rados/configuration/bluestore-config-ref.rst @@ -452,3 +452,20 @@ of ``/sys/block//queue/optimal_io_size``. .. confval:: bluestore_min_alloc_size_ssd .. confval:: bluestore_use_optimal_io_size_for_min_alloc_size +DSA (Data Streaming Accelerator Usage) +====================================== + +If you want to use the DML library to drive DSA device for offloading +read/write operations on Persist memory in Bluestore. You need to install +`DML`_ and `idxd-config`_ library in your machine with SPR (Sapphire Rapids) CPU. + +.. _DML: https://github.com/intel/DML +.. _idxd-config: https://github.com/intel/idxd-config + +After installing the DML software, you need to configure the shared +work queues (WQs) with the following WQ configuration example via accel-config tool:: + +$ accel-config config-wq --group-id=1 --mode=shared --wq-size=16 --threshold=15 --type=user --name="MyApp1" --priority=10 --block-on-fault=1 dsa0/wq0.1 +$ accel-config config-engine dsa0/engine0.1 --group-id=1 +$ accel-config enable-device dsa0 +$ accel-config enable-wq dsa0/wq0.1 diff --git a/src/blk/CMakeLists.txt b/src/blk/CMakeLists.txt index 37b9c0a410c8a..40afb84dc141f 100644 --- a/src/blk/CMakeLists.txt +++ b/src/blk/CMakeLists.txt @@ -44,6 +44,10 @@ if(WITH_ZBD) endif() if(WITH_BLUESTORE_PMEM) + if(HAVE_LIBDML) + target_link_libraries(blk PRIVATE dml::dml dml::dmlhl) + endif() + target_link_libraries(blk PRIVATE pmem::pmem) endif() diff --git a/src/blk/pmem/PMEMDevice.cc b/src/blk/pmem/PMEMDevice.cc index 7b0be249b4cff..1ebfe7b2d3406 100644 --- a/src/blk/pmem/PMEMDevice.cc +++ b/src/blk/pmem/PMEMDevice.cc @@ -28,6 +28,11 @@ #include "common/debug.h" #include "common/blkdev.h" +#if defined(HAVE_LIBDML) +#include +using execution_path = dml::automatic; +#endif + #define dout_context cct #define dout_subsys ceph_subsys_bdev #undef dout_prefix @@ -219,7 +224,14 @@ int PMEMDevice::write(uint64_t off, bufferlist& bl, bool buffered, int write_hin while (len) { const char *data; uint32_t l = p.get_ptr_and_advance(len, &data); + +#if defined(HAVE_LIBDML) + // Take care of the persistency issue + auto result = dml::execute(dml::mem_move, dml::make_view(data, l), dml::make_view(addr + off1, l)); + ceph_assert(result.status == dml::status_code::ok); +#else pmem_memcpy_persist(addr + off1, data, l); +#endif len -= l; off1 += l; } @@ -245,7 +257,13 @@ int PMEMDevice::read(uint64_t off, uint64_t len, bufferlist *pbl, ceph_assert(is_valid_io(off, len)); bufferptr p = buffer::create_small_page_aligned(len); + +#if defined(HAVE_LIBDML) + auto result = dml::execute(dml::mem_move, dml::make_view(addr + off, len), dml::make_view(p.c_str(), len)); + ceph_assert(result.status == dml::status_code::ok); +#else memcpy(p.c_str(), addr + off, len); +#endif pbl->clear(); pbl->push_back(std::move(p)); @@ -268,7 +286,13 @@ int PMEMDevice::read_random(uint64_t off, uint64_t len, char *buf, bool buffered dout(5) << __func__ << " " << off << "~" << len << dendl; ceph_assert(is_valid_io(off, len)); + +#if defined(HAVE_LIBDML) + auto result = dml::execute(dml::mem_move, dml::make_view(addr + off, len), dml::make_view(buf, len)); + ceph_assert(result.status == dml::status_code::ok); +#else memcpy(buf, addr + off, len); +#endif return 0; } diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index 6d3a25c5f52a0..421ce82456325 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -84,6 +84,9 @@ /* Defined if you have libaio */ #cmakedefine HAVE_LIBAIO +/* Defined if you have libdml */ +#cmakedefine HAVE_LIBDML + /* Defined if you have libzbd */ #cmakedefine HAVE_LIBZBD