Re: [PATCH bpf-next v2 3/3] selftests/bpf: libarena: Cache the rbtree's leftmost node and count

From: bot+bpf-ci

Date: Wed Nov 11 2026 - 03:12:26 EST


> selftests/bpf: libarena: Cache the rbtree's leftmost node and count

TL;DR: The three new rbtree lockless helpers in rbtree.h are plain static, not
static inline. They may trigger -Wunused-function under -Werror and break the
whole selftests build. Should they be inline?

> diff --git a/tools/testing/selftests/bpf/libarena/include/libarena/rbtree.h b/tools/testing/selftests/bpf/libarena/include/libarena/rbtree.h
> index 788e25fcd7fd..e34d5a51ae3d 100644
> --- a/tools/testing/selftests/bpf/libarena/include/libarena/rbtree.h
> +++ b/tools/testing/selftests/bpf/libarena/include/libarena/rbtree.h

[ ... ]

> @@ -81,4 +98,37 @@ void rb_node_free(struct rbnode __arena *rbnode);
>
> int rb_integrity_check(struct rbtree __arena *rbtree);
>
> +/*
> + * Lockless reads of the head and the node count. [ ... ]
> + */
> +static struct rbnode __arena *rb_first_lockless(struct rbtree __arena *rbtree)
> +{
> + return READ_ONCE(rbtree->first);
> +}
> +
> +/* -ENOENT if the tree is empty, 0 with the leftmost key in @key otherwise. */
> +static int rb_first_key_lockless(struct rbtree __arena *rbtree, u64 *key)
> +{
[ ... ]
> +static u64 rb_nr_nodes_lockless(struct rbtree __arena *rbtree)
> +{
> + return READ_ONCE(rbtree->nr);
> +}
> +
> #endif /* __BPF__ */

Can these three plain static functions break the libarena build?

src/rbtree.bpf.c includes <libarena/rbtree.h> but calls none of them.
Clang only exempts unused file-scope functions from -Wunused-function when
they are declared inline, since static inline functions are assumed to be
header helpers. A plain static function defined in a header still gets the
warning.

The libarena objects are built with the selftests' BPF_CFLAGS, which include
-Wall -Werror, so this would be expected to fail with something like:

rbtree.h: error: unused function 'rb_first_lockless' [-Werror,-Wunused-function]

and, because the libarena skeletons are prerequisites of the test_progs
build, it would break the whole selftests build rather than only the rbtree
tests.

The other helpers defined in libarena headers use static inline or
static __always_inline. Should these three be declared static inline (or
static __always_inline, as in the earlier revision) as well?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/42982574960