Skip to content

Conversation

@swananan
Copy link
Contributor

@swananan swananan commented Dec 15, 2025

This PR tackles #992 and focuses on multi-attach uprobes.

Main talking points:

  1. Refactors symbol resolution to batch lookups over a single object::File mmap, since repeated mmap/parse per location was too expensive for multi-attach workloads. I haven’t split out a dedicated symbol resolver yet because that felt heavier, but I’m open to doing this.

  2. Introduces #[uprobe(multi)] expectations, add attach-type checks, and emit friendly ProgramNotMulti/UProbeMultiNotSupported errors. To keep compiled_for_multi in sync, UProbe can no longer rely on the shared impl_from_prog_info! macro, so it now hand-rolls from_program_info (open to suggestions for a more reusable pattern).


This change is Reviewable

@netlify
Copy link

netlify bot commented Dec 15, 2025

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bd05ab8
🔍 Latest deploy log https://app.netlify.com/projects/aya-rs-docs/deploys/6940386f597fb90008feb51f
😎 Deploy Preview https://deploy-preview-1417--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Introduce UProbe::attach_multi with UProbeMultiAttachOptions and per-location
cookies. Require #[uprobe(multi)] programs (BPF_TRACE_UPROBE_MULTI) and guard
unsupported kernels.

Refactor symbol resolution into a single pass to batch lookups efficiently and
add integration tests covering multi-attach success and rejecting non-multi
programs
@swananan swananan force-pushed the feature/uprobe-multi-attach branch 2 times, most recently from 5beedeb to 374eba6 Compare December 15, 2025 16:32
@swananan swananan force-pushed the feature/uprobe-multi-attach branch from 374eba6 to bd05ab8 Compare December 15, 2025 16:33
Copy link
Member

@tamird tamird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tamird reviewed 8 of 13 files at r1.
Reviewable status: 8 of 14 files reviewed, 3 unresolved discussions (waiting on @swananan)


test/integration-test/src/tests/uprobe_multi.rs line 34 at r1 (raw file):

        Some(map) => map,
        None => {
            eprintln!("skipping test because RING_BUF map is unavailable");

how can this happen? if it can't, please fail the test on it.


test/integration-ebpf/src/uprobe_multi.rs line 21 at r1 (raw file):

    let cookie = unsafe { helpers::bpf_get_attach_cookie(ctx.as_ptr()) };
    let cookie_bytes = cookie.to_le_bytes();
    let _ = RING_BUF.output::<[u8]>(cookie_bytes, 0);

let _res to match existing style plz


aya/src/programs/uprobe.rs line 198 at r1 (raw file):

    ///   cookies; the list must be non-empty or the call fails with
    ///   [`UProbeError::InvalidLocations`].
    pub fn attach_multi(

does this need to be a separate function? The current attach already has an abstraction we can use (UProbeAttachLocation). We can change that type to allow it to model multiple attachment and implement conversion (From or Into) such that a user could pass a list to indicate multiple attachment. WDYT?

@swananan
Copy link
Contributor Author

@tamird I used a separate attach_multi for two reasons. First, the uprobe multi lets every location carry its own cookie, I wanted the type system to enforce that one-to-one relationship instead of juggling parallel arrays. Bundling location + cookie into the existing attach signature felt like churn—people upgrading Aya would have to touch their code even if they never use uprobe multi. Second, having a dedicated entry point keeps the docs straightforward and makes it harder to miss details like “your eBPF program must use #[uprobe(multi)]”. Even with good error messages that requirement can be surprising.

That said, these are just instincts from a Rust newbie (I’ve been around Rust for a while now, but I still feel like a newbie 😂). Yeah, I’ve noticed the current attach_multi API isn’t very idiomatic Rust either.

If we go with a single attach interface, I’d prefer to bundle the location and cookie together so we keep that one-one relationship. If that approach sounds ok to you, I'm happy to refactor it.

@tamird
Copy link
Member

tamird commented Dec 16, 2025

Bundling the two makes sense to me. Perhaps that can happen in a standalone PR ahead of this one.

swananan added a commit to swananan/aya that referenced this pull request Dec 17, 2025
This follows the aya-rs#1417 review discussion: by bundling location
+ cookie into a UProbeAttachPoint we get a more idiomatic Into<_>
entry point, keep the one-to-one relationship enforced by the type
system, and make it easier to extend attach with multi-location
support without introducing parallel arrays or a brand new API.
swananan added a commit to swananan/aya that referenced this pull request Dec 23, 2025
This follows the aya-rs#1417 review discussion: by bundling location
+ cookie into a UProbeAttachPoint we get a more idiomatic Into<_>
entry point, keep the one-to-one relationship enforced by the type
system, and make it easier to extend attach with multi-location
support without introducing parallel arrays or a brand new API.
swananan added a commit to swananan/aya that referenced this pull request Dec 23, 2025
This follows the aya-rs#1417 review discussion: by bundling location
+ cookie into a UProbeAttachPoint we get a more idiomatic Into<_>
entry point, keep the one-to-one relationship enforced by the type
system, and make it easier to extend attach with multi-location
support without introducing parallel arrays or a brand new API.
tamird pushed a commit that referenced this pull request Dec 23, 2025
This follows the #1417 review discussion: by bundling location
+ cookie into a UProbeAttachPoint we get a more idiomatic Into<_>
entry point, keep the one-to-one relationship enforced by the type
system, and make it easier to extend attach with multi-location
support without introducing parallel arrays or a brand new API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants