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>,
	Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Hao Luo <haoluo@google.com>, Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Alan Maguire <alan.maguire@oracle.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [RFC bpf-next 09/11] selftests/bpf: Add usdt trigger bench
Date: Sat, 16 Nov 2024 22:45:01 +0100	[thread overview]
Message-ID: <ZzkSXTjGxNGnpzZX@krava> (raw)
In-Reply-To: <CAEf4BzaXvdXr4dyHrozWYyMHJor5GpaHnPF8=8qy0r_5Crb3wg@mail.gmail.com>

On Thu, Nov 14, 2024 at 03:40:53PM -0800, Andrii Nakryiko wrote:
> On Tue, Nov 5, 2024 at 5:35 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Adding usdt trigger bench to meassure optimized usdt probes.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/testing/selftests/bpf/bench.c           |  2 +
> >  .../selftests/bpf/benchs/bench_trigger.c      | 45 +++++++++++++++++++
> >  .../selftests/bpf/progs/trigger_bench.c       | 10 ++++-
> >  3 files changed, 56 insertions(+), 1 deletion(-)
> >
> 
> Why not just adding uprobe-nop5 benchmark instead of going all the way
> into USDT? Seems simpler and will benchmark all the same stuff?

ok, perhaps with your new usdt library and the possible nop/nop5 tricks we
might want to have specific usdt benchmarks.. but that's for later anyway

jirka

