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

bpf: Add kprobe multi link #2613

Closed
wants to merge 11 commits into from
Closed

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: bpf: Add kprobe multi link
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820

@kernel-patches-bot
Copy link
Author

Master branch: 13c6a37
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 6966d4c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: b4f7278
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: a19df71
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 08894d9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: c561d11
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 08d4dba
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 80bebeb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: dda7596
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 5e214f2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: c62dd8a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

Nobody and others added 6 commits February 28, 2022 07:38
Adding support to have priv pointer in swap callback function.

Following the initial change on cmp callback functions [1]
and adding SWAP_WRAPPER macro to identify sort call of sort_r.

Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
[1] 4333fb9 ("media: lib/sort.c: implement sort() variant taking context argument")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Adding new link type BPF_LINK_TYPE_KPROBE_MULTI that attaches kprobe
program through fprobe API.

The fprobe API allows to attach probe on multiple functions at once
very fast, because it works on top of ftrace. On the other hand this
limits the probe point to the function entry or return.

The kprobe program gets the same pt_regs input ctx as when it's attached
through the perf API.

Adding new attach type BPF_TRACE_KPROBE_MULTI that allows attachment
kprobe to multiple function with new link.

User provides array of addresses or symbols with count to attach the
kprobe program to. The new link_create uapi interface looks like:

  struct {
          __aligned_u64   syms;
          __aligned_u64   addrs;
          __u32           cnt;
          __u32           flags;
  } kprobe_multi;

The flags field allows single BPF_TRACE_KPROBE_MULTI bit to create
return multi kprobe.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding support to call bpf_get_func_ip helper from kprobe
programs attached by multi kprobe link.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding support to inline it on x86, because it's single
load instruction.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding support to call bpf_get_attach_cookie helper from
kprobe programs attached with kprobe multi link.

The cookie is provided by array of u64 values, where each
value is paired with provided function address or symbol
with the same array index.

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Move the kallsyms parsing in internal libbpf_kallsyms_parse
function, so it can be used from other places.

It will be used in following changes.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding new kprobe_multi struct to bpf_link_create_opts object
to pass multiple kprobe data to link_create attr uapi.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding support to bpf_program__attach_kprobe_opts to attach kprobes
to multiple functions.

If the kprobe program has BPF_TRACE_KPROBE_MULTI as expected_attach_type
it will use the new kprobe_multi link to attach the program. In this case
it will use 'func_name' as pattern for functions to attach.

Adding also new section types 'kprobe.multi' and kretprobe.multi'
that allows to specify wildcards (*?) for functions, like:

  SEC("kprobe.multi/bpf_fentry_test*")
  SEC("kretprobe.multi/bpf_fentry_test?")

This will set kprobe's expected_attach_type to BPF_TRACE_KPROBE_MULTI,
and attach it to functions provided by the function pattern.

Using glob_match from selftests/bpf/test_progs.c and adding support to
match '?' based on original perf code.

Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Yucong Sun <fallentree@fb.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding kprobe_multi attach test that uses new fprobe interface to
attach kprobe program to multiple functions.

The test is attaching programs to bpf_fentry_test* functions and
uses single trampoline program bpf_prog_test_run to trigger
bpf_fentry_test* functions.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
@kernel-patches-bot
Copy link
Author

Master branch: 07609c1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=616820
version: 1

Adding bpf_cookie test for programs attached by kprobe_multi links.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=616820 expired. Closing PR.

@kernel-patches-bot kernel-patches-bot deleted the series/616820=>bpf-next branch March 3, 2022 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants