From b6112cb45ffea90e854238a4c659ed60fbe150b5 Mon Sep 17 00:00:00 2001 From: Pavel Siska Date: Wed, 30 Jul 2025 18:21:33 +0200 Subject: [PATCH] NfbPlugin: replace numa_bind with numa_set_preferred for flexible memory allocation Switched from `numa_bind()` to `numa_set_preferred()` with `numa_set_bind_policy(0)` to allow preferred NUMA node memory allocation without hard binding. This enables memory to be allocated on the preferred NUMA node first, but allows fallback to others when necessary. --- src/plugins/input/nfb/src/ndpReader.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/plugins/input/nfb/src/ndpReader.cpp b/src/plugins/input/nfb/src/ndpReader.cpp index 40770945..a41a6d52 100644 --- a/src/plugins/input/nfb/src/ndpReader.cpp +++ b/src/plugins/input/nfb/src/ndpReader.cpp @@ -60,21 +60,19 @@ int NdpReader::init_interface(const std::string& interface) return 1; } - struct bitmask* bits = nullptr; int node_id; rx_handle = ndp_open_rx_queue(dev_handle, channel); if (!rx_handle) { error_msg = std::string() + "error opening NDP queue of NFB device"; return 1; } - if (((node_id = ndp_queue_get_numa_node(rx_handle)) >= 0) - && // OPTIONAL: bind thread to correct NUMA node - ((bits = numa_allocate_nodemask()) != nullptr)) { - (void) numa_bitmask_setbit(bits, node_id); - numa_bind(bits); - numa_free_nodemask(bits); + if ((node_id = ndp_queue_get_numa_node(rx_handle)) >= 0) { + // allow memory to be allocated on other nodes if preferred is unavailable + constexpr int PREFERRED_NODE_POLICY = 0; + numa_set_bind_policy(PREFERRED_NODE_POLICY); + numa_set_preferred(node_id); } else { - error_msg = std::string() + "warning - NUMA node binding failed\n"; + error_msg = "warning - NUMA node detection failed\n"; return 1; } if (ndp_queue_start(rx_handle)) { // start capturing data from NDP queue