BPF List
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
	Viktor Malik <vmalik@redhat.com>
Subject: [PATCH RFCv2 bpf-next 0/4] bpf: Introduce kprobe multi wrapper attach
Date: Wed, 28 Feb 2024 10:02:38 +0100	[thread overview]
Message-ID: <20240228090242.4040210-1-jolsa@kernel.org> (raw)

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

             reply	other threads:[~2024-02-28  9:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  9:02 Jiri Olsa [this message]
2024-02-28  9:02 ` [PATCH RFCv2 bpf-next 1/4] bpf: Add support for kprobe multi wrapper attach 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240228090242.4040210-1-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=mhiramat@kernel.org \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=vmalik@redhat.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox