|
|
Log in / Subscribe / Register

selftests/bpf: libarena: Add initial data structures

From:  Emil Tsalapatis <emil-AT-etsalapatis.com>
To:  bpf-AT-vger.kernel.org
Subject:  [PATCH bpf-next v2 0/3] selftests/bpf: libarena: Add initial data structures
Date:  Wed, 03 Jun 2026 14:27:24 -0400
Message-ID:  <20260603182727.3922-1-emil@etsalapatis.com>
Cc:  ast-AT-kernel.org, andrii-AT-kernel.org, memxor-AT-gmail.com, daniel-AT-iogearbox.net, eddyz87-AT-gmail.com, song-AT-kernel.org, mattbobrowski-AT-google.com, Emil Tsalapatis <emil-AT-etsalapatis.com>
Archive-link:  Article

Add two new data structures to libarena. These data structures initially
resided in the sched-ext repo (https://github.com/sched-ext/scx) and
have been adapted to the internal libarena build system. The data
structures are:

- Red black tree: Fundamental tree data structure that can also serve
  as a base for more domain-specific data structures.

- Lev-Chase deque: Queue data structure that allows efficient work
  stealing, useful in scheduling scenarios.

The data structures are accompanied by selftests that are automatically
discovered by the existing libarena test_progs selftest and incorporated
in the CI.

CHANGELOG
=========

v1 -> v2 (https://lore.kernel.org/bpf/20260511214100.9487-1-emil@et...):

- Rename tests from st_ to test_ (Alexei)
- Removed the freelist caches from the rbtrees, previously used to defer freeing (Alexei)
- Moved the type and function definitions to use the __arena identifier
- Removed the typecasts during function return and directly return __arena
  pointers (Alexei)
- Renamed queues to spmc queues to abstract away the algorithm (Alexei)
- Adjusted the memory barriers in the spmc queue
- Added multithreaded testing harness for libarena programs (Alexei)
- Added parallel selftest for queues (Alexei)
- Split least upper bound and exact find operations back into separate
  functions to prevent RB_DUPLICATE-related bug (AI)

Emil Tsalapatis (3):
  selftests/bpf: libarena: Add rbtree data structure
  selftests/bpf: libarena: Add spmc queue data structure
  selftests/bpf: libarena: parallel test harness and spmc parallel
    selftest

 .../bpf/libarena/include/libarena/rbtree.h    |   83 ++
 .../bpf/libarena/include/libarena/spmc.h      |   27 +
 .../bpf/libarena/include/libarena/userspace.h |    6 +
 .../selftests/test_parallel_spmc.bpf.c        |  659 +++++++++++
 .../bpf/libarena/selftests/test_rbtree.bpf.c  |  968 ++++++++++++++++
 .../bpf/libarena/selftests/test_spmc.bpf.c    |  194 ++++
 .../selftests/bpf/libarena/src/rbtree.bpf.c   | 1015 +++++++++++++++++
 .../selftests/bpf/libarena/src/spmc.bpf.c     |  232 ++++
 .../selftests/bpf/prog_tests/libarena.c       |  157 +++
 9 files changed, 3341 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/rbtree.h
 create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/spmc.h
 create mode 100644 tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
 create mode 100644 tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
 create mode 100644 tools/testing/selftests/bpf/libarena/selftests/test_spmc.bpf.c
 create mode 100644 tools/testing/selftests/bpf/libarena/src/rbtree.bpf.c
 create mode 100644 tools/testing/selftests/bpf/libarena/src/spmc.bpf.c

-- 
2.54.0




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds