| #
57c6ace8 |
| 06-Jun-2026 |
Emil Tsalapatis <emil@etsalapatis.com> |
selftests/bpf: libarena: Add spmc queue data structure
Expand libarena with a single producer multiple consumer deque data structure. This is a single producer, multiple consumer lockless structure
selftests/bpf: libarena: Add spmc queue data structure
Expand libarena with a single producer multiple consumer deque data structure. This is a single producer, multiple consumer lockless structure that permits efficient work stealing. The structure is a Lev-Chase queue, so it is lock-free and wait-free.
The data structure exposes three main calls. two of them are available to the thread owning the queue and one available to all threads in the program:
spmc_owner_push(): Push an item to the top of the queue. spmc_owner_pop(): Pop an item from the top of the queue. spmc_steal(): Steal a thread from the bottom of the queue from any thread.
Note that the queue is not really FIFO for all consumers, since non-owners of the queue can only work steal from the bottom.
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com> Link: https://lore.kernel.org/r/20260605222020.5231-3-emil@etsalapatis.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
show more ...
|