From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: jolsa@kernel.org, quentin@isovalent.com, alan.maguire@oracle.com,
eddyz87@gmail.com, andrii.nakryiko@gmail.com, ast@kernel.org,
daniel@iogearbox.net, bpf@vger.kernel.org
Subject: Re: [PATCH dwarves v9 3/3] pahole: Inject kfunc decl tags into BTF
Date: Tue, 30 Apr 2024 16:57:26 -0300 [thread overview]
Message-ID: <ZjFNJmfq-DKQYx9K@x1> (raw)
In-Reply-To: <26ec519a00aa47f25bc6b4c7e4e15e5191ba4d45.1714430735.git.dxu@dxuuu.xyz>
On Mon, Apr 29, 2024 at 04:46:00PM -0600, 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.
>
> Example of encoding:
>
> $ bpftool btf dump file .tmp_vmlinux.btf | rg "DECL_TAG 'bpf_kfunc'" | wc -l
> 121
>
> $ bpftool btf dump file .tmp_vmlinux.btf | rg 56337
> [56337] FUNC 'bpf_ct_change_timeout' type_id=56336 linkage=static
> [127861] DECL_TAG 'bpf_kfunc' type_id=56337 component_idx=-1
>
> 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.
>
> This feature is enabled with --btf_features=decl_tag,decl_tag_kfuncs.
>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
> Tested-by: Jiri Olsa <jolsa@kernel.org>
> Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
> Tested-by: Alan Maguire <alan.maguire@oracle.com>
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Here I needed this to avoid an strdup possibly followed by a free and
then checking the strdup result, please Ack/revalidate tags. I'm
dropping them as there are changes.
- Arnaldo
diff --git a/btf_encoder.c b/btf_encoder.c
index e9d82e0af0e178fd..c2df2bc7a374447b 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -1434,11 +1434,13 @@ static char *get_func_name(const char *sym)
return NULL;
/* Strip prefix and handle malformed input such as __BTF_ID__func___ */
- func = strdup(sym + sizeof(BTF_ID_FUNC_PFX) - 1);
- if (!strstr(func, "__")) {
- free(func);
+ const char *func_sans_prefix = sym + sizeof(BTF_ID_FUNC_PFX) - 1;
+ if (!strstr(func_sans_prefix, "__"))
return NULL;
- }
+
+ func = strdup(func_sans_prefix);
+ if (!func)
+ return NULL;
/* Strip suffix */
end = strrchr(func, '_');
next prev parent reply other threads:[~2024-04-30 19:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 22:45 [PATCH dwarves v9 0/3] pahole: Inject kfunc decl tags into BTF Daniel Xu
2024-04-29 22:45 ` [PATCH dwarves v9 1/3] pahole: Save input filename separate from output Daniel Xu
2024-04-30 18:41 ` Arnaldo Carvalho de Melo
2024-04-29 22:45 ` [PATCH dwarves v9 2/3] pahole: Add --btf_feature=decl_tag_kfuncs feature Daniel Xu
2024-04-30 18:48 ` Arnaldo Carvalho de Melo
2024-04-30 23:00 ` Daniel Xu
2024-05-02 11:49 ` Alan Maguire
2024-05-02 13:35 ` Arnaldo Carvalho de Melo
2024-05-02 13:43 ` Alan Maguire
2024-04-29 22:46 ` [PATCH dwarves v9 3/3] pahole: Inject kfunc decl tags into BTF Daniel Xu
2024-04-30 19:57 ` Arnaldo Carvalho de Melo [this message]
2024-04-30 23:29 ` Daniel Xu
2024-04-30 20:42 ` Arnaldo Carvalho de Melo
2024-04-30 23:27 ` Daniel Xu
2024-05-06 20:07 ` Arnaldo Carvalho de Melo
2024-05-07 2:18 ` 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=ZjFNJmfq-DKQYx9K@x1 \
--to=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dxu@dxuuu.xyz \
--cc=eddyz87@gmail.com \
--cc=jolsa@kernel.org \
--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 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.