Re: [PATCH dwarves] pahole: Inject kfunc decl tags into BTF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> ---
>  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)

Maybe we need a codemod from:

        BTF_ID(func, ...

to:

        BTF_ID(kfunc, ...


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.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux