From: Jiri Olsa <olsajiri@gmail.com>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: acme@kernel.org, quentin@isovalent.com,
andrii.nakryiko@gmail.com, ast@kernel.org, daniel@iogearbox.net,
bpf@vger.kernel.org
Subject: Re: [PATCH dwarves] pahole: Inject kfunc decl tags into BTF
Date: Thu, 21 Dec 2023 09:35:28 +0100 [thread overview]
Message-ID: <ZYP40EN9U9GKOu7x@krava> (raw)
In-Reply-To: <62ytcwvqvnd5wiyaic7iedfjlnh5qfclqqbsng3obx7rbpsrqv@3bjpvcep4zme>
On Wed, Dec 20, 2023 at 11:37:01PM -0700, Daniel Xu wrote:
> On Wed, Dec 20, 2023 at 03:19:52PM -0700, Daniel Xu wrote:
> > This commit teaches pahole to parse symbols in .BTF_ids section in
> > vmlinux and discover exported kfuncs. Pahole then takes the list of
> > kfuncs and injects a BTF_KIND_DECL_TAG for each kfunc.
> >
> > This enables downstream users and tools to dynamically discover which
> > kfuncs are available on a system by parsing vmlinux or module BTF, both
> > available in /sys/kernel/btf.
> >
> > Example of encoding:
> >
> > $ bpftool btf dump file .tmp_vmlinux.btf | rg DECL_TAG | wc -l
> > 388
> >
> > $ bpftool btf dump file .tmp_vmlinux.btf | rg 68940
> > [68940] FUNC 'bpf_xdp_get_xfrm_state' type_id=68939 linkage=static
> > [128124] DECL_TAG 'kfunc' type_id=68940 component_idx=-1
> >
> > Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> > ---
> > btf_encoder.c | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 202 insertions(+)
> >
>
> Hmm, looking more, seems like this will pick up non-kfunc functions as
> well. For example, kernel/trace/bpf_trace.c:
>
>
> BTF_SET_START(btf_allowlist_d_path)
> #ifdef CONFIG_SECURITY
> BTF_ID(func, security_file_permission)
> BTF_ID(func, security_inode_getattr)
> BTF_ID(func, security_file_open)
> #endif
> #ifdef CONFIG_SECURITY_PATH
> BTF_ID(func, security_path_truncate)
> #endif
> BTF_ID(func, vfs_truncate)
> BTF_ID(func, vfs_fallocate)
> BTF_ID(func, dentry_open)
> BTF_ID(func, vfs_getattr)
> BTF_ID(func, filp_close)
> BTF_SET_END(btf_allowlist_d_path)
you need to pick up only 'BTF_ID(func, ...)' IDs that belongs to SET8 lists,
which are bounded by __BTF_ID__set8__<name> symbols, which also provide size
__BTF_ID__func_* symbol that has address inside the SET8 list is kfunc
>
> Maybe we need a codemod from:
>
> BTF_ID(func, ...
>
> to:
>
> BTF_ID(kfunc, ...
I think it's better to keep just 'func' and not to do anything special for
kfuncs in resolve_btfids logic to keep it simple
also it's going to be already in pahole so if we want to make a fix in future
you need to change pahole, resolve_btfids and possibly also kernel
jirka
>
>
> The change to resolve_btfids would be relatively small. Not sure what
> the drawbacks are yet.
>
> One way or another we'll need to annotate the kfuncs in source.
next prev parent reply other threads:[~2023-12-21 8:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 22:19 [PATCH dwarves] pahole: Inject kfunc decl tags into BTF Daniel Xu
2023-12-21 6:37 ` Daniel Xu
2023-12-21 8:35 ` Jiri Olsa [this message]
2023-12-21 17:05 ` Alexei Starovoitov
2023-12-21 17:42 ` Alan Maguire
2023-12-21 18:07 ` Alexei Starovoitov
2023-12-21 18:18 ` Daniel Xu
2023-12-22 0:52 ` Alexei Starovoitov
2023-12-22 20:50 ` Daniel Xu
2023-12-22 9:55 ` Alan Maguire
2023-12-22 12:46 ` Jiri Olsa
2023-12-22 16:24 ` Alan Maguire
2023-12-22 20:55 ` Daniel Xu
2023-12-22 22:11 ` Alexei Starovoitov
2024-01-03 0:56 ` Daniel Xu
2024-01-03 8:48 ` Jiri Olsa
2024-01-03 20:19 ` Daniel Xu
2023-12-21 8:35 ` Jiri Olsa
2023-12-23 19:35 ` Daniel Xu
2023-12-21 22:57 ` David Marchevsky
2023-12-23 19:40 ` Daniel Xu
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=ZYP40EN9U9GKOu7x@krava \
--to=olsajiri@gmail.com \
--cc=acme@kernel.org \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dxu@dxuuu.xyz \
--cc=quentin@isovalent.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