linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	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>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCHv5 bpf-next 06/13] libbpf: Add support for uprobe multi session attach
Date: Tue, 1 Oct 2024 15:18:07 +0200	[thread overview]
Message-ID: <Zvv2jzNRzzm1ND-y@krava> (raw)
In-Reply-To: <CAEf4BzYQLo41DtTPpkZ-mMWx-34G4h2pFKY_mDrBfFibjGHjPA@mail.gmail.com>

On Mon, Sep 30, 2024 at 02:36:35PM -0700, Andrii Nakryiko wrote:
> On Sun, Sep 29, 2024 at 1:58 PM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Adding support to attach program in uprobe session mode
> > with bpf_program__attach_uprobe_multi function.
> >
> > Adding session bool to bpf_uprobe_multi_opts struct that allows
> > to load and attach the bpf program via uprobe session.
> > the attachment to create uprobe multi session.
> >
> > Also adding new program loader section that allows:
> >   SEC("uprobe.session/bpf_fentry_test*")
> >
> > and loads/attaches uprobe program as uprobe session.
> >
> > Adding sleepable hook (uprobe.session.s) as well.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/lib/bpf/bpf.c    |  1 +
> >  tools/lib/bpf/libbpf.c | 21 ++++++++++++++++++---
> >  tools/lib/bpf/libbpf.h |  4 +++-
> >  3 files changed, 22 insertions(+), 4 deletions(-)
> >
> 
> LGTM, though see the nit below
> 
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> 
> > diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> > index 2a4c71501a17..becdfa701c75 100644
> > --- a/tools/lib/bpf/bpf.c
> > +++ b/tools/lib/bpf/bpf.c
> > @@ -776,6 +776,7 @@ int bpf_link_create(int prog_fd, int target_fd,
> >                         return libbpf_err(-EINVAL);
> >                 break;
> >         case BPF_TRACE_UPROBE_MULTI:
> > +       case BPF_TRACE_UPROBE_SESSION:
> >                 attr.link_create.uprobe_multi.flags = OPTS_GET(opts, uprobe_multi.flags, 0);
> >                 attr.link_create.uprobe_multi.cnt = OPTS_GET(opts, uprobe_multi.cnt, 0);
> >                 attr.link_create.uprobe_multi.path = ptr_to_u64(OPTS_GET(opts, uprobe_multi.path, 0));
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 3587ed7ec359..563ff5e64269 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -9410,8 +9410,10 @@ static const struct bpf_sec_def section_defs[] = {
> >         SEC_DEF("kprobe.session+",      KPROBE, BPF_TRACE_KPROBE_SESSION, SEC_NONE, attach_kprobe_session),
> >         SEC_DEF("uprobe.multi+",        KPROBE, BPF_TRACE_UPROBE_MULTI, SEC_NONE, attach_uprobe_multi),
> >         SEC_DEF("uretprobe.multi+",     KPROBE, BPF_TRACE_UPROBE_MULTI, SEC_NONE, attach_uprobe_multi),
> > +       SEC_DEF("uprobe.session+",      KPROBE, BPF_TRACE_UPROBE_SESSION, SEC_NONE, attach_uprobe_multi),
> >         SEC_DEF("uprobe.multi.s+",      KPROBE, BPF_TRACE_UPROBE_MULTI, SEC_SLEEPABLE, attach_uprobe_multi),
> >         SEC_DEF("uretprobe.multi.s+",   KPROBE, BPF_TRACE_UPROBE_MULTI, SEC_SLEEPABLE, attach_uprobe_multi),
> > +       SEC_DEF("uprobe.session.s+",    KPROBE, BPF_TRACE_UPROBE_SESSION, SEC_SLEEPABLE, attach_uprobe_multi),
> >         SEC_DEF("ksyscall+",            KPROBE, 0, SEC_NONE, attach_ksyscall),
> >         SEC_DEF("kretsyscall+",         KPROBE, 0, SEC_NONE, attach_ksyscall),
> >         SEC_DEF("usdt+",                KPROBE, 0, SEC_USDT, attach_usdt),
> > @@ -11733,7 +11735,10 @@ static int attach_uprobe_multi(const struct bpf_program *prog, long cookie, stru
> >                 ret = 0;
> >                 break;
> >         case 3:
> > -               opts.retprobe = str_has_pfx(probe_type, "uretprobe.multi");
> > +               if (str_has_pfx(probe_type, "uprobe.session"))
> > +                       opts.session = true;
> > +               else
> > +                       opts.retprobe = str_has_pfx(probe_type, "uretprobe.multi");
> 
> nit: this is very non-uniform, can you please just do:
> 
> opts.session = str_has_pfx(probe_type, "uprobe.session");
> opts.retprobe = str_has_pfx(probe_type, "uretprobe.multi");
> 
> There is no need to micro-optimize str_has_pfx() calls, IMO.

sure, will change

thanks,
jirka

  reply	other threads:[~2024-10-01 13:18 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-29 20:57 [PATCHv5 bpf-next 00/13] uprobe, bpf: Add session support Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 01/13] uprobe: Add data pointer to consumer handlers Jiri Olsa
2024-09-30  9:34   ` Oleg Nesterov
2024-09-30 21:35   ` Andrii Nakryiko
2024-09-29 20:57 ` [PATCHv5 bpf-next 02/13] uprobe: Add support for session consumer Jiri Olsa
2024-09-30  9:40   ` Oleg Nesterov
2024-09-30 11:42     ` Jiri Olsa
2024-09-30 21:36   ` Andrii Nakryiko
2024-10-01 13:17     ` Jiri Olsa
2024-10-01 17:09       ` Andrii Nakryiko
2024-09-29 20:57 ` [PATCHv5 bpf-next 03/13] bpf: Add support for uprobe multi session attach Jiri Olsa
2024-09-30 21:36   ` Andrii Nakryiko
2024-10-01 13:17     ` Jiri Olsa
2024-10-01 17:11       ` Andrii Nakryiko
2024-10-02 13:07         ` Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 04/13] bpf: Add support for uprobe multi session context Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 05/13] bpf: Allow return values 0 and 1 for uprobe/kprobe session Jiri Olsa
2024-09-30 21:36   ` Andrii Nakryiko
2024-10-01 13:18     ` Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 06/13] libbpf: Add support for uprobe multi session attach Jiri Olsa
2024-09-30 21:36   ` Andrii Nakryiko
2024-10-01 13:18     ` Jiri Olsa [this message]
2024-09-29 20:57 ` [PATCHv5 bpf-next 07/13] selftests/bpf: Add uprobe session test Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 08/13] selftests/bpf: Add uprobe session cookie test Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 09/13] selftests/bpf: Add uprobe session recursive test Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 10/13] selftests/bpf: Add uprobe session verifier test for return value Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 11/13] selftests/bpf: Add kprobe " Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 12/13] selftests/bpf: Add uprobe session single consumer test Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 13/13] selftests/bpf: Add uprobe sessions to " 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=Zvv2jzNRzzm1ND-y@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=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sdf@fomichev.me \
    --cc=songliubraving@fb.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).