From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, kafai@meta.com, kernel-team@meta.com,
eddyz87@gmail.com, memxor@gmail.com, peterz@infradead.org,
rostedt@goodmis.org
Cc: Mykyta Yatsenko <yatsenko@meta.com>
Subject: [PATCH bpf-next 1/3] bpf: Export btf_get_module_btf() and btf_relocate_id()
Date: Fri, 15 May 2026 09:41:01 -0700 [thread overview]
Message-ID: <20260515-generic_tracepoint-v1-1-aa619fa94132@meta.com> (raw)
In-Reply-To: <20260515-generic_tracepoint-v1-0-aa619fa94132@meta.com>
From: Mykyta Yatsenko <yatsenko@meta.com>
Make btf_get_module_btf() and btf_relocate_id() available outside
kernel/bpf/btf.c so the tracing core can look up module BTF and
translate ids stored by resolve_btfids (which are local to a
module's split BTF) into the runtime ids used by the kernel.
Used by the upcoming events/<sys>/<event>/btf_ids tracefs interface.
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
---
include/linux/btf.h | 2 ++
kernel/bpf/btf.c | 6 ++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/btf.h b/include/linux/btf.h
index 240401d9b25b..273a93a3b2bd 100644
--- a/include/linux/btf.h
+++ b/include/linux/btf.h
@@ -235,6 +235,8 @@ int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec);
bool btf_type_is_void(const struct btf_type *t);
s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind);
s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p);
+struct btf *btf_get_module_btf(const struct module *module);
+__u32 btf_relocate_id(const struct btf *btf, __u32 id);
const struct btf_type *btf_type_skip_modifiers(const struct btf *btf,
u32 id, u32 *res_id);
const struct btf_type *btf_type_resolve_ptr(const struct btf *btf,
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 17d4ab0a8206..b92914dd224c 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6429,12 +6429,13 @@ struct btf *btf_parse_vmlinux(void)
* split BTF ids will need to be mapped to actual base/split ids for
* BTF now that it has been relocated.
*/
-static __u32 btf_relocate_id(const struct btf *btf, __u32 id)
+__u32 btf_relocate_id(const struct btf *btf, __u32 id)
{
if (!btf->base_btf || !btf->base_id_map)
return id;
return btf->base_id_map[id];
}
+EXPORT_SYMBOL_GPL(btf_relocate_id);
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
@@ -8496,7 +8497,7 @@ struct module *btf_try_get_module(const struct btf *btf)
/* Returns struct btf corresponding to the struct module.
* This function can return NULL or ERR_PTR.
*/
-static struct btf *btf_get_module_btf(const struct module *module)
+struct btf *btf_get_module_btf(const struct module *module)
{
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
struct btf_module *btf_mod, *tmp;
@@ -8525,6 +8526,7 @@ static struct btf *btf_get_module_btf(const struct module *module)
return btf;
}
+EXPORT_SYMBOL_GPL(btf_get_module_btf);
static int check_btf_kconfigs(const struct module *module, const char *feature)
{
--
2.53.0-Meta
next prev parent reply other threads:[~2026-05-15 16:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 16:41 [PATCH bpf-next 0/3] tracing: Expose tracepoint BTF ids via tracefs Mykyta Yatsenko
2026-05-15 16:41 ` Mykyta Yatsenko [this message]
2026-05-15 17:56 ` [PATCH bpf-next 1/3] bpf: Export btf_get_module_btf() and btf_relocate_id() sashiko-bot
2026-05-15 19:54 ` Mykyta Yatsenko
2026-05-15 16:41 ` [PATCH bpf-next 2/3] tracing: Expose tracepoint BTF ids via tracefs Mykyta Yatsenko
2026-05-15 18:25 ` sashiko-bot
2026-05-15 20:07 ` Mykyta Yatsenko
2026-05-15 16:41 ` [PATCH bpf-next 3/3] selftests/bpf: Add test for tracepoint btf_ids tracefs file Mykyta Yatsenko
2026-05-15 18:36 ` sashiko-bot
2026-05-15 20:09 ` Mykyta Yatsenko
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=20260515-generic_tracepoint-v1-1-aa619fa94132@meta.com \
--to=mykyta.yatsenko5@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kafai@meta.com \
--cc=kernel-team@meta.com \
--cc=memxor@gmail.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=yatsenko@meta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox