Skip to content

bpf: Add fprobe link

Jiri Olsa bpf lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 41 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8bpf: Add support to attach kprobe program with fprobeinclude/linux/bpf_types.h include/uapi/linux/bpf.h kernel/bpf/syscall.c +1 more+270 -52 replies
2/8bpf: Add bpf_get_func_ip kprobe helper for fprobe linkkernel/bpf/verifier.c kernel/trace/bpf_trace.c+33 -25 replies
3/8bpf: Add bpf_cookie support to fprobeinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/syscall.c +2 more+100 -35 replies
4/8libbpf: Add libbpf__kallsyms_parse functiontools/lib/bpf/libbpf.c tools/lib/bpf/libbpf_internal.h+43 -242 replies
5/8libbpf: Add bpf_link_create support for multi kprobestools/lib/bpf/bpf.c tools/lib/bpf/bpf.h+15 -10 replies
6/8libbpf: Add bpf_program__attach_kprobe_opts for multi kprobestools/lib/bpf/libbpf.c+133 -32 replies
7/8selftest/bpf: Add fprobe attach testtools/testing/selftests/bpf/prog_tests/fprobe_test.c tools/testing/selftests/bpf/progs/fprobe.c+175 -00 replies
8/8selftest/bpf: Add fprobe test for bpf_cookie valuestools/testing/selftests/bpf/prog_tests/bpf_cookie.c tools/testing/selftests/bpf/progs/fprobe_bpf_cookie.c+135 -03 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/8] bpf: Add fprobe link

hi,
this patchset adds new link type BPF_LINK_TYPE_FPROBE that attaches kprobe program through fprobe API [1] instroduced by Masami.

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.

With bpftrace support I see following attach speed:

  # perf stat --null -r 5 ./src/bpftrace -e 'kprobe:x* { } i:ms:1 { exit(); } '
  Attaching 2 probes...
  Attaching 3342 functions
  ...

1.4960 +- 0.0285 seconds time elapsed ( +- 1.91% )

Also available at:
https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
bpf/fprobe_link

thanks,
jirka

[1] https://lore.kernel.org/bpf/[email protected]/T/#t
---
Jiri Olsa (8):
bpf: Add support to attach kprobe program with fprobe
bpf: Add bpf_get_func_ip kprobe helper for fprobe link
bpf: Add bpf_cookie support to fprobe
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 fprobe attach test
selftest/bpf: Add fprobe test for bpf_cookie values

 include/linux/bpf.h                                   |   2 +
 include/linux/bpf_types.h                             |   1 +
 include/uapi/linux/bpf.h                              |  14 +++++
 kernel/bpf/syscall.c                                  | 327 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 kernel/bpf/verifier.c                                 |  19 +++++-
 kernel/trace/bpf_trace.c                              |  32 +++++++++-
 tools/include/uapi/linux/bpf.h                        |  14 +++++
 tools/lib/bpf/bpf.c                                   |   7 +++
 tools/lib/bpf/bpf.h                                   |   9 ++-
 tools/lib/bpf/libbpf.c                                | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
 tools/lib/bpf/libbpf_internal.h                       |   5 ++
 tools/testing/selftests/bpf/prog_tests/bpf_cookie.c   |  73 ++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/fprobe_test.c  | 117 +++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/fprobe.c            |  58 ++++++++++++++++++
 tools/testing/selftests/bpf/progs/fprobe_bpf_cookie.c |  62 +++++++++++++++++++
 15 files changed, 902 insertions(+), 36 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/fprobe_test.c
 create mode 100644 tools/testing/selftests/bpf/progs/fprobe.c
 create mode 100644 tools/testing/selftests/bpf/progs/fprobe_bpf_cookie.c