diff mbox series

[SRU,B/F/H/I/J,1/1] selftests/net: Fix reuseport_bpf_numa by skipping unavailable nodes

Message ID 20211108112540.19229-2-kleber.souza@canonical.com
State New
Headers show
Series Fix for selftests/net/reuseport_bpf_numa (lp#1867570) | expand

Commit Message

Kleber Sacilotto de Souza Nov. 8, 2021, 11:25 a.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1867570

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
(cherry picked from commit a38bc45a08e9759f04d61669f45941d6624d173c linux-next)
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
---
 tools/testing/selftests/net/reuseport_bpf_numa.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Thadeu Lima de Souza Cascardo Nov. 8, 2021, 1:45 p.m. UTC | #1
On Mon, Nov 08, 2021 at 12:25:40PM +0100, Kleber Sacilotto de Souza wrote:
> BugLink: https://bugs.launchpad.net/bugs/1867570
> 
> 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
> (cherry picked from commit a38bc45a08e9759f04d61669f45941d6624d173c linux-next)
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

> ---
>  tools/testing/selftests/net/reuseport_bpf_numa.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/reuseport_bpf_numa.c b/tools/testing/selftests/net/reuseport_bpf_numa.c
> index c9f478b40996..b2eebf669b8c 100644
> --- a/tools/testing/selftests/net/reuseport_bpf_numa.c
> +++ b/tools/testing/selftests/net/reuseport_bpf_numa.c
> @@ -211,12 +211,16 @@ static void test(int *rcv_fd, int len, int family, int proto)
>  
>  	/* Forward iterate */
>  	for (node = 0; node < len; ++node) {
> +		if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
> +			continue;
>  		send_from_node(node, family, proto);
>  		receive_on_node(rcv_fd, len, epfd, node, proto);
>  	}
>  
>  	/* Reverse iterate */
>  	for (node = len - 1; node >= 0; --node) {
> +		if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
> +			continue;
>  		send_from_node(node, family, proto);
>  		receive_on_node(rcv_fd, len, epfd, node, proto);
>  	}
> -- 
> 2.30.2
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/reuseport_bpf_numa.c b/tools/testing/selftests/net/reuseport_bpf_numa.c
index c9f478b40996..b2eebf669b8c 100644
--- a/tools/testing/selftests/net/reuseport_bpf_numa.c
+++ b/tools/testing/selftests/net/reuseport_bpf_numa.c
@@ -211,12 +211,16 @@  static void test(int *rcv_fd, int len, int family, int proto)
 
 	/* Forward iterate */
 	for (node = 0; node < len; ++node) {
+		if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
+			continue;
 		send_from_node(node, family, proto);
 		receive_on_node(rcv_fd, len, epfd, node, proto);
 	}
 
 	/* Reverse iterate */
 	for (node = len - 1; node >= 0; --node) {
+		if (!numa_bitmask_isbitset(numa_nodes_ptr, node))
+			continue;
 		send_from_node(node, family, proto);
 		receive_on_node(rcv_fd, len, epfd, node, proto);
 	}