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
BTF support for tracepoints defined in modules #2479
Conversation
65ae766
to
332fd2b
Compare
332fd2b
to
bc3303f
Compare
std::unordered_set<std::string> to_dump(set); | ||
if (btf_objects.size() == 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like if bpf_objects.size() > 2
, then only vmlinux btf is dumped. And user will get an ambiguous error about incomplete/missing definitions. Do we want to have a more explicit error check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. It'll happen only if probes from multiple modules are used at once, but adding the error message should be relatively easy.
Dumping C definitions from multiple kernel modules at once can introduce type redefinitions, hence it is not supported for now. On the other hand, we can support dumping from a single module since there should be no conflicts and it could help for some situations. This will enable BTF support for tracepoints defined in modules as tracepoints always need to dump C structs from BTF for ClangParser.
For tracepoints defined in vmlinux, we support usage of BTF for type parsing which can automatically resolve types from tracepoint defs. Thanks to this feature, users do not have to include headers with necessary types manually. This commit enables the same for tracepoints defined in kernel modules. Since parsing BTF for modules is already supported for kfuncs, it is sufficient to add the tracepoint subsystem name to the list of modules. If the name of the subsystem does not correspond to a loaded module, it will be ignored. Note that this is only supported for single-subsystem tracepoints at the moment. The reason is that tracepoints require dumping of C definitions from BTF which is not possible for multiple modules at once (as it could introduce type redefinitions).
bc3303f
to
8885911
Compare
For tracepoints defined in vmlinux, we support usage of BTF for type parsing which can automatically resolve types from tracepoint defs. Thanks to this feature, users do not have to include headers with necessary types manually.
This PR enables the same for tracepoints defined in kernel modules. Since parsing of BTF for modules is already supported for kfuncs (#2315) , this change is as simple as adding the subsystem name to the list of modules whose BTF is parsed.
At the moment, this is not supported for tracepoints using wildcarded subsystems. The reason is that tracepoints require dumping of C definitions from BTF which is not possible for multiple modules at once (as it could introduce type redefinitions) so this feature is limited to single-subsystem tracepoints only.
Check #2094 to see where this is useful.
Checklist
man/adoc/bpftrace.adoc
and if needed indocs/reference_guide.md
CHANGELOG.md