RFC x86/ftrace/bpf: Add batch support for direct/tracing attach
Get series with b4
b4 am [email protected]Versions newest first
- v3 RFC Latest19 patches 56 repliesIn review
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/19 | x86/ftrace: Remove extra orig rax movearch/ | +0 | 0 replies | |
| 2/19 | x86/ftrace: Remove fault protection code in prepare_ftrace_returnarch/ | +3 | 0 replies | |
| 3/19 | x86/ftrace: Make function graph use ftrace directlyarch/ arch/ arch/ +2 more | +53 | 3 replies | |
| 4/19 | tracing: Add trampoline/graph selftestkernel/ | +48 | 0 replies | |
| 5/19 | ftrace: Add ftrace_add_rec_direct functionkernel/ | +36 | 0 replies | |
| 6/19 | ftrace: Add multi direct register/unregister interfaceinclude/ kernel/ | +118 | 0 replies | |
| 7/19 | ftrace: Add multi direct modify interfaceinclude/ kernel/ | +49 | 0 replies | |
| 8/19 | ftrace/samples: Add multi direct interface test modulesamples/ samples/ | +53 | 0 replies | |
| 9/19 | bpf, x64: Allow to use caller address from stackarch/ include/ | +14 | 2 replies | |
| 10/19 | bpf: Allow to store caller's ip as argumentarch/ include/ | +19 | 6 replies | |
| 11/19 | bpf: Add support to load multi func tracing programinclude/ include/ kernel/ +3 more | +52 | 3 replies | |
| 12/19 | bpf: Add bpf_trampoline_alloc functionkernel/ | +22 | 0 replies | |
| 13/19 | bpf: Add support to link multi func tracing programinclude/ include/ kernel/ +2 more | +237 | 13 replies | |
| 14/19 | libbpf: Add btf__find_by_pattern_kind functiontools/ tools/ | +71 | 3 replies | |
| 15/19 | libbpf: Add support to link multi func tracing programtools/ tools/ tools/ | +85 | 8 replies | |
| 16/19 | selftests/bpf: Add fentry multi func testtools/ tools/ tools/ | +113 | 6 replies | |
| 17/19 | selftests/bpf: Add fexit multi func testtools/ tools/ | +64 | 0 replies | |
| 18/19 | selftests/bpf: Add fentry/fexit multi func testtools/ tools/ | +80 | 2 replies | |
| 19/19 | selftests/bpf: Temporary fix for fentry_fexit_multi_testtools/ tools/ tools/ +1 more | +32 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [RFCv3 00/19] x86/ftrace/bpf: Add batch support for direct/tracing attach
hi,
saga continues.. ;-) previous post is in here [1]
After another discussion with Steven, he mentioned that if we fix the ftrace graph problem with direct functions, he'd be open to add batch interface for direct ftrace functions.
He already had prove of concept fix for that, which I took and broke up into several changes. I added the ftrace direct batch interface and bpf new interface on top of that.
It's not so many patches after all, so I thought having them all together will help the review, because they are all connected. However I can break this up into separate patchsets if necessary.
This patchset contains:
1) patches (1-4) that fix the ftrace graph tracing over the function with direct trampolines attached
2) patches (5-8) that add batch interface for ftrace direct function register/unregister/modify
3) patches (9-19) that add support to attach BPF program to multiple functions
In nutshell:
Ad 1) moves the graph tracing setup before the direct trampoline prepares the stack, so they don't clash
Ad 2) uses ftrace_ops interface to register direct function with all functions in ftrace_ops filter.
Ad 3) creates special program and trampoline type to allow attachment of multiple functions to single program.
There're more detailed desriptions in related changelogs.
I have working bpftrace multi attachment code on top this. I briefly checked retsnoop and I think it could use the new API as well.
Also available at:
https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
bpf/batch
thanks,
jirka
[1] https://lore.kernel.org/bpf/[email protected]/
---
Jiri Olsa (17):
x86/ftrace: Remove extra orig rax move
tracing: Add trampoline/graph selftest
ftrace: Add ftrace_add_rec_direct function
ftrace: Add multi direct register/unregister interface
ftrace: Add multi direct modify interface ftrace/samples: Add multi direct interface test module bpf, x64: Allow to use caller address from stack
bpf: Allow to store caller's ip as argument
bpf: Add support to load multi func tracing program
bpf: Add bpf_trampoline_alloc function
bpf: Add support to link multi func tracing program
libbpf: Add btf__find_by_pattern_kind function
libbpf: Add support to link multi func tracing program selftests/bpf: Add fentry multi func test selftests/bpf: Add fexit multi func test selftests/bpf: Add fentry/fexit multi func test selftests/bpf: Temporary fix for fentry_fexit_multi_test
Steven Rostedt (VMware) (2):
x86/ftrace: Remove fault protection code in prepare_ftrace_return x86/ftrace: Make function graph use ftrace directly
arch/x86/include/asm/ftrace.h | 9 ++++-- arch/x86/kernel/ftrace.c | 71 ++++++++++++++++++++++----------------------- arch/x86/kernel/ftrace_64.S | 30 +------------------ arch/x86/net/bpf_jit_comp.c | 31 ++++++++++++++------ include/linux/bpf.h | 14 +++++++++ include/linux/ftrace.h | 22 ++++++++++++++ include/uapi/linux/bpf.h | 12 ++++++++ kernel/bpf/btf.c | 5 ++++ kernel/bpf/syscall.c | 220 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- kernel/bpf/trampoline.c | 83 ++++++++++++++++++++++++++++++++++++++--------------- kernel/bpf/verifier.c | 3 +- kernel/trace/fgraph.c | 8 ++++-- kernel/trace/ftrace.c | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------- kernel/trace/trace_selftest.c | 49 ++++++++++++++++++++++++++++++- samples/ftrace/Makefile | 1 + samples/ftrace/ftrace-direct-multi.c | 52 +++++++++++++++++++++++++++++++++ tools/include/uapi/linux/bpf.h | 12 ++++++++ tools/lib/bpf/bpf.c | 11 ++++++- tools/lib/bpf/bpf.h | 4 ++- tools/lib/bpf/btf.c | 68 +++++++++++++++++++++++++++++++++++++++++++ tools/lib/bpf/btf.h | 3 ++ tools/lib/bpf/libbpf.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/multi_check.h | 53 ++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/prog_tests/fentry_fexit_multi_test.c | 52 +++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/prog_tests/fentry_multi_test.c | 43 +++++++++++++++++++++++++++ tools/testing/selftests/bpf/prog_tests/fexit_multi_test.c | 44 ++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/fentry_fexit_multi_test.c | 31 ++++++++++++++++++++ tools/testing/selftests/bpf/progs/fentry_multi_test.c | 20 +++++++++++++ tools/testing/selftests/bpf/progs/fexit_multi_test.c | 22 ++++++++++++++ 29 files changed, 1121 insertions(+), 135 deletions(-) create mode 100644 samples/ftrace/ftrace-direct-multi.c create mode 100644 tools/testing/selftests/bpf/multi_check.h create mode 100644 tools/testing/selftests/bpf/prog_tests/fentry_fexit_multi_test.c create mode 100644 tools/testing/selftests/bpf/prog_tests/fentry_multi_test.c create mode 100644 tools/testing/selftests/bpf/prog_tests/fexit_multi_test.c create mode 100644 tools/testing/selftests/bpf/progs/fentry_fexit_multi_test.c create mode 100644 tools/testing/selftests/bpf/progs/fentry_multi_test.c create mode 100644 tools/testing/selftests/bpf/progs/fexit_multi_test.c