Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory: remove libnuma dependency #179

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cooking_recipe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ cooking_ingredient (nettle
BUILD_COMMAND <DISABLE>
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
Expand Down
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ target_link_libraries (seastar-module
yaml-cpp::yaml-cpp
"$<BUILD_INTERFACE:Valgrind::valgrind>"
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)
Expand Down
27 changes: 21 additions & 6 deletions src/core/memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ module;
#include <utility>
#include <boost/intrusive/list.hpp>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/mempolicy.h>

#ifdef SEASTAR_HAVE_NUMA
#include <numaif.h>
#endif
#endif // !defined(SEASTAR_DEFAULT_ALLOCATOR)

#ifdef SEASTAR_MODULE
Expand Down Expand Up @@ -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<resource::memory> m, bool mbind,
bool transparent_hugepages,
Expand Down Expand Up @@ -1865,13 +1881,13 @@ configure(std::vector<resource::memory> 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<unsigned long>::digits,
MPOL_MF_MOVE);
Expand All @@ -1890,7 +1906,6 @@ configure(std::vector<resource::memory> m, bool mbind,
}
pos += x.bytes;
}
#endif
return ret_layout;
}

Expand Down
Loading