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

runtime: add uprobe_multi support #252

Closed
wants to merge 15 commits into from

Conversation

Officeyutong
Copy link
Contributor

@Officeyutong Officeyutong commented Mar 19, 2024

uprobe_multi is a special type of uprobe, which allows hooking multiple userspace functions in a single attach. This PR adds uprobe_multi support for uprobe_attach_impl, the corresponding example, and update CI

Closes #214

See https://lore.kernel.org/bpf/[email protected]/ for details

Our design

In the kernel bpf, the attaching of uprobe_multi were implemented through creating a bpf link, and filling all information (such as pid, function offset, attach cookies) in the link opts. You may find it in bpf_program__attach_uprobe_multi

But in bpftime, all attaches are required to have an attach target (a.k.a perf event), so for uprobe_multi that doesn't give us a perf event, we have a slightly different implementation to the kernel: When creating a bpf link, we doesn't only record configurations from bpf_link_create_opts into the handler, but also do we create some perf events for the uprobe_multi links, and record them in the handler. In this way, we tear down a uprobe_multi into several simple uprobe attach targets, and with a total bpf link. This will not affect the hooking performance.

Main changes

  • Update bpf_link_handler to make it support multiple attach targets
  • Adapt for multiple attach targets in a single bpf_link

@Officeyutong Officeyutong marked this pull request as ready for review March 22, 2024 14:59
@Officeyutong Officeyutong requested a review from yunwei37 March 22, 2024 15:03
Copy link
Member

@yunwei37 yunwei37 left a comment

Choose a reason for hiding this comment

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

Seems we still mix attach related code in runtime?

@Officeyutong Officeyutong requested a review from yunwei37 March 24, 2024 09:04
@Officeyutong Officeyutong marked this pull request as draft March 24, 2024 15:18
@Officeyutong Officeyutong marked this pull request as ready for review March 24, 2024 15:40
@Officeyutong
Copy link
Contributor Author

Not planned now

@yunwei37
Copy link
Member

And can we reopen this?

@Officeyutong
Copy link
Contributor Author

Moves to #328

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

Successfully merging this pull request may close these issues.

[idea]: Support uprobe_multi for bpftime
2 participants