From: sashiko-bot@kernel.org
To: "Anton Protopopov" <a.s.protopopov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v1 bpf-next 3/4] libbpf: Look up the functions of a module first
Date: Thu, 03 Dec 2026 18:57:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-248446@kernel.org> (raw)
In-Reply-To: <20261203172617.1137735-4-a.s.protopopov@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] libbpf: redundant own-BTF scan on miss in
find_btf_by_prefix_kind()
--
commit 22c83c9c42525589b71bc7e58f2a6c4584fceb13
Author: Anton Protopopov <a.s.protopopov@gmail.com>
libbpf: Look up the functions of a module first
This commit changes libbpf to search a module's own BTF types before falling
back to vmlinux BTF when resolving tracing targets and tracing multi globs.
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 8ed4786e0e512..b75b94add2276 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -11869,6 +11869,13 @@ static int find_btf_by_prefix_kind(const struct btf *btf, const char *prefix,
> */
> if (ret < 0 || ret >= sizeof(btf_type_name))
> return -ENAMETOOLONG;
> + /*
> + * A function of a module first, then the one of vmlinux, which the
> + * dedup of BTF merges a module function of the same prototype into
> + */
> + ret = btf__find_by_name_kind_own(btf, btf_type_name, kind);
> + if (ret > 0 || !btf__base_btf(btf))
> + return ret;
> return btf__find_by_name_kind(btf, btf_type_name, kind);
> }
[Severity: Low]
Should the fallback call btf__find_by_name_kind() on the base BTF rather than
btf?
When the symbol is absent from both btf and its base BTF,
btf__find_by_name_kind(btf, ...) searches base_btf and then scans btf's own
types a second time. For an unqualified attach name, find_kernel_btf_id()
iterates over all loaded module BTFs, doubling the own-BTF scan for every
non-matching module.
Saving base_btf = btf__base_btf(btf) and falling back to
btf__find_by_name_kind(base_btf, btf_type_name, kind) avoids the second scan.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203172617.1137735-1-a.s.protopopov@gmail.com?part=3
next prev parent reply other threads:[~2026-12-03 18:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:26 [PATCH v1 bpf-next 0/4] bpf: Refuse the vmlinux prototype for a module function Anton Protopopov
2026-12-03 17:26 ` [PATCH v1 bpf-next 1/4] " Anton Protopopov
2026-12-03 17:54 ` bot+bpf-ci
2026-12-03 17:26 ` [PATCH v1 bpf-next 2/4] bpf: Refuse the vmlinux prototype for a module function in multi links Anton Protopopov
2026-12-03 17:26 ` [PATCH v1 bpf-next 3/4] libbpf: Look up the functions of a module first Anton Protopopov
2026-12-03 18:57 ` sashiko-bot [this message]
2026-12-03 17:26 ` [PATCH v1 bpf-next 4/4] selftests/bpf: Test a vmlinux function ID with the BTF of a module Anton Protopopov
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=sashiko-outbox-248446@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a.s.protopopov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.