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

Add Support for USDT Probes #329

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

dave-tucker
Copy link
Member

@dave-tucker dave-tucker commented Jun 24, 2022

Adds support for USDT programs.
Doing this required a lot of work despite the uprobe support already existing.

Notable refactoring changes include:

  • Stricter parsing of /proc/$pid/maps
  • Make Features a lazy_static so they can be checked anywhere in the lib
  • Support for bpf_link_create for programs that use PerfLink

As for USDT support itself, it requires the use of maps to unify access to arguments from eBPF (one usdt can have multiple different ways to get the same arg, depending on how the compiler does its thing).
To support this an aya-common crate was added.

Since the maps would always be created whenever aya_bpf was used, USDT is it's own feature.
Also, as we don't support bpf_core_* functions in eBPF yet there is a second feature to indicate whether you are using the bpf_attach_cookie or not. This MUST match whatever is Aya uses - which is derived by probing for bpf_attach_cookie support. Not ideal, but workable in the short term.

Test Program: https://github.com/dave-tucker/usdt-test

Wishlist

Required before merge

  • Figure out how to pass the maps into this program for attach - would be nice to not have to do that 🤔
  • Add the necessary logic to load the USDT probe to each entrypoint

(Optional) can be tracked in issues afterwards

  • Ensure that we're compatible with libbpf-style USDT programs
  • Add libbpf compatible BPF code to aya-bpf such that a USDT prog written in aya could be loaded with libbpf
  • Optimize - maybe use lazy_static! for handling of /proc/pid/maps so it could be re-used if you're attaching to multiple tracepoints in the same binary.

This change is Reviewable

@netlify
Copy link

netlify bot commented Jun 24, 2022

Deploy Preview for aya-rs-docs failed.

Name Link
🔨 Latest commit 782a06b
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/67a37247355e1900081e3cf4

@dave-tucker dave-tucker marked this pull request as draft June 24, 2022 23:18
@dave-tucker dave-tucker force-pushed the usdt branch 5 times, most recently from 3522993 to 47220d0 Compare June 28, 2022 13:51
This commit refactors the handling of /proc/$pid/maps since the
collection previously assumed that all entries here could be
representeted in a HashMap. Those with a path component are stored
in a HashMap for fast lookup via library name. All other entries
are cached in a Vec to allow for filtering based on offsets, required
for supporting USDT probes.

Signed-off-by: Dave Tucker <[email protected]>
@dave-tucker dave-tucker force-pushed the usdt branch 4 times, most recently from 6ec3b64 to 8a7cf5e Compare June 28, 2022 14:47
Signed-off-by: Dave Tucker <[email protected]>
This commit adds aya-common, which is for code that is shared between
aya-bpf and aya. The initial use case is for USDT probes, which require
a lot of co-operation between aya and aya-bpf to provide a good UX.

Signed-off-by: Dave Tucker <[email protected]>
Signed-off-by: Dave Tucker <[email protected]>
Since these programs require that a few maps are created, we hide this
behind a feature since otherwise the maps will get created regardless of
the program type.

Signed-off-by: Dave Tucker <[email protected]>
Signed-off-by: Dave Tucker <[email protected]>
Signed-off-by: Dave Tucker <[email protected]>
@dave-tucker dave-tucker force-pushed the usdt branch 4 times, most recently from 594784a to 17e3e35 Compare October 12, 2022 21:29
@dave-tucker dave-tucker force-pushed the usdt branch 3 times, most recently from cfd7226 to dfd26f9 Compare October 13, 2022 08:35
@mergify mergify bot added aya This is about aya (userspace) aya-bpf This is about aya-bpf (kernel) aya-log Relating to aya-log test A PR that improves test cases or CI labels Sep 14, 2023
@mergify
Copy link

mergify bot commented Sep 14, 2023

@dave-tucker, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Sep 14, 2023
Copy link

mergify bot commented Feb 6, 2024

@dave-tucker, this pull request is now in conflict and requires a rebase.

@mergify mergify bot removed the needs-rebase label Jan 1, 2025
Copy link

mergify bot commented Jan 1, 2025

@dave-tucker, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Jan 1, 2025
@dave-tucker dave-tucker marked this pull request as draft January 31, 2025 14:32
@dave-tucker
Copy link
Member Author

Marking as draft. I intend to come back to this and rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya This is about aya (userspace) aya-bpf This is about aya-bpf (kernel) aya-log Relating to aya-log needs-rebase test A PR that improves test cases or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants