libbpf: Add bpf_prog_clone for individual program loading#11035
libbpf: Add bpf_prog_clone for individual program loading#11035kernel-patches-daemon-bpf[bot] wants to merge 2 commits intobpf-next_basefrom
Conversation
|
Upstream branch: 4475cda |
254af9f to
25c770c
Compare
|
Upstream branch: 19de32d |
8f1eb1d to
510f045
Compare
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: AI-authorship-score: low |
|
Forwarding comment 3888110456 via email |
25c770c to
1bbc6aa
Compare
|
Upstream branch: a86c608 |
510f045 to
8dc72b3
Compare
1bbc6aa to
b0043d3
Compare
|
Upstream branch: a86c608 |
8dc72b3 to
b94a91c
Compare
b0043d3 to
3d9d955
Compare
|
Upstream branch: a86c608 |
b94a91c to
e942dd3
Compare
3d9d955 to
8c8442a
Compare
|
Upstream branch: 561085f |
e942dd3 to
9b6d8e0
Compare
8c8442a to
a4a9811
Compare
|
Upstream branch: f632de6 |
9b6d8e0 to
de103f0
Compare
a4a9811 to
2650068
Compare
Add bpf_prog_clone() API that loads a single BPF program from a prepared BPF object into the kernel, returning a file descriptor owned by the caller. After bpf_object__prepare(), callers can use bpf_prog_clone() to load individual programs with custom bpf_prog_load_opts, instead of loading all programs at once via bpf_object__load(). Non-zero fields in opts override the defaults derived from the program and object internals; passing NULL opts populates everything automatically. Internally, bpf_prog_clone() resolves BTF-based attach targets (attach_btf_id, attach_btf_obj_fd) and the sleepable flag, fills func/line info, fd_array, license, and kern_version from the prepared object before calling bpf_prog_load(). Program-containing maps (PROG_ARRAY, DEVMAP, CPUMAP) track the owner program type in the kernel. When loading programs with different attributes (e.g. sleepable vs non-sleepable) from the same prepared object, the shared map would reject incompatible programs. To handle this, bpf_prog_clone() creates temporary copies of program-containing maps for each load and patches the instruction references, so each program gets a fresh map without owner conflicts. Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Replace veristat's per-program object re-opening with bpf_prog_clone(). Previously, veristat opened a separate bpf_object for every program in a multi-program object file, iterated all programs to enable only the target one, and then loaded the entire object. Use bpf_object__prepare() once, then call bpf_prog_clone() for each program individually. This lets veristat load programs one at a time from a single prepared object. The caller now owns the returned fd and closes it after collecting stats. Remove the special single-program fast path and the per-file early exit in handle_verif_mode() so all files are always processed. Split fixup_obj() into fixup_obj_maps() for object-wide map fixups that must run before bpf_object__prepare(), and fixup_obj() for per-program fixups (struct_ops masking, freplace type guessing) that run before each bpf_prog_clone() call. Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
|
Upstream branch: 4c51f90 |
de103f0 to
9d06fa6
Compare
Pull request for series with
subject: libbpf: Add bpf_prog_clone for individual program loading
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1053330