]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add the support to use DML library for PMEM device. 44230/head
authorZiye Yang <ziye.yang@intel.com>
Thu, 2 Dec 2021 02:15:28 +0000 (02:15 +0000)
committerZiye Yang <ziye.yang@intel.com>
Tue, 19 Apr 2022 06:51:12 +0000 (14:51 +0800)
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 <ziye.yang@intel.com>
CMakeLists.txt
cmake/modules/Finddml.cmake [new file with mode: 0644]
doc/rados/configuration/bluestore-config-ref.rst
src/blk/CMakeLists.txt
src/blk/pmem/PMEMDevice.cc
src/include/config-h.in.cmake

index da6098a4262d2301b1f2021f191902249bf8869a..42ab137775d735b3b6d22a44aa01cb1b9baba562 100644 (file)
@@ -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 (file)
index 0000000..8e94ad2
--- /dev/null
@@ -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()
index ce703055cfaa8d081e30518e330fac058b630d34..d3f5ba994abe4262a2c14ada3ff582349cec7682 100644 (file)
@@ -452,3 +452,20 @@ of ``/sys/block/<drive>/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
index 37b9c0a410c8a7de2888e9c9bfa96989d76c8c43..40afb84dc141fec0098766741b38f8d4c3bf8a56 100644 (file)
@@ -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()
index 7b0be249b4cff6907ff822c7b1d895b8932c2605..1ebfe7b2d34064a2d32a5932208ad24c38647677 100644 (file)
 #include "common/debug.h"
 #include "common/blkdev.h"
 
+#if defined(HAVE_LIBDML)
+#include <dml/dml.hpp>
+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<execution_path>(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<execution_path>(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<execution_path>(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;
 }
 
index 6d3a25c5f52a00485fa9d11605a3fd1cdb8c0cb3..421ce82456325613378879330fa5cfec27321f3f 100644 (file)
@@ -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