Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support probing for kfuncs availability #98

Open
qmonnet opened this issue May 3, 2023 · 7 comments
Open

Support probing for kfuncs availability #98

qmonnet opened this issue May 3, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@qmonnet
Copy link
Member

qmonnet commented May 3, 2023

Similarly to what we do for program types, map types, helpers, and a few other components, we could look into dumping supported kfuncs with bpftool feature probe.

It is not clear yet what the probes would look like.

@qmonnet qmonnet added the enhancement New feature or request label May 3, 2023
@danobi
Copy link
Member

danobi commented Dec 17, 2023

Interesting, I thought kfuncs were encoded into BTF. I see a reference to that here: https://github.com/torvalds/linux/blob/0e389834672c723435a44818ed2cabc4dad24429/kernel/bpf/btf.c#L7669

Mind double checking me on that? If kfuncs availability can be pulled from BTF feel free to give this one to me -- it's been bugging me for a while

@qmonnet
Copy link
Member Author

qmonnet commented Dec 18, 2023

Hey, thanks Daniel for looking into this!

As far as I'm aware, kfuncs and their prototypes are indeed available in the raw BTF, but I can't see them in the vmlinux.h generated by bpftool. In the raw BTF ouput, I don't know if there's a way to distinguish them from other non-kfuncs kernel functions.

What do you have in mind, exactly?

@danobi
Copy link
Member

danobi commented Dec 18, 2023

Hey, thanks Daniel for looking into this!

As far as I'm aware, kfuncs and their prototypes are indeed available in the raw BTF, but I can't see them in the vmlinux.h generated by bpftool. In the raw BTF ouput, I don't know if there's a way to distinguish them from other non-kfuncs kernel functions.

Ah makes sense. In that case, I was thinking of adding a BTF tag to all kfunc via __bpf_kfunc macro. Then bpftool could just walk all the tags and find kfunc tagged functions.

What do you have in mind, exactly?

I'm interested in two things:

  1. Have bpftool support a "feature dump" of all supported kfuncs on running kernel
  2. Have bpftool generate vmlinux.h with kfunc prototypes

@danobi
Copy link
Member

danobi commented Dec 18, 2023

Oh, BTF tags only work for clang built linux. Lemme think on it more

@qmonnet
Copy link
Member Author

qmonnet commented Dec 18, 2023

Would be great to have these tags, indeed. Thanks!

@danobi
Copy link
Member

danobi commented Dec 18, 2023

So I think this approach is probably still doable, except we cannot use BTF type tags from kernel side. Instead we'd probably want to teach pahole to parse the .BTF_ids section in vmlinux and generate type tags from that. But unfortunately not the quick win I was looking for :p w.r.t. how much time I can allocate to this.

@qmonnet
Copy link
Member Author

qmonnet commented Dec 19, 2023

Could be worth opening a thread on bpf@, I wouldn't be surprised if other people are interested in listing the kfuncs, too. Some may even have more suggestions, or cycles to take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants