-
Notifications
You must be signed in to change notification settings - Fork 5
support inline tracing with BTF #6114
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
Closed
kernel-patches-daemon-bpf-rc
wants to merge
15
commits into
bpf-next_base
from
series/1009483=>bpf-next
Closed
support inline tracing with BTF #6114
kernel-patches-daemon-bpf-rc
wants to merge
15
commits into
bpf-next_base
from
series/1009483=>bpf-next
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add BTF_KIND_LOC_PARAM, BTF_KIND_LOC_PROTO and BTF_KIND_LOCSEC to help represent location information for functions. BTF_KIND_LOC_PARAM is used to represent how we retrieve data at a location; either via a register, or register+offset or a constant value. BTF_KIND_LOC_PROTO represents location information about a location with multiple BTF_KIND_LOC_PARAMs. And finally BTF_KIND_LOCSEC is a set of location sites, each of which has - a name (function name) - a function prototype specifying which types are associated with parameters - a location prototype specifying where to find those parameters - an address offset This can be used to represent - a fully-inlined function - a partially-inlined function where some _LOC_PROTOs represent inlined sites as above and others have normal _FUNC representations - a function with optimized parameters; again the FUNC_PROTO represents the original function, with LOC info telling us where to obtain each parameter (or 0 if the parameter is unobtainable) Signed-off-by: Alan Maguire <[email protected]>
Add support for new kinds to libbpf. BTF_KIND_LOC_PARAM and BTF_KIND_LOC_PROTO are dedup-able so add support for their deduplication, whereas since BTF_KIND_LOCSEC contains a unique offset it is not. Other considerations: because BTF_KIND_LOCSEC has multiple member type ids we need to increase the number of member elements to 2 in the field iterator. Add APIs to add location param, location prototypes and location sections. For BTF relocation we add location info to split BTF. One small thing noticed during testing; the test for adding_to_base relies on the split BTF start id being > 1; however it is possible to have empty distilled base BTF, so this test should be generalized to check for the base BTF pointer (it will be non-NULL for split BTF even if the base BTF is empty). Signed-off-by: Alan Maguire <[email protected]>
When creating split BTF for the .BTF.extra section to record location information, we need to add function prototypes that refer to base BTF (vmlinux) types. However since .BTF.extra is split BTF we have a problem; since collecting those type ids for the parameters, the base vmlinux BTF has been deduplicated so the type ids are stale. As a result it is valuable to be able to access the map from old->new type ids that is constructed as part of deduplication. This allows us to update the out-of-date type ids in the FUNC_PROTOs. In order to pass the map back, we need to fill out all of the hypot map mappings; as an optimization normal dedup only computes type id mappings needed in existing BTF type id references. Signed-off-by: Alan Maguire <[email protected]>
When creating multi-split BTF we correctly set the start string offset to be the size of the base string section plus the base BTF start string offset; the latter is needed for multi-split BTF since the offset is non-zero there. Unfortunately the BTF parsing case needed that logic and it was missed. Fixes: 4e29128 ("libbpf/btf: Fix string handling to support multi-split BTF") Signed-off-by: Alan Maguire <[email protected]>
In raw mode ensure we can dump new BTF kinds in normal/json format. Signed-off-by: Alan Maguire <[email protected]>
For bpftool to be able to dump .BTF.extra data in /sys/kernel/btf_extra for modules, it needs to support multi-split BTF because the parent-child relationship of BTF extra data for modules is vmlinux BTF data module BTF data module BTF extra data So for example to dump BTF extra info for xfs we would run $ bpftool btf dump -B /sys/kernel/btf/vmlinux -B /sys/kernel/btf/xfs file /sys/kernel/btf_extra/xfs Multiple bases are specified with the vmlinux base BTF first (parent) followed by the xfs BTF (child), and finally the XFS BTF extra. Signed-off-by: Alan Maguire <[email protected]>
Add support to dump, encode and validate new location-related kinds. Signed-off-by: Alan Maguire <[email protected]>
BTF_KIND_LOC[_PARAM|_PROTO|SEC] need to work with field iteration, so extend the selftest to cover these and ensure iteration over all types and names succeeds. Signed-off-by: Alan Maguire <[email protected]>
Ensure that location params/protos are deduplicated and location sections are not, and that references to deduplicated locations within location prototypes and sections are updated after deduplication. Signed-off-by: Alan Maguire <[email protected]>
…split BTF When creating distilled BTF, BTF_KIND_LOC_PARAM and BTF_KIND_LOC_PROTO should be added to split BTF. This means potentially some duplication of location information, but only for out-of-tree modules that use distilled base/split BTF. Signed-off-by: Alan Maguire <[email protected]>
information .BTF.extra sections wil be used to add additional BTF information for inlines etc. .BTF.extra sections are split BTF relative to kernel/module BTF and are enabled via CONFIG_DEBUG_INFO_BTF_EXTRA. It is bool for now but will become tristate in a later patch when support for a separate module is added (vmlinux .BTF.extra is 9Mb so 'y' is not a good option for most cases since it will bloat vmlinux size). Signed-off-by: Alan Maguire <[email protected]>
Allow module-based delivery of potentially large vmlinux .BTF.extra section; section; also support visibility of BTF data in kernel, modules in /sys/kernel/btf_extra. Signed-off-by: Alan Maguire <[email protected]>
Add btf__load_btf_extra() function to load extra BTF relative to base passed in. Base can be vmlinux or module BTF. Signed-off-by: Alan Maguire <[email protected]>
Add support for BTF-based location attachment via multiple kprobes
attaching to each instance of an inline site. Note this is not kprobe
multi attach since that requires fprobe on entry and sites are within
functions. Implementation similar to USDT manager where we use BTF
to create a location manager and populate expected arg values with
metadata based upon BTF_KIND_LOC_PARAM/LOC_PROTOs.
Add new auto-attach SEC("kloc/module:name") where the module is
vmlinux/kernel module and the name is the name of the associated
location; all sites associated with that name will be attached via
kprobes for tracing.
Signed-off-by: Alan Maguire <[email protected]>
Add a test tracing a vmlinux inline function called from __sys_bpf() and ensure one of its arguments - if available - is as expected. A simple test as a starting point but it does demonstrate the viability of the approach. Ideally we would add a bunch of inlines to bpf_testmod, but need to have BTF distillation/relocation working for .BTF.extra sections; that is not yet implemented. Signed-off-by: Alan Maguire <[email protected]>
Author
|
Upstream branch: 56b4d16 |
Author
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1009483 expired. Closing PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: support inline tracing with BTF
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1009483