mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang@linux.alibaba.com>
To: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Cc: Feng Tang <feng.tang@linux.alibaba.com>
Subject: [PATCH] selftests: net: reuseport_bpf_numa: consider cpuless numa node
Date: Thu, 30 Jul 2026 19:30:40 +0800	[thread overview]
Message-ID: <20260730113040.75718-1-feng.tang@linux.alibaba.com> (raw)

'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)


                 reply	other threads:[~2026-07-30 11:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260730113040.75718-1-feng.tang@linux.alibaba.com \
    --to=feng.tang@linux.alibaba.com \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®