Skip to content

Commit

Permalink
seastar: remove libnuma dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
rockwotj committed Feb 17, 2025
1 parent 99ac8ed commit 796067c
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 113 deletions.
1 change: 0 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ use_repo(non_module_dependencies, "libpciaccess")
use_repo(non_module_dependencies, "libprotobuf_mutator")
use_repo(non_module_dependencies, "libxml2")
use_repo(non_module_dependencies, "lksctp")
use_repo(non_module_dependencies, "numactl")
use_repo(non_module_dependencies, "openssl")
use_repo(non_module_dependencies, "openssl-fips")

Expand Down
17 changes: 4 additions & 13 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ def data_dependency():
url = "https://vectorized-public.s3.amazonaws.com/dependencies/lksctp-tools-1.0.19.tar.gz",
)

http_archive(
name = "numactl",
build_file = "//bazel/thirdparty:numactl.BUILD",
sha256 = "1ee27abd07ff6ba140aaf9bc6379b37825e54496e01d6f7343330cf1a4487035",
strip_prefix = "numactl-2.0.14",
url = "https://vectorized-public.s3.amazonaws.com/dependencies/numactl-v2.0.14.tar.gz",
)

#
# ** IMPORTANT - OpenSSL and FIPS **
#
Expand Down Expand Up @@ -170,7 +162,7 @@ def data_dependency():
sha256 = "cd235a75a15a2fff0bdc12462d28862ecbc96ac34445725d545c0041f32dfb39",
strip_prefix = "seastar-3aa6ca607d0227052301427d400e50bbdd70f37b",
url = "https://github.com/redpanda-data/seastar/archive/3aa6ca607d0227052301427d400e50bbdd70f37b.tar.gz",
patches = ["//bazel/thirdparty:seastar-fortify-source.patch"],
patches = ["//bazel/thirdparty:seastar-fortify-source.patch", "//bazel/thirdparty:seastar-remove-libnuma.patch"],
patch_args = ["-p1"],
)

Expand Down
72 changes: 0 additions & 72 deletions bazel/thirdparty/numactl.BUILD

This file was deleted.

118 changes: 118 additions & 0 deletions bazel/thirdparty/seastar-remove-libnuma.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
From dddf21728809cf44322bfc85a14413cd44b682db Mon Sep 17 00:00:00 2001
From: Tyler Rockwood <[email protected]>
Date: Mon, 17 Feb 2025 15:59:14 +0000
Subject: [PATCH] memory: remove libnuma dependency

Seastar is currently pulling in all of libnuma to just invoke a single
syscall. Additionally since libnuma being LGPL licensed, it's simpler
to not include it as a dependency. Replace the call in numaif.h with
a direct syscall.

I'm assuming that once libnuma was depended on because it was a
dependency of hwloc, however, hwloc version 2 removed the dependency
on libnuma, so Seastar can too:
https://github.com/open-mpi/hwloc/blob/263908a2c1f21c0e221a8d1f6472daf3a1fc07b9/NEWS#L291
---
cooking_recipe.cmake | 2 +-
src/CMakeLists.txt | 4 ----
src/core/memory.cc | 33 ++++++++++++++++++++++++---------
3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/cooking_recipe.cmake b/cooking_recipe.cmake
index d63ad23d646..0e8138d479b 100644
--- a/cooking_recipe.cmake
+++ b/cooking_recipe.cmake
@@ -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
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 46e7a13daf8..6455b093386 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -127,10 +127,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)
diff --git a/src/core/memory.cc b/src/core/memory.cc
index 85d9b13cccd..6e0fb5d1225 100644
--- a/src/core/memory.cc
+++ b/src/core/memory.cc
@@ -102,9 +102,6 @@ module;
#include <boost/intrusive/list.hpp>
#include <sys/mman.h>

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

#ifdef SEASTAR_MODULE
@@ -1832,6 +1829,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(
+ __NR_mbind,
+ reinterpret_cast<long>(addr),
+ len,
+ mode,
+ reinterpret_cast<long>(nodemask),
+ maxnode,
+ flags
+ );
+}
+
internal::numa_layout
configure(std::vector<resource::memory> m, bool mbind,
bool transparent_hugepages,
@@ -1865,16 +1879,18 @@ 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,
- MPOL_PREFERRED,
- &nodemask, std::numeric_limits<unsigned long>::digits,
- MPOL_MF_MOVE);
+ static constexpr int mpol_preferred = 1;
+ static constexpr unsigned int mpol_mf_move = 2;
+ auto r = seastar::memory::mbind(
+ start, x.bytes,
+ mpol_preferred,
+ &nodemask, std::numeric_limits<unsigned long>::digits,
+ mpol_mf_move);

if (r == -1) {
char err[1000] = {};
@@ -1890,7 +1906,6 @@ configure(std::vector<resource::memory> m, bool mbind,
}
pos += x.bytes;
}
-#endif
return ret_layout;
}

18 changes: 0 additions & 18 deletions bazel/thirdparty/seastar.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ bool_flag(
build_setting_default = False,
)

bool_flag(
name = "numactl",
build_setting_default = True,
)

bool_flag(
name = "hwloc",
build_setting_default = True,
Expand Down Expand Up @@ -101,13 +96,6 @@ config_setting(
},
)

config_setting(
name = "use_numactl",
flag_values = {
":numactl": "true",
},
)

config_setting(
name = "use_task_backtrace",
flag_values = {
Expand Down Expand Up @@ -609,9 +597,6 @@ cc_library(
}) + select({
":use_io_uring": ["SEASTAR_HAVE_URING"],
"//conditions:default": [],
}) + select({
":use_numactl": ["SEASTAR_HAVE_NUMA"],
"//conditions:default": [],
}) + select({
# this only needs to be applied to memory.cc and reactor.cc. could be
# split out into a separate cc_library, but we'd need to inherit all the
Expand Down Expand Up @@ -657,9 +642,6 @@ cc_library(
}) + select({
":use_io_uring": ["@liburing"],
"//conditions:default": [],
}) + select({
":use_numactl": ["@numactl"],
"//conditions:default": [],
}),
)

Expand Down

0 comments on commit 796067c

Please sign in to comment.