On Wed, Mar 20, 2024 at 12:54:11PM +0000, Alan Maguire wrote: > On 15/03/2024 19:48, 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. > > > > Signed-off-by: Daniel Xu <dxu@xxxxxxxxx> > > This is great work; a lot of steps needed to collect this info, but it's > really valuable! > > Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > Tested-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > > BTW we need something like the attached patch to switch to using > --btf_features for pahole 1.26 and later; will I send it officially or > do you have something that does the same that you want to roll into your > bpf-next series? Let me know what works from your side. Thanks! SNIP > > From 2ca37cfa1e9be4f4d9717fc3dc346cdd7c617e32 Mon Sep 17 00:00:00 2001 > From: Alan Maguire <alan.maguire@xxxxxxxxxx> > Date: Mon, 11 Mar 2024 10:17:47 +0000 > Subject: [PATCH bpf-next] kbuild,bpf: switch to using --btf_features for > pahole v1.26 and later > > The btf_features list can be used for pahole v1.26 and later - > it is useful because if a feature is not yet implemented it will > not exit with a failure message. This will allow us to add feature > requests to the pahole options without having to check pahole versions > in future; if the version of pahole supports the feature it will be > added. > > Signed-off-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > --- > scripts/Makefile.btf | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf > index 82377e470aed..9694ca3c5252 100644 > --- a/scripts/Makefile.btf > +++ b/scripts/Makefile.btf > @@ -12,8 +12,11 @@ pahole-flags-$(call test-ge, $(pahole-ver), 121) += --btf_gen_floats > > pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j > > -pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust > - > pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsistent_proto --btf_gen_optimized > > +# Switch to using --btf_features for v1.26 and later. > +pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j --btf_features=encode_force,var,float,emum64,decl_tag,type_tag,optimized_func,consistent_func I was testing with '--btf_features=all' but I guess it's better to be specific, lgtm jirka > + > +pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust > + > export PAHOLE_FLAGS := $(pahole-flags-y) > -- > 2.39.3 >