Re: [PATCH] selftests: net: reuseport_bpf_numa: consider cpuless numa node
Feng Tang <[email protected]> Fri, 31 Jul 2026 09:02:07 +0800
| Newsgroups | dev.linux.lists.sashiko-reviews,org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
Thanks for the review! Add Andi On Thu, Jul 30, 2026 at 11:37:37AM +0000, [email protected] wrote: > 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 <[email protected]> > > 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. Good point. If the allocation fail, will return 'false' to let the code go the original flow. > > + 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? From the code logic (with above change), the 'node_id' and 'cpumask' have both been validated, and this numa_node_to_cpus() is very unlikely to fail here upon reading libnuma source code. Thanks, Feng > > + > > + numa_bitmask_free(cpumask); > > + return ret; > > +} > > -- > Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1