libbpf: remove fake __arena_internal map
Unify actual ARENA map and fake __arena_internal map. .arena.1 ELF
section isn't a stand-alone BPF map, so it shouldn't be represented as
`struct bpf_map *` instance in libbpf APIs. Instead, use ELF section
data as initial data image, which is exposed through skeleton and
bpf_map__initial_value() to the user, if they need to tune it before the
load phase. During load phase, this initial image is copied over into
mmap()'ed region corresponding to ARENA, and discarded.
Few small checks here and there had to be added to make sure this
approach works with bpf_map__initial_value(), mostly due to hard-coded
assumption that map->mmaped is set up with mmap() syscall and should be
munmap()'ed. For ARENA, .arena.1 can be (much) smaller than maximum
ARENA size, so this smaller data size has to be tracked separately.
Given it is enforced that there is only one ARENA for entire bpf_object
instance, we just keep it in a separate field. This can be generalized
if necessary later.
bpftool is adjusted a bit as well, because ARENA map is not reported as
"internal" (it's not a great fit in this case), plus we need to take
into account that ARENA map can exist without corresponding .arena.1 ELF
section, so user-facing data section in skeleton is optional.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
3 files changed