BPF List
 help / color / mirror / Atom feed
* [PATCH RFCv2 bpf-next 0/4] bpf: Introduce kprobe multi wrapper attach
@ 2024-02-28  9:02 Jiri Olsa
  2024-02-28  9:02 ` [PATCH RFCv2 bpf-next 1/4] bpf: Add support for " Jiri Olsa
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Jiri Olsa @ 2024-02-28  9:02 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: bpf, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Masami Hiramatsu (Google),
	Viktor Malik

hi,
adding support to attach both entry and return bpf program on single
kprobe multi link. The first RFC patchset is in [0].

Having entry together with return probe for given function is common
use case for tetragon, bpftrace and most likely for others.

At the moment if we want both entry and return probe to execute bpf
program we need to create two (entry and return probe) links. The link
for return probe creates extra entry probe to setup the return probe.
The extra entry probe execution could be omitted if we had a way to
use just single link for both entry and exit probe.

In addition it's possible to control the execution of the return probe
with the return value of the entry bpf program. If the entry program
returns 0 the return probe is installed and executed, otherwise it's
skip.

v2 changes:
  - adding 'kprobe.wrapper' program that is called both for entry and
    exit probe [Andrii]
  - I kept the interface that adds new flag in attr.link_create.kprobe_multi.flags,
    because I don't see it breaking backward compatibility and it's much simpler
    than new attach type, I tried to discuss this in [1], but I'm ok to change
    that if it turns out to be a problem

thanks,
jirka


[0] https://lore.kernel.org/bpf/20240207153550.856536-1-jolsa@kernel.org/
[1] https://lore.kernel.org/bpf/ZdhmKQ1_vpCJTS_U@krava/
---
Jiri Olsa (4):
      bpf: Add support for kprobe multi wrapper attach
      bpf: Add bpf_kprobe_multi_is_return kfunc
      libbpf: Add support for kprobe multi wrapper attach
      selftests/bpf: Add kprobe multi wrapper test

 include/uapi/linux/bpf.h                                   |   3 ++-
 kernel/bpf/btf.c                                           |   3 +++
 kernel/trace/bpf_trace.c                                   |  71 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 tools/include/uapi/linux/bpf.h                             |   3 ++-
 tools/lib/bpf/libbpf.c                                     |  38 ++++++++++++++++++++++++++++---
 tools/lib/bpf/libbpf.h                                     |   4 +++-
 tools/testing/selftests/bpf/bpf_kfuncs.h                   |   2 ++
 tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c |  49 ++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/kprobe_multi_wrapper.c   | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 259 insertions(+), 14 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/kprobe_multi_wrapper.c

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-03-04  8:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28  9:02 [PATCH RFCv2 bpf-next 0/4] bpf: Introduce kprobe multi wrapper attach Jiri Olsa
2024-02-28  9:02 ` [PATCH RFCv2 bpf-next 1/4] bpf: Add support for " Jiri Olsa
2024-02-29  1:23   ` Andrii Nakryiko
2024-02-29 10:20     ` Jiri Olsa
2024-02-28  9:02 ` [PATCH RFCv2 bpf-next 2/4] bpf: Add bpf_kprobe_multi_is_return kfunc Jiri Olsa
2024-02-29  1:23   ` Andrii Nakryiko
2024-02-29 10:16     ` Jiri Olsa
2024-03-01 18:01       ` Andrii Nakryiko
2024-03-04  8:28         ` Jiri Olsa
2024-02-28  9:02 ` [PATCH RFCv2 bpf-next 3/4] libbpf: Add support for kprobe multi wrapper attach Jiri Olsa
2024-02-29  1:23   ` Andrii Nakryiko
2024-02-29 10:24     ` Jiri Olsa
2024-02-28  9:02 ` [PATCH RFCv2 bpf-next 4/4] selftests/bpf: Add kprobe multi wrapper test Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox