* [PATCH] selftests: net: reuseport_bpf_numa: consider cpuless numa node
@ 2026-07-30 11:30 Feng Tang
2026-07-30 11:37 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Feng Tang @ 2026-07-30 11:30 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Shuah Khan, netdev, linux-kselftest, linux-kernel,
bpf
Cc: Feng Tang
'reuseport_bpf_numa' case failed on a platform with CXL memory:
#./reuseport_bpf_numa
---- IPv4 UDP ----
send node 0, receive socket 0
./reuseport_bpf_numa: failed to pin to node: Invalid argument
The root cause is that platform has 2 numa nodes: node 0 has both
cpu and memory, while node 1 is a CXL node which only has memory,
which caused numa_run_on_node() failure.
Add check to skip cpuless numa node for the numa binding test.
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
---
.../selftests/net/reuseport_bpf_numa.c | 31 +++++++++++++++++--
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/reuseport_bpf_numa.c b/tools/testing/selftests/net/reuseport_bpf_numa.c
index 8ec52fc5ef41..197dbfc475f6 100644
--- a/tools/testing/selftests/net/reuseport_bpf_numa.c
+++ b/tools/testing/selftests/net/reuseport_bpf_numa.c
@@ -104,13 +104,35 @@ static void attach_bpf(int fd)
close(bpf_fd);
}
-static void send_from_node(int node_id, int family, int proto)
+static inline bool is_cpuless_node(int node_id)
+{
+ struct bitmask *cpumask;
+ bool ret = false;
+
+ cpumask = numa_allocate_cpumask();
+
+ numa_node_to_cpus(node_id, cpumask);
+ if (!numa_bitmask_weight(cpumask))
+ ret = true;
+
+ numa_bitmask_free(cpumask);
+ return ret;
+}
+
+/*
+ * return -1 on node_id pointing to a cpuless node (like a CXL node),
+ * return 0 on successful numa setup
+ */
+static int send_from_node(int node_id, int family, int proto)
{
struct sockaddr_storage saddr, daddr;
struct sockaddr_in *saddr4, *daddr4;
struct sockaddr_in6 *saddr6, *daddr6;
int fd;
+ if (is_cpuless_node(node_id))
+ return -1;
+
switch (family) {
case AF_INET:
saddr4 = (struct sockaddr_in *)&saddr;
@@ -155,6 +177,7 @@ static void send_from_node(int node_id, int family, int proto)
error(1, errno, "failed to send message");
close(fd);
+ return 0;
}
static
@@ -213,7 +236,8 @@ static void test(int *rcv_fd, int len, int family, int proto)
for (node = 0; node < len; ++node) {
if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
continue;
- send_from_node(node, family, proto);
+ if (send_from_node(node, family, proto))
+ continue;
receive_on_node(rcv_fd, len, epfd, node, proto);
}
@@ -221,7 +245,8 @@ static void test(int *rcv_fd, int len, int family, int proto)
for (node = len - 1; node >= 0; --node) {
if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
continue;
- send_from_node(node, family, proto);
+ if (send_from_node(node, family, proto))
+ continue;
receive_on_node(rcv_fd, len, epfd, node, proto);
}
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests: net: reuseport_bpf_numa: consider cpuless numa node
2026-07-30 11:30 [PATCH] selftests: net: reuseport_bpf_numa: consider cpuless numa node Feng Tang
@ 2026-07-30 11:37 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-07-30 11:37 UTC (permalink / raw)
To: Feng Tang; +Cc: bpf
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Missing NULL check for cpumask allocation in is_cpuless_node()
- [Medium] Missing return value check for numa_node_to_cpus() leading to masked errors
--
--- Patch [1]: [PATCH] selftests: net: reuseport_bpf_numa: consider cpuless numa node ---
commit 806931cbf2ad9438843e4d30f69b4887e641f7d2
Author: Feng Tang <feng.tang@linux.alibaba.com>
selftests: net: reuseport_bpf_numa: consider cpuless numa node
This patch addresses a failure in the 'reuseport_bpf_numa' selftest on
platforms with CXL memory where one node is cpuless. It introduces an
is_cpuless_node() check to skip memory-only NUMA nodes during the binding
test.
> diff --git a/tools/testing/selftests/net/reuseport_bpf_numa.c b/tools/testing/selftests/net/reuseport_bpf_numa.c
> index 8ec52fc5ef41b..197dbfc475f65 100644
> --- a/tools/testing/selftests/net/reuseport_bpf_numa.c
> +++ b/tools/testing/selftests/net/reuseport_bpf_numa.c
[ ... ]
> @@ -104,13 +104,35 @@ static void attach_bpf(int fd)
> close(bpf_fd);
> }
>
> -static void send_from_node(int node_id, int family, int proto)
> +static inline bool is_cpuless_node(int node_id)
> +{
> + struct bitmask *cpumask;
> + bool ret = false;
> +
> + cpumask = numa_allocate_cpumask();
> +
> + numa_node_to_cpus(node_id, cpumask);
[Severity: Medium]
Will this crash if numa_allocate_cpumask() fails to allocate memory?
It looks like cpumask could be NULL here, which is passed directly to
numa_node_to_cpus() and numa_bitmask_weight() without validation.
> + if (!numa_bitmask_weight(cpumask))
> + ret = true;
[Severity: Medium]
What happens if numa_node_to_cpus() fails?
It can return a negative error value, leaving the cpumask unmodified with
zero bits set. Because the return value is not checked,
numa_bitmask_weight(cpumask) will evaluate to 0. Does this cause the function
to return true and silently skip testing on nodes where an error occurs,
rather than reporting the infrastructure issue?
> +
> + numa_bitmask_free(cpumask);
> + return ret;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260730113040.75718-1-feng.tang@linux.alibaba.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-30 11:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30 11:30 [PATCH] selftests: net: reuseport_bpf_numa: consider cpuless numa node Feng Tang
2026-07-30 11:37 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.