> 
> > diff --git a/tools/testing/selftests/bpf/bench.c b/tools/testing/selftests/bpf/bench.c
> > index 1bd403a5ef7b..dc5121e49623 100644
> > --- a/tools/testing/selftests/bpf/bench.c
> > +++ b/tools/testing/selftests/bpf/bench.c
> > @@ -526,6 +526,7 @@ extern const struct bench bench_trig_uprobe_multi_push;
> >  extern const struct bench bench_trig_uretprobe_multi_push;
> >  extern const struct bench bench_trig_uprobe_multi_ret;
> >  extern const struct bench bench_trig_uretprobe_multi_ret;
> > +extern const struct bench bench_trig_usdt;
> >
> >  extern const struct bench bench_rb_libbpf;
> >  extern const struct bench bench_rb_custom;
> > @@ -586,6 +587,7 @@ static const struct bench *benchs[] = {
> >         &bench_trig_uretprobe_multi_push,
> >         &bench_trig_uprobe_multi_ret,
> >         &bench_trig_uretprobe_multi_ret,
> > +       &bench_trig_usdt,
> >         /* ringbuf/perfbuf benchmarks */
> >         &bench_rb_libbpf,
> >         &bench_rb_custom,
> > diff --git a/tools/testing/selftests/bpf/benchs/bench_trigger.c b/tools/testing/selftests/bpf/benchs/bench_trigger.c
> > index 32e9f194d449..bdee8b8362d0 100644
> > --- a/tools/testing/selftests/bpf/benchs/bench_trigger.c
> > +++ b/tools/testing/selftests/bpf/benchs/bench_trigger.c
> > @@ -8,6 +8,7 @@
> >  #include "bench.h"
> >  #include "trigger_bench.skel.h"
> >  #include "trace_helpers.h"
> > +#include "../sdt.h"
> >
> >  #define MAX_TRIG_BATCH_ITERS 1000
> >
> > @@ -333,6 +334,13 @@ static void *uprobe_producer_ret(void *input)
> >         return NULL;
> >  }
> >
> > +static void *uprobe_producer_usdt(void *input)
> > +{
> > +       while (true)
> > +               STAP_PROBE(trigger, usdt);
> > +       return NULL;
> > +}
> > +
> >  static void usetup(bool use_retprobe, bool use_multi, void *target_addr)
> >  {
> >         size_t uprobe_offset;
> > @@ -383,6 +391,37 @@ static void usetup(bool use_retprobe, bool use_multi, void *target_addr)
> >         }
> >  }
> >
> > +static void __usdt_setup(const char *provider, const char *name)
> > +{
> > +       struct bpf_link *link;
> > +       int err;
> > +
> > +       setup_libbpf();
> > +
> > +       ctx.skel = trigger_bench__open();
> > +       if (!ctx.skel) {
> > +               fprintf(stderr, "failed to open skeleton\n");
> > +               exit(1);
> > +       }
> > +
> > +       bpf_program__set_autoload(ctx.skel->progs.bench_trigger_usdt, true);
> > +
> > +       err = trigger_bench__load(ctx.skel);
> > +       if (err) {
> > +               fprintf(stderr, "failed to load skeleton\n");
> > +               exit(1);
> > +       }
> > +
> > +       link = bpf_program__attach_usdt(ctx.skel->progs.bench_trigger_usdt,
> > +                                       -1 /* all PIDs */, "/proc/self/exe",
> > +                                       provider, name, NULL);
> > +       if (!link) {
> > +               fprintf(stderr, "failed to attach uprobe!\n");
> > +               exit(1);
> > +       }
> > +       ctx.skel->links.bench_trigger_usdt = link;
> > +}
> > +
> >  static void usermode_count_setup(void)
> >  {
> >         ctx.usermode_counters = true;
> > @@ -448,6 +487,11 @@ static void uretprobe_multi_ret_setup(void)
> >         usetup(true, true /* use_multi */, &uprobe_target_ret);
> >  }
> >
> > +static void usdt_setup(void)
> > +{
> > +       __usdt_setup("trigger", "usdt");
> > +}
> > +
> >  const struct bench bench_trig_syscall_count = {
> >         .name = "trig-syscall-count",
> >         .validate = trigger_validate,
> > @@ -506,3 +550,4 @@ BENCH_TRIG_USERMODE(uprobe_multi_ret, ret, "uprobe-multi-ret");
> >  BENCH_TRIG_USERMODE(uretprobe_multi_nop, nop, "uretprobe-multi-nop");
> >  BENCH_TRIG_USERMODE(uretprobe_multi_push, push, "uretprobe-multi-push");
> >  BENCH_TRIG_USERMODE(uretprobe_multi_ret, ret, "uretprobe-multi-ret");
> > +BENCH_TRIG_USERMODE(usdt, usdt, "usdt");
> > diff --git a/tools/testing/selftests/bpf/progs/trigger_bench.c b/tools/testing/selftests/bpf/progs/trigger_bench.c
> > index 044a6d78923e..7b7d4a71e7d4 100644
> > --- a/tools/testing/selftests/bpf/progs/trigger_bench.c
> > +++ b/tools/testing/selftests/bpf/progs/trigger_bench.c
> > @@ -1,8 +1,9 @@
> >  // SPDX-License-Identifier: GPL-2.0
> >  // Copyright (c) 2020 Facebook
> > -#include <linux/bpf.h>
> > +#include "vmlinux.h"
> >  #include <asm/unistd.h>
> >  #include <bpf/bpf_helpers.h>
> > +#include <bpf/usdt.bpf.h>
> >  #include <bpf/bpf_tracing.h>
> >  #include "bpf_misc.h"
> >
> > @@ -138,3 +139,10 @@ int bench_trigger_rawtp(void *ctx)
> >         inc_counter();
> >         return 0;
> >  }
> > +
> > +SEC("?usdt")
> > +int bench_trigger_usdt(struct pt_regs *ctx)
> > +{
> > +       inc_counter();
> > +       return 0;
> > +}
> > --
> > 2.47.0
> >

  reply	other threads:[~2024-11-16 21:45 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-05 13:33 [RFC 00/11] uprobes: Add support to optimize usdt probes on x86_64 Jiri Olsa
2024-11-05 13:33 ` [RFC perf/core 01/11] uprobes: Rename arch_uretprobe_trampoline function Jiri Olsa
2024-11-05 13:33 ` [RFC perf/core 02/11] uprobes: Make copy_from_page global Jiri Olsa
2024-11-14 23:40   ` Andrii Nakryiko
2024-11-16 21:41     ` Jiri Olsa
2024-11-05 13:33 ` [RFC perf/core 03/11] uprobes: Add len argument to uprobe_write_opcode Jiri Olsa
2024-11-14 23:41   ` Andrii Nakryiko
2024-11-16 21:41     ` Jiri Olsa
2024-11-05 13:33 ` [RFC perf/core 04/11] uprobes: Add data argument to uprobe_write_opcode function Jiri Olsa
2024-11-14 23:41   ` Andrii Nakryiko
2024-11-16 21:43     ` Jiri Olsa
2024-11-05 13:33 ` [RFC perf/core 05/11] uprobes: Add mapping for optimized uprobe trampolines Jiri Olsa
2024-11-05 14:23   ` Peter Zijlstra
2024-11-05 16:33     ` Jiri Olsa
2024-11-14 23:44       ` Andrii Nakryiko
2024-11-16 21:44         ` Jiri Olsa
2024-11-19  6:06           ` Andrii Nakryiko
2024-11-19  9:13             ` Peter Zijlstra
2024-11-19 15:15               ` Jiri Olsa
2024-11-21  0:07               ` Andrii Nakryiko
2024-11-21 11:53                 ` Peter Zijlstra
2024-11-21 16:02                   ` Alexei Starovoitov
2024-11-21 16:34                     ` Peter Zijlstra
2024-11-21 16:47                       ` Alexei Starovoitov
2024-11-21 19:38                         ` Mark Rutland
2024-11-14 23:44   ` Andrii Nakryiko
2024-11-16 21:44     ` Jiri Olsa
2024-11-19  6:05       ` Andrii Nakryiko
2024-11-19 15:14         ` Jiri Olsa
2024-11-21  0:10           ` Andrii Nakryiko
2024-11-05 13:34 ` [RFC perf/core 06/11] uprobes: Add uprobe syscall to speed up uprobe Jiri Olsa
2024-11-05 13:34 ` [RFC perf/core 07/11] uprobes/x86: Add support to optimize uprobes Jiri Olsa
2024-11-14 23:44   ` Andrii Nakryiko
2024-11-16 21:44     ` Jiri Olsa
2024-11-18  8:18   ` Masami Hiramatsu
2024-11-18  9:39     ` Jiri Olsa
2024-11-05 13:34 ` [RFC bpf-next 08/11] selftests/bpf: Use 5-byte nop for x86 usdt probes Jiri Olsa
2024-11-05 13:34 ` [RFC bpf-next 09/11] selftests/bpf: Add usdt trigger bench Jiri Olsa
2024-11-14 23:40   ` Andrii Nakryiko
2024-11-16 21:45     ` Jiri Olsa [this message]
2024-11-19  6:08       ` Andrii Nakryiko
2024-11-05 13:34 ` [RFC bpf-next 10/11] selftests/bpf: Add uprobe/usdt optimized test Jiri Olsa
2024-11-05 13:34 ` [RFC bpf-next 11/11] selftests/bpf: Add hit/attach/detach race optimized uprobe test Jiri Olsa
2024-11-17 11:49 ` [RFC 00/11] uprobes: Add support to optimize usdt probes on x86_64 Peter Zijlstra
2024-11-18  9:29   ` Jiri Olsa
2024-11-18 10:06   ` Mark Rutland
2024-11-19  6:13     ` Andrii Nakryiko
2024-11-21 18:18       ` Mark Rutland
2024-11-26 19:13         ` Andrii Nakryiko
2024-11-18  8:04 ` Masami Hiramatsu
2024-11-18  9:52   ` 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=ZzkSXTjGxNGnpzZX@krava \
    --to=olsajiri@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --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=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).