RFC kprobe/bpf: Add support to attach multiple kprobes
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest13 patches 22 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/13 | ftrace: Add ftrace_set_filter_ips functioninclude/ kernel/ | +47 | 0 replies | |
| 2/13 | kprobe: Keep traced function addressinclude/ kernel/ kernel/ +1 more | +18 | 4 replies | |
| 3/13 | kprobe: Add support to register multiple ftrace kprobesarch/ arch/ arch/ +2 more | +235 | 1 reply | |
| 4/13 | kprobe: Add support to register multiple ftrace kretprobesinclude/ kernel/ | +37 | 0 replies | |
| 5/13 | kprobe: Allow to get traced function address for multi ftrace kprobesarch/ include/ kernel/ +1 more | +41 | 1 reply | |
| 6/13 | samples/kprobes: Add support for multi kprobe interfacesamples/ | +43 | 0 replies | |
| 7/13 | samples/kprobes: Add support for multi kretprobe interfacesamples/ | +41 | 0 replies | |
| 8/13 | bpf: Add kprobe link for attaching raw kprobesinclude/ include/ kernel/ +1 more | +211 | 4 replies | |
| 9/13 | libbpf: Add libbpf__kallsyms_parse functiontools/ tools/ | +43 | 0 replies | |
| 10/13 | libbpf: Add bpf_link_create support for multi kprobestools/ tools/ | +11 | 0 replies | |
| 11/13 | libbpf: Add bpf_program__attach_kprobe_opts for multi kprobestools/ | +123 | 0 replies | |
| 12/13 | selftest/bpf: Add raw kprobe attach testtools/ tools/ | +150 | 0 replies | |
| 13/13 | selftest/bpf: Add bpf_cookie test for raw_k[ret]probetools/ tools/ | +65 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC 00/13] kprobe/bpf: Add support to attach multiple kprobes
hi,
adding support to attach multiple kprobes within single syscall and speed up attachment of many kprobes.
The previous attempt [1] wasn't fast enough, so coming with new approach that adds new kprobe interface.
The attachment speed of of this approach (tested in bpftrace) is now comparable to ftrace tracer attachment speed.. fast ;-)
The limit of this approach is forced by using ftrace as attach layer, so it allows only kprobes on function's entry (plus return probes).
This patchset contains:
- kprobes support to register multiple kprobes with current kprobe API (patches 1 - 8)
- bpf support ot create new kprobe link allowing to attach multiple addresses (patches 9 - 14)
We don't need to care about multiple probes on same functions because it's taken care on the ftrace_ops layer.
Also available at:
https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
kprobe/multi
thanks,
jirka
[1] https://lore.kernel.org/bpf/[email protected]/
---
Jiri Olsa (13):
ftrace: Add ftrace_set_filter_ips function
kprobe: Keep traced function address
kprobe: Add support to register multiple ftrace kprobes
kprobe: Add support to register multiple ftrace kretprobes
kprobe: Allow to get traced function address for multi ftrace kprobes samples/kprobes: Add support for multi kprobe interface samples/kprobes: Add support for multi kretprobe interface
bpf: Add kprobe link for attaching raw kprobes
libbpf: Add libbpf__kallsyms_parse function
libbpf: Add bpf_link_create support for multi kprobes
libbpf: Add bpf_program__attach_kprobe_opts for multi kprobes selftest/bpf: Add raw kprobe attach test
selftest/bpf: Add bpf_cookie test for raw_k[ret]probe
arch/Kconfig | 3 ++ arch/x86/Kconfig | 1 + arch/x86/kernel/kprobes/ftrace.c | 51 +++++++++++++----- include/linux/bpf_types.h | 1 + include/linux/ftrace.h | 3 ++ include/linux/kprobes.h | 55 ++++++++++++++++++++ include/uapi/linux/bpf.h | 12 +++++ kernel/bpf/syscall.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- kernel/kprobes.c | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------- kernel/trace/bpf_trace.c | 7 ++- kernel/trace/ftrace.c | 53 +++++++++++++++---- samples/kprobes/kprobe_example.c | 47 +++++++++++++++-- samples/kprobes/kretprobe_example.c | 43 +++++++++++++++- tools/include/uapi/linux/bpf.h | 12 +++++ tools/lib/bpf/bpf.c | 5 ++ tools/lib/bpf/bpf.h | 7 ++- tools/lib/bpf/libbpf.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- tools/lib/bpf/libbpf_internal.h | 5 ++ tools/testing/selftests/bpf/prog_tests/bpf_cookie.c | 42 +++++++++++++++ tools/testing/selftests/bpf/prog_tests/raw_kprobe_test.c | 92 +++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/get_func_ip_test.c | 4 +- tools/testing/selftests/bpf/progs/raw_kprobe.c | 58 +++++++++++++++++++++ tools/testing/selftests/bpf/progs/test_bpf_cookie.c | 24 ++++++++- 23 files changed, 1062 insertions(+), 104 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/raw_kprobe_test.c create mode 100644 tools/testing/selftests/bpf/progs/raw_kprobe.c