Allow pushing an "extra" value in Frame in padding #11
+35
−8
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.
What
Per this comment on the Frame struct:
https://github.com/open-telemetry/opentelemetry-ebpf-profiler/blob/1e5516f97d8b8dea21ad0d9d3f6e126647013fcf/support/ebpf/types.h#L384-L387
This puts those bytes to work by enabling us to pass an additional value in them.
Why
6 bytes is enough for another memory address on x86_64 or aarch64, where they are limited to 48 bits.
https://github.com/torvalds/linux/blob/master/Documentation/arch/arm64/memory.rst
https://github.com/torvalds/linux/blob/master/Documentation/arch/x86/x86_64/mm.rst
Though in practice, we only really see 48 bit addresses for x86_64 and this remains the default.
Specifically, I need this patch to ferry an additional address from BPF to userspace for open-telemetry#907 in order to get accurate line numbers. I'm opening this as a separate PR as I expect these changes to be more controversial.
How
Currently there are 6 bytes of unused padding on the Frame struct. They are present for alignment purposes, but can be used to ferry an additional address to userspace if needed.
This enables
_push_with_extraon the BPF side, as well as the code to decode this on the userspace side if it is present. If an interpreter needs the extra address, they use this instead of_pushto send the address.We only encode the value if the extra value is not 0. Likewise, we only decode in userspace it if the first byte is non-zero