-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 custom signal handling probe type #3522
Conversation
cb9cb69
to
4c56d2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature! Just a few comments below.
This feature is a good example of something where #3521 would be useful if we had it - it's a good feature to add but I don't think we're settled on a probe name yet. |
To throw out another idea for probe naming that combines two cases we'd eventually want to support:
|
looks more clear. if you all agree, we can use this naming. |
or maybe using
|
What is the purpose of using the |
The logical grouping was the reason in my mind. I can't think of any classes of event like this right now other than signals and keypresses. I guess another reason for grouping them behind a single probe type would be that it makes it clear that it's not tracing any signal or keypress systemwide - only ones sent to the bpftrace runtime. Another idea based on this:
|
I second this reason and this syntax makes it pretty clear that these are internal events received by bpftrace itself. I like it probably the best out of the proposed options. And it nicely opens way for more internal (pseudo-)events in future. We could even move |
7d5759b
to
4905494
Compare
b7c6bf7
to
e0f13fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice changes! A few more comments but I think that it's almost ready.
Nit: The commit message could use some more detail and perhaps an example. |
I don't mean to hold up this PR but I got confused when I first saw this naming |
Should this also deprecate the ability to print maps when issuing a SIGUSR to bpftrace? Seems strange to have both. |
I think the PR removes the functionality but fails to mention it in the docs. This is probably a good candidate for the "Breaking" changelog section and a migration guide entry. |
hmm. while defining a signal probe changes the default behavior, still it's not a breaking change for those who don’t use it. does it really need a migration guide entry? |
c1c3892
to
dce3e42
Compare
@viktormalik - Making sure you saw my comment above. What do you think about |
Apologies in advance if this sends you on bit of a side quest, but BPF_PROG_TYPE_RAW_TRACEPOINT was added in 4.17 kernel: torvalds/linux@a0fe3e5 bpftrace's policy w.r.t. old kernels is we support up to the oldest LTS kernel still in service: https://www.kernel.org/category/releases.html The oldest LTS kernel still in service is 4.19, so we are free to assume BPF_PROG_TYPE_RAW_TRACEPOINT is always available. So let's delete all the trigger probe stuff. It was always a bit of a hack. It should greatly simplify some of the stuff you're doing in this PR. Also means we can delete the feature probe ( |
@danobi just to make sure i got your point correctly, now we don't need to attach the special probes to anyting? calling |
Thanks for the ping! I agree it's a breaking change, but it'll be simple to adjust existing programs. |
0ae22d2
to
a26f8e8
Compare
Yes, that's right. And sorry about late reply - must've missed notification |
a26f8e8
to
c286f54
Compare
Hmm, I bpftrace prefix is ok. Maybe I write too much c++/rust. In both languages you end up having a top level namespace w/ same name as project. |
But do you find yourself writing the words "c++" or "rust" in these projects? Maybe it's just a gut reaction but I feel weird reading/writing "bpftrace" as a keyword in the tool/language itself. "self" is also shorter. And if we decide to someday add support for embedding bpftrace scripts in other languages then the process running these scripts will not be "bpftrace" but some other process. "self" would still apply in this case. |
:P sure. Sounds like
|
thanks folks. I’d like to know @ajor and @viktormalik opinion too before doing any modifications. |
Yeah, |
c286f54
to
611450e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the contribution!
This does make me crave the ability for bpftrace to be more interactive and be able to handle custom commands from stdin e.g. "print_maps", "lost_event_count", "print_map_value(@A, 1)", etc.
if I’m not mistaken, we can also receive data via signals. while this approach isn’t as convenient as sending data through stdin, it can still be implemented relatively easily in the future |
@viktormalik @danobi - One last look before I merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one nit.
Also, we should squash the PR, even though it's not ideal as it actually does 2 things - simplify the special probes implementation and add signal probes.
this commit implements a custom signal handling probe which will be triggered when the specified signal is sent to the bpftrace process. the default behavior of printing maps on `SIGUSR1` is removed. ``` bpftrace:signal:SIGUSR1 { print("hello"); } ``` Also trigger functions and extra checks for the special probes are removed as BPF_PROG_TYPE_RAW_TRACEPOINT was added in 4.17 kernel: torvalds/linux@a0fe3e5 The oldest LTS kernel still in service is 4.19, so we are free to assume BPF_PROG_TYPE_RAW_TRACEPOINT is always available
611450e
to
0dcca91
Compare
Did a quick skim - didn't spot any major issues |
#3500
Checklist
man/adoc/bpftrace.adoc
CHANGELOG.md