From: sashiko-bot@kernel.org
To: "Fuyu Zhao" <zhaofuyu@vivo.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 1/2] libbpf: support selective kernel module BTF loading via bpf_object_open_opts
Date: Mon, 24 Aug 2026 13:08:05 +0000 [thread overview]
Message-ID: <20260824130806.51B591F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824125310.1384-2-zhaofuyu@vivo.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Failure to short-circuit BTF loading when the requested module list is empty.
--
--- Patch [1]: [PATCH bpf-next v4 1/2] libbpf: support selective kernel module BTF loading via bpf_object_open_opts ---
commit 45ee1cea8b0fa604bfa594a065030f18301877c5
Author: Fuyu Zhao <zhaofuyu@vivo.com>
libbpf: support selective kernel module BTF loading via bpf_object_open_opts
This commit adds btf_module_names and nr_btf_module_names to
bpf_object_open_opts, allowing selective loading of kernel module BTFs. When a
list is provided, libbpf will skip module BTFs not in the list to reduce BPF
object loading time.
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index b749c01742ee0..d8ef6ecc6f5dd 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
[ ... ]
> @@ -5851,6 +5854,94 @@ int bpf_core_add_cands(struct bpf_core_cand *local_cand,
[ ... ]
> +static bool all_needed_module_btfs_loaded(const struct bpf_object *obj)
> +{
> + return obj->btf_module_names &&
> + obj->nr_btf_module_names == obj->btf_module_cnt;
> +}
> +
> static int load_module_btfs(struct bpf_object *obj)
> {
[Severity: Medium]
Could we short-circuit this function earlier when the requested module list is
empty?
If a user passes a non-NULL btf_module_names with nr_btf_module_names = 0
(meaning no module BTFs should be loaded), this function still proceeds into
the while (true) loop, issuing system calls for every BTF object on the
system.
[ ... ]
> @@ -5915,6 +6006,11 @@ static int load_module_btfs(struct bpf_object *obj)
> continue;
> }
>
> + if (!is_module_btf_needed(obj, name)) {
> + close(fd);
> + continue;
> + }
> +
[Severity: Medium]
Does this continue bypass the early exit check when nr_btf_module_names is 0?
When the requested list is empty, is_module_btf_needed() always returns false,
triggering this continue on every iteration. This skips the
all_needed_module_btfs_loaded() check at the bottom of the loop entirely,
causing the loop to exhaustively iterate all BTFs unnecessarily.
> btf = btf_get_from_fd(fd, obj->btf_vmlinux);
> err = libbpf_get_error(btf);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824125310.1384-1-zhaofuyu@vivo.com?part=1
next prev parent reply other threads:[~2026-08-24 13:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 12:53 [PATCH bpf-next v4 0/2] libbpf: Improve BPF load performance by selectively loading kmod BTFs Fuyu Zhao
2026-08-24 12:53 ` [PATCH bpf-next v4 1/2] libbpf: support selective kernel module BTF loading via bpf_object_open_opts Fuyu Zhao
2026-08-24 13:08 ` sashiko-bot [this message]
2026-08-25 3:42 ` Fuyu Zhao
2026-08-24 13:31 ` bot+bpf-ci
2026-08-25 3:42 ` Fuyu Zhao
2026-08-24 12:53 ` [PATCH bpf-next v4 2/2] selftests/bpf: add tests for selective module BTF loading Fuyu Zhao
2026-08-24 13:31 ` bot+bpf-ci
2026-08-25 3:45 ` Fuyu Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260824130806.51B591F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhaofuyu@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.