Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/net: Fix reuseport_bpf_numa by skipping unavailable nodes

In some platforms the numa node numbers are not necessarily consecutive,
meaning that not all nodes from 0 to the value returned by numa_max_node()
are available on the system. Using node numbers which are not available
results on errors from libnuma such as:

---- IPv4 UDP ----
send node 0, receive socket 0
libnuma: Warning: Cannot read node cpumask from sysfs
./reuseport_bpf_numa: failed to pin to node: No such file or directory

Fix it by checking if the node number bit is set on numa_nodes_ptr, which
is defined on libnuma as "Set with all nodes the kernel has exposed to
userspace".

Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211101145317.286118-1-kleber.souza@canonical.com

authored by

Kleber Sacilotto de Souza and committed by
Daniel Borkmann
a38bc45a c08455de

+4
+4
tools/testing/selftests/net/reuseport_bpf_numa.c
··· 211 211 212 212 /* Forward iterate */ 213 213 for (node = 0; node < len; ++node) { 214 + if (!numa_bitmask_isbitset(numa_nodes_ptr, node)) 215 + continue; 214 216 send_from_node(node, family, proto); 215 217 receive_on_node(rcv_fd, len, epfd, node, proto); 216 218 } 217 219 218 220 /* Reverse iterate */ 219 221 for (node = len - 1; node >= 0; --node) { 222 + if (!numa_bitmask_isbitset(numa_nodes_ptr, node)) 223 + continue; 220 224 send_from_node(node, family, proto); 221 225 receive_on_node(rcv_fd, len, epfd, node, proto); 222 226 }