bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: John Fastabend <john.fastabend@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Viktor Malik <vmalik@redhat.com>,
	"Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Subject: Re: [PATCH bpf-next 0/7] bpf: Introduce kprobe_multi session attach
Date: Wed, 24 Apr 2024 13:43:41 +0200	[thread overview]
Message-ID: <ZijwbSFR9E_IkbcF@krava> (raw)
In-Reply-To: <662894a735565_61405208b7@john.notmuch>

On Tue, Apr 23, 2024 at 10:12:07PM -0700, John Fastabend wrote:
> Andrii Nakryiko wrote:
> > On Mon, Apr 22, 2024 at 5:12 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > >
> > > hi,
> > > adding support to attach kprobe program through kprobe_multi link
> > > in a session mode, which means:
> > >   - program is attached to both function entry and return
> > >   - entry program can decided if the return program gets executed
> > >   - entry program can share u64 cookie value with return program
> > >
> > > The initial RFC for this was posted in [0] and later discussed more
> > > and which ended up with the session idea [1]
> > >
> > > 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 the possibility to control the return program execution
> > > and sharing data within entry and return probe allows for other use
> > > cases.
> > >
> > > Changes from last RFC version [1]:
> > >   - changed wrapper name to session
> > >   - changed flag to adding new attach type for session:
> > >       BPF_TRACE_KPROBE_MULTI_SESSION
> > >     it's more convenient wrt filtering on kfuncs setup and seems
> > >     to make more sense alltogether
> > >   - renamed bpf_kprobe_multi_is_return to bpf_session_is_return
> > >   - added bpf_session_cookie kfunc, which actually already works
> > >     on current fprobe implementation (not just fprobe-on-fgraph)
> > >     and it provides the shared data between entry/return probes [Andrii]
> > >
> > >     we could actually make the cookie size configurable.. thoughts?
> > >     (it's 8 bytes atm)
> > >
> > 
> > Attach cookie is fixed at 8 bytes and that works pretty well. I think
> > beyond 8 bytes there is no clearly "right" size. A common case would
> > be to capture arguments in kprobe to handle in kretprobe, and there
> > you might need at least 40+ bytes, which seems wasteful. So I want to
> > say that it's probably good to hard-code it to just 8 bytes (enough to
> > store timestamp and you can even fit in some flags if you reduce
> > timestamp precision from nanoseconds to microseconds), or use it as an
> > index into array or some other data structure.
> > 
> > let's keep it simple?
> 
> +1 for keeping it simple. Use it as a key if you need more.

ok, it's true then it'd be tricky wrt verifier being able to check
the proper size and it does work with attach cookie so far

jirka

      reply	other threads:[~2024-04-24 11:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 12:12 [PATCH bpf-next 0/7] bpf: Introduce kprobe_multi session attach Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 1/7] bpf: Add support for kprobe multi " Jiri Olsa
2024-04-24  0:26   ` Andrii Nakryiko
2024-04-24 11:46     ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 2/7] bpf: Add support for kprobe multi session context Jiri Olsa
2024-04-24  0:26   ` Andrii Nakryiko
2024-04-24 11:45     ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 3/7] bpf: Add support for kprobe multi session cookie Jiri Olsa
2024-04-22 17:48   ` Alexei Starovoitov
2024-04-22 20:55     ` Jiri Olsa
2024-04-24  0:26   ` Andrii Nakryiko
2024-04-24 11:45     ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 4/7] libbpf: Add support for kprobe multi session attach Jiri Olsa
2024-04-24  0:26   ` Andrii Nakryiko
2024-04-24 11:45     ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 5/7] libbpf: Add kprobe session attach type name to attach_type_name Jiri Olsa
2024-04-24  0:27   ` Andrii Nakryiko
2024-04-24 11:44     ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 6/7] selftests/bpf: Add kprobe multi session test Jiri Olsa
2024-04-24  0:27   ` Andrii Nakryiko
2024-04-24 11:44     ` Jiri Olsa
2024-04-30  8:10       ` Jiri Olsa
2024-04-22 12:12 ` [PATCH bpf-next 7/7] selftests/bpf: Add kprobe multi wrapper cookie test Jiri Olsa
2024-04-24  0:27   ` Andrii Nakryiko
2024-04-24 11:44     ` Jiri Olsa
2024-04-24  0:27 ` [PATCH bpf-next 0/7] bpf: Introduce kprobe_multi session attach Andrii Nakryiko
2024-04-24  5:12   ` John Fastabend
2024-04-24 11:43     ` Jiri Olsa [this message]

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=ZijwbSFR9E_IkbcF@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).