BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: range_tree for bpf arena
@ 2024-11-08  2:56 Alexei Starovoitov
  2024-11-08  2:56 ` [PATCH bpf-next 1/2] bpf: Introduce range_tree data structure and use it in " Alexei Starovoitov
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Alexei Starovoitov @ 2024-11-08  2:56 UTC (permalink / raw)
  To: bpf; +Cc: daniel, andrii, martin.lau, memxor, eddyz87, djwong, kernel-team

From: Alexei Starovoitov <ast@kernel.org>

Introduce range_tree (internval tree plus rbtree) to track
unallocated ranges in bpf arena and replace maple_tree with it.
This is a step towards making bpf_arena|free_alloc_pages non-sleepable.
The previous approach to reuse drm_mm to replace maple_tree reached
dead end, since sizeof(struct drm_mm_node) = 168 and
sizeof(struct maple_node) = 256 while
sizeof(struct range_node) = 64 introduced in this patch.
Not only it's smaller, but the algorithm splits and merges
adjacent ranges. Ultimate performance doesn't matter.
The main objective of range_tree is to work in context
where kmalloc/kfree are not safe. It achieves that via bpf_mem_alloc.

Alexei Starovoitov (2):
  bpf: Introduce range_tree data structure and use it in bpf arena
  selftests/bpf: Add a test for arena range tree algorithm

 kernel/bpf/Makefile                           |   2 +-
 kernel/bpf/arena.c                            |  34 ++-
 kernel/bpf/range_tree.c                       | 262 ++++++++++++++++++
 kernel/bpf/range_tree.h                       |  21 ++
 .../bpf/progs/verifier_arena_large.c          | 110 +++++++-
 5 files changed, 412 insertions(+), 17 deletions(-)
 create mode 100644 kernel/bpf/range_tree.c
 create mode 100644 kernel/bpf/range_tree.h

-- 
2.43.5


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-01-06 17:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08  2:56 [PATCH bpf-next 0/2] bpf: range_tree for bpf arena Alexei Starovoitov
2024-11-08  2:56 ` [PATCH bpf-next 1/2] bpf: Introduce range_tree data structure and use it in " Alexei Starovoitov
2024-11-13 16:02   ` Kumar Kartikeya Dwivedi
2025-01-06 16:12   ` Barret Rhoden
2025-01-06 17:45     ` Alexei Starovoitov
2024-11-08  2:56 ` [PATCH bpf-next 2/2] selftests/bpf: Add a test for arena range tree algorithm Alexei Starovoitov
2024-11-13 16:04   ` Kumar Kartikeya Dwivedi
2024-11-15 12:20   ` Jiri Olsa
2024-11-15 16:30     ` Yonghong Song
2024-11-16 19:00       ` Alexei Starovoitov
2024-11-16 20:35         ` Jiri Olsa
2024-11-13 21:59 ` [PATCH bpf-next 0/2] bpf: range_tree for bpf arena Andrii Nakryiko
2024-11-14  0:48   ` Alexei Starovoitov
2024-11-13 22:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox