diff --git a/cooking_recipe.cmake b/cooking_recipe.cmake index 7f0a6f89570..47870712a8d 100644 --- a/cooking_recipe.cmake +++ b/cooking_recipe.cmake @@ -110,7 +110,7 @@ cooking_ingredient (nettle BUILD_COMMAND INSTALL_COMMAND ${make_command} install) -# Also a direct dependency of Seastar. +# A dependency of DPDK. cooking_ingredient (numactl EXTERNAL_PROJECT_ARGS URL https://github.com/numactl/numactl/releases/download/v2.0.12/numactl-2.0.12.tar.gz diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e659f9806da..4589d44a100 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,10 +130,6 @@ target_link_libraries (seastar-module yaml-cpp::yaml-cpp "$" Threads::Threads) -if (Seastar_NUMA) - target_link_libraries (seastar-module - PRIVATE numactl::numactl) -endif () if (Seastar_HWLOC) target_link_libraries (seastar-module PRIVATE hwloc::hwloc) diff --git a/src/core/memory.cc b/src/core/memory.cc index 1759123c874..68faae5b710 100644 --- a/src/core/memory.cc +++ b/src/core/memory.cc @@ -101,10 +101,9 @@ module; #include #include #include +#include +#include -#ifdef SEASTAR_HAVE_NUMA -#include -#endif #endif // !defined(SEASTAR_DEFAULT_ALLOCATOR) #ifdef SEASTAR_MODULE @@ -1832,6 +1831,23 @@ void configure_minimal() { init_cpu_mem(); } +static long mbind(void *addr, + unsigned long len, + int mode, + const unsigned long *nodemask, + unsigned long maxnode, + unsigned flags) { + return syscall( + SYS_mbind, + addr, + len, + mode, + nodemask, + maxnode, + flags + ); +} + internal::numa_layout configure(std::vector m, bool mbind, bool transparent_hugepages, @@ -1865,13 +1881,13 @@ configure(std::vector m, bool mbind, get_cpu_mem().replace_memory_backing(sys_alloc); } get_cpu_mem().resize(total, sys_alloc); -#ifdef SEASTAR_HAVE_NUMA size_t pos = 0; for (auto&& x : m) { unsigned long nodemask = 1UL << x.nodeid; if (mbind) { auto start = get_cpu_mem().mem() + pos; - auto r = ::mbind(start, x.bytes, + auto r = seastar::memory::mbind( + start, x.bytes, MPOL_PREFERRED, &nodemask, std::numeric_limits::digits, MPOL_MF_MOVE); @@ -1890,7 +1906,6 @@ configure(std::vector m, bool mbind, } pos += x.bytes; } -#endif return ret_layout; }