Re: [PATCH bpf-next v5 5/9] selftests/bpf: Add basic libarena scaffolding

Alexei Starovoitov
2026-04-10T22:50:27Z

On Fri, Apr 10, 2026 at 3:06 PM Song Liu <song@kernel.org> wrote:
>
> On Fri, Apr 10, 2026 at 1:12 PM Emil Tsalapatis <emil@etsalapatis.com> wrote:
> >
> > On Fri Apr 10, 2026 at 3:44 PM EDT, Kumar Kartikeya Dwivedi wrote:
> > > On Fri, 10 Apr 2026 at 20:39, Song Liu <song@kernel.org> wrote:
> > >>
> > >> On Fri, Apr 10, 2026 at 9:31 AM Emil Tsalapatis <emil@etsalapatis.com> wrote:
> > >> [...]
> > >> > diff --git a/tools/testing/selftests/bpf/libarena/include/common.h b/tools/testing/selftests/bpf/libarena/include/common.h
> > >> > new file mode 100644
> > >> > index 000000000000..5acf9b994943
> > >> > --- /dev/null
> > >> > +++ b/tools/testing/selftests/bpf/libarena/include/common.h
> > >> > @@ -0,0 +1,67 @@
> > >> > +// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause
> > >> > +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
> > >> > +#pragma once
> > >> > +
> > >> > +#ifdef __BPF__
> > >> > +
> > >> > +#include <vmlinux.h>
> > >> > +
> > >> > +#include "bpf_experimental.h"
> > >>
> > >> bpf_experimental.h is not needed here.
> > >>
> > >> > +#include "bpf_arena_common.h"
> > >> > +#include "bpf_arena_spin_lock.h"
> > >>
> > >> These two headers are indeed needed. However, what's the plan
> > >> with them? They are not part of libarena at the moment. How should
> > >> we include them in the future?
> > >
> > > I would propose making them part of libarena, and adding libarena's
> > > header directory to -I for all progs in selftest to simplify
> > > inclusion.
> > >
> >
> > +1 on this. We should have all arena related functionality in a single
> > directory.
>
> There is also tools/sched_ext/include/scx/bpf_arena_common.h, which

imo tools/sched_ext are bitrotting. I wouldn't be surprised
if they're removed. It's not really a library or a tool.

> is similar to bpf_arena_common.h in selftests/bpf. We can have sched_ext
> include this version of bpf_arena_common.h. However, it seems weird to
> have sched_ext code include a header in selftests/bpf. Therefore, I think
> it makes more sense to move libarena to tools/lib/. WDYT?

I wouldn't. In general tools/lib/ is not a place for generic libraries.
libbpf is there because it's needed to build the kernel.
libarena is in selftest/bpf, because it's needed for selftests.
The kernel itself doesn't need it.
I would remove some of the libs from tools/lib/.