diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2024-01-03 17:38:42 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2024-01-03 21:22:49 -0800 |
commit | dac645b950ea4fc0896fe46a645365cb8d9ab92b (patch) | |
tree | 246b69d04cdbeaa2b277cfb0ecb855e61a13a847 /fs/sysv/balloc.c | |
parent | f08c18e083adfef92946ae1d44b07bb81e727e08 (diff) |
libbpf: use stable map placeholder FDs
Move map creation to later during BPF object loading by pre-creating
stable placeholder FDs (utilizing memfd_create()). Use dup2()
syscall to then atomically make those placeholder FDs point to real
kernel BPF map objects.
This change allows to delay BPF map creation to after all the BPF
program relocations. That, in turn, allows to delay BTF finalization and
loading into kernel to after all the relocations as well. We'll take
advantage of the latter in subsequent patches to allow libbpf to adjust
BTF in a way that helps with BPF global function usage.
Clean up a few places where we close map->fd, which now shouldn't
happen, because map->fd should be a valid FD regardless of whether map
was created or not. Surprisingly and nicely it simplifies a bunch of
error handling code. If this change doesn't backfire, I'm tempted to
pre-create such stable FDs for other entities (progs, maybe even BTF).
We previously did some manipulations to make gen_loader work with fake
map FDs, with stable map FDs this hack is not necessary for maps (we
still have it for BTF, but I left it as is for now).
Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20240104013847.3875810-5-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'fs/sysv/balloc.c')
0 files changed, 0 insertions, 0 deletions