On Tue, Dec 19, 2023 at 9:29 AM Daniel Xu <dxu@xxxxxxxxx> wrote: > > Hi, > > I was chatting w/ Quentin [0] about how bpftool could: > > 1. Support a "feature dump" of all supported kfuncs on running kernel > 2. Generate vmlinux.h with kfunc prototypes > > I had another idea this morning so I thought I'd bounce it around > on the list in case others had better ones. 3 vague ideas: > > 1. Add a BTF type tag annotation in __bpf_kfunc macro. This would > let bpftool parse BTF to do discovery. It would be fairly clean and > straightforward, except that I don't think GCC supports these type > tags. So only clang-built-linux would work. > > 2. Do the same thing as above, except rather than tagging src code, > teach pahole about the .BTF_ids section in vmlinux. pahole could then > construct BTF with the appropriate type tags. resolve_btfids knows about all of them already. The best is to teach bpftool about them as well. It can look for BTF_SET8_START and there it can find btf_ids of all kfuncs. >From there it can generate them into vmlinux.h We wanted kfuncs to appear in vmlinux.h for quite some time, but no one had cycles to do it. Still an awesome feature to have.