-
Notifications
You must be signed in to change notification settings - Fork 721
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
allow to pin kprobe and kprobe_multi links #1496
Conversation
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.
Please correct me if I'm wrong @mmat11:
- ioctl attach doesn't have pinning, so we don't allow it.
- bpf_link attach does have pinning. so far we don't allow it because we can't recover
perfEventLink.pe
. perfEventLink.pe
is used byClose()
and returned byPerfEvent()
.- contrary to ioctl attach, closing the perf event when doing bpf_link attach is not an issue.
If all of these are true, why do we have perfEvent.pe
in the first place? We could remove the field. To replace PerfEvent()
we expose an API that explicitly attaches via bpf_link (we've done similar for cgroup IIRC) and returns (Link, perfEvent *os.File, error)
or similar.
Thoughts?
link/perf_event.go
Outdated
// when loading a pinned link, so leave as not supported for now. | ||
func (pl *perfEventLink) Pin(string) error { | ||
return fmt.Errorf("perf event link pin: %w", ErrNotSupported) | ||
func (pl *perfEventLink) Pin(fileName string) error { |
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.
I think you can just remove this method + Unpin
and then you'll get the implementation from RawLink
.
should all be correct, I think we can remove |
b88f1da
to
c37accb
Compare
I'm trying the pushed code, but I'm not sure where to put the comments with fd/link states.. @lmb |
@mmat11 do you think they are still useful? Seems like the table doesn't match the reality of bpf_link attached with a perf_event (why?) and also not for the ioctl case (since that doesn't have a link fd in the first place). |
I think we can remove the comment, it refers only to the bpf_link implementation which now has pinning
These are some quick tests I made a while ago ("works" refers to the link, not the pinning) so I don't exactly remember how I got to these results, and that's what I could observe at the time. The only line that doesn't match should be
This table refers to bpf_link only |
Makes me think we should see whether we can return |
What about uprobe_multi, can that be pinned as well? |
c37accb
to
51465b5
Compare
yep, added ;-) thanks |
hm, I guess we could actually just remove Pin/Unpin methods from kprobe/uprobe multi links as well.. it'll be taken care of via raw link |
51465b5
to
c099ba1
Compare
Support pinning of Kprobe and Uprobe links. It's not possible to retrieve the perf event of a pinned link, so PerfEvent() now returns an error. Signed-off-by: Jiri Olsa <[email protected]>
Also removed the shadowed Pin/Unpin methods from kprobe multi, they aren't necessary. |
we need to pin kprobe and kprobe_multi links, ATM I'm using this, but I guess there's better way at least for standard kprobes
I'm not sure if the issue described in Pin function comment is also valid for kprobes created via perf_link,
but the pinning seems to work, and that's what we'd like to use (we don't need to re-open the link)
note the wrapRawLink for perf event kprobe needs to be done properly somehow
cc: @lmb @ti-mo