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

Incorrect number of probes being attached reported with kprobe globbing #3180

Open
tyroguru opened this issue May 17, 2024 · 3 comments
Open
Labels

Comments

@tyroguru
Copy link
Contributor

What reproduces the bug? Provide code if possible.

When using globbing to match multiple kprobes we use the multi kprobe link type to attach the probes. When doing this we report the number of probes being attached to as 1 instead of the actual number of probes being attached.

$ cat ~/BPF/kernelfuncs.bt
config = {
  max_probes = 50000;
}

kprobe:s*
{
  @[func] = count();
}

$ sudo ./bpftrace  ~/BPF/kernelfuncs.bt
Attaching 1 probe...

Obviously we can calculate up front how many probes we are trying to attach to though:

$ sudo ./bpftrace  -l ~/BPF/kernelfuncs.bt | wc -l
3780

I haven't tested but this problem probably applies to uprobe multi attach as well.

bpftrace --info output

@tyroguru tyroguru added the bug Something isn't working label May 17, 2024
@viktormalik
Copy link
Contributor

Technically speaking, there's only one probe being attached (from bpftrace point of view) with the list of functions passed via link_opts. OTOH, I see that this may be confusing.

At the moment, we print the amount of attached functions, along with the complete list of functions, when -v is used:

# bpftrace -v -e 'kprobe:s* { @[func] = count(); }'
node count: 7
Attaching 1 probe...
[...]
Attaching kprobe:s*
Attaching to 7867 functions
 s25fs256t_late_init
 s25fs256t_post_bfpt_fixup
 [...]

I'd suggest we change the behaviour to report

Attaching 1 probe to 7876 functions...

for the non-verbose output and add the list of functions for the verbose output.

I'm currently working on refactoring the verbosity/debug outputs so I can add this, too.

@tyroguru
Copy link
Contributor Author

I think it's important here not to introduce anything that could be confusing to an end user as it's confusing enough as it is for them. IMO there should be no difference in the output given to a user whether they specified the probes manually or whether they obtained the list of probes to enable via globbing. Exposing the details of a 1:N mapping that kprobe multi gives could be very confusing, especially if the output is different to the non-globbed way of specifying the probes.

@viktormalik
Copy link
Contributor

That's a fair point. We probably shouldn't print a different number for the same bpftrace script depending on whether the kprobe multi is used or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants