BPF List
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: 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@google.com>, Hao Luo <haoluo@google.com>
Subject: Re: [PATCHv3 bpf-next 21/26] selftests/bpf: Add uprobe_multi bench test
Date: Tue, 11 Jul 2023 11:07:01 +0200	[thread overview]
Message-ID: <ZK0bteQwo7NPRDi4@krava> (raw)
In-Reply-To: <CAEf4BzYrKXWskLfHY+FOLWjNMvm_ujvmHVB6ai8zrMevFXEg2Q@mail.gmail.com>

On Thu, Jul 06, 2023 at 09:38:20PM -0700, Andrii Nakryiko wrote:
> On Fri, Jun 30, 2023 at 1:38 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Adding test that attaches 50k uprobes in uprobe_multi binary.
> >
> > After the attach is done we run the binary and make sure we
> > get proper amount of hits.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  .../bpf/prog_tests/uprobe_multi_test.c        | 56 +++++++++++++++++++
> >  .../selftests/bpf/progs/uprobe_multi.c        |  9 +++
> >  2 files changed, 65 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
> > index fd858636b8b0..547d46965d70 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
> > @@ -202,6 +202,60 @@ static void test_link_api(void)
> >         free(offsets);
> >  }
> >
> > +static inline __u64 get_time_ns(void)
> > +{
> > +       struct timespec t;
> > +
> > +       clock_gettime(CLOCK_MONOTONIC, &t);
> > +       return (__u64) t.tv_sec * 1000000000 + t.tv_nsec;
> > +}
> > +
> 
> hmm.. I would expect we have this helper somewhere in common headers.
> If not, we should probably move all such helpers into one header and
> use it everywhere

hum, now I see it's also defined in bench.h, I'll try to use it from
there ;-) also perhaps in kprobe multi test

> 
> > +static void test_bench_attach_uprobe(void)
> > +{
> > +       long attach_start_ns, attach_end_ns;
> > +       long detach_start_ns, detach_end_ns;
> > +       double attach_delta, detach_delta;
> > +       struct uprobe_multi *skel = NULL;
> > +       struct bpf_program *prog;
> > +       int err;
> > +
> > +       skel = uprobe_multi__open();
> > +       if (!ASSERT_OK_PTR(skel, "uprobe_multi__open"))
> > +               goto cleanup;
> > +
> > +       bpf_object__for_each_program(prog, skel->obj)
> > +               bpf_program__set_autoload(prog, false);
> > +
> > +       bpf_program__set_autoload(skel->progs.test_uprobe_bench, true);
> 
> I don't get why you bothered adding this test_uprobe_bench into
> progs/uprobe_multi and go through this manual auto-load
> setting/resetting, instead of just having test_uprobe_bench in a
> separate skeleton?...

ok, will add separate file for that.. will be simpler

> 
> > +
> > +       err = uprobe_multi__load(skel);
> > +       if (!ASSERT_EQ(err, 0, "uprobe_multi__load"))
> > +               goto cleanup;
> > +
> > +       attach_start_ns = get_time_ns();
> > +
> > +       err = uprobe_multi__attach(skel);
> > +       if (!ASSERT_OK(err, "uprobe_multi__attach"))
> > +               goto cleanup;
> > +
> > +       attach_end_ns = get_time_ns();
> > +
> > +       system("./uprobe_multi");
> > +
> > +       ASSERT_EQ(skel->bss->count, 50000, "uprobes_count");
> > +
> > +cleanup:
> > +       detach_start_ns = get_time_ns();
> > +       uprobe_multi__destroy(skel);
> > +       detach_end_ns = get_time_ns();
> > +
> > +       attach_delta = (attach_end_ns - attach_start_ns) / 1000000000.0;
> > +       detach_delta = (detach_end_ns - detach_start_ns) / 1000000000.0;
> > +
> > +       printf("%s: attached in %7.3lfs\n", __func__, attach_delta);
> > +       printf("%s: detached in %7.3lfs\n", __func__, detach_delta);
> 
> and for us lazy folks, what are the numbers you see on your machine?

right, will put it to the changelog

	# ./test_progs -n 260/5 -v
	bpf_testmod.ko is already unloaded.
	Loading bpf_testmod.ko...
	Successfully loaded bpf_testmod.ko.
	test_bench_attach_uprobe:PASS:uprobe_multi__open 0 nsec
	test_bench_attach_uprobe:PASS:uprobe_multi__load 0 nsec
	test_bench_attach_uprobe:PASS:uprobe_multi__attach 0 nsec
	test_bench_attach_uprobe:PASS:uprobes_count 0 nsec
	test_bench_attach_uprobe: attached in   0.398s
	test_bench_attach_uprobe: detached in   0.443s
	#260/5   uprobe_multi_test/bench_uprobe:OK
	#260     uprobe_multi_test:OK
	Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
	Successfully unloaded bpf_testmod.ko.

thanks,
jirka

> 
> > +}
> > +
> >  void test_uprobe_multi_test(void)
> >  {
> >         if (test__start_subtest("skel_api"))
> > @@ -212,4 +266,6 @@ void test_uprobe_multi_test(void)
> >                 test_attach_api_syms();
> >         if (test__start_subtest("link_api"))
> >                 test_link_api();
> > +       if (test__start_subtest("bench_uprobe"))
> > +               test_bench_attach_uprobe();
> >  }
> > diff --git a/tools/testing/selftests/bpf/progs/uprobe_multi.c b/tools/testing/selftests/bpf/progs/uprobe_multi.c
> > index 1eeb9b7b9cad..cd73139dc881 100644
> > --- a/tools/testing/selftests/bpf/progs/uprobe_multi.c
> > +++ b/tools/testing/selftests/bpf/progs/uprobe_multi.c
> > @@ -89,3 +89,12 @@ int test_uretprobe_sleep(struct pt_regs *ctx)
> >         uprobe_multi_check(ctx, true, true);
> >         return 0;
> >  }
> > +
> > +int count;
> > +
> > +SEC("?uprobe.multi/./uprobe_multi:uprobe_multi_func_*")
> > +int test_uprobe_bench(struct pt_regs *ctx)
> > +{
> > +       count++;
> > +       return 0;
> > +}
> > --
> > 2.41.0
> >

  reply	other threads:[~2023-07-11  9:07 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-30  8:33 [PATCHv3 bpf-next 00/26] bpf: Add multi uprobe link Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 01/26] bpf: Add attach_type checks under bpf_prog_attach_check_attach_type Jiri Olsa
2023-07-06 22:34   ` Andrii Nakryiko
2023-06-30  8:33 ` [PATCHv3 bpf-next 02/26] bpf: Add multi uprobe link Jiri Olsa
2023-07-06 22:34   ` Andrii Nakryiko
2023-07-11  9:00     ` Jiri Olsa
2023-07-07  4:22   ` Andrii Nakryiko
2023-07-11  9:01     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 03/26] bpf: Add cookies support for uprobe_multi link Jiri Olsa
2023-07-01  3:40   ` Yafang Shao
2023-07-01  8:54     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 04/26] bpf: Add pid filter " Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 05/26] bpf: Add bpf_get_func_ip helper support for uprobe link Jiri Olsa
2023-07-06 22:29   ` Andrii Nakryiko
2023-07-10  7:24     ` Jiri Olsa
2023-07-10 17:55       ` Andrii Nakryiko
2023-07-11  8:28         ` Jiri Olsa
2023-07-11 16:57           ` Andrii Nakryiko
2023-06-30  8:33 ` [PATCHv3 bpf-next 06/26] libbpf: Add uprobe_multi attach type and link names Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 07/26] libbpf: Move elf_find_func_offset* functions to elf object Jiri Olsa
2023-07-06 23:02   ` Andrii Nakryiko
2023-07-11  9:05     ` Jiri Olsa
2023-07-11 17:01       ` Andrii Nakryiko
2023-07-06 23:03   ` Andrii Nakryiko
2023-07-11  9:05     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 08/26] libbpf: Add elf_open/elf_close functions Jiri Olsa
2023-07-06 23:09   ` Andrii Nakryiko
2023-07-11  9:01     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 09/26] libbpf: Add elf symbol iterator Jiri Olsa
2023-07-06 23:24   ` Andrii Nakryiko
2023-07-11  9:03     ` Jiri Olsa
2023-07-11 16:59       ` Andrii Nakryiko
2023-06-30  8:33 ` [PATCHv3 bpf-next 10/26] libbpf: Add elf_resolve_syms_offsets function Jiri Olsa
2023-07-07  3:48   ` Andrii Nakryiko
2023-07-11  9:04     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 11/26] libbpf: Add elf_resolve_pattern_offsets function Jiri Olsa
2023-07-07  3:52   ` Andrii Nakryiko
2023-07-11  9:04     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 12/26] libbpf: Add bpf_link_create support for multi uprobes Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 13/26] libbpf: Add bpf_program__attach_uprobe_multi function Jiri Olsa
2023-07-07  4:05   ` Andrii Nakryiko
2023-07-11  9:05     ` Jiri Olsa
2023-07-11 17:02       ` Andrii Nakryiko
2023-06-30  8:33 ` [PATCHv3 bpf-next 14/26] libbpf: Add support for u[ret]probe.multi[.s] program sections Jiri Olsa
2023-07-07  4:07   ` Andrii Nakryiko
2023-06-30  8:33 ` [PATCHv3 bpf-next 15/26] libbpf: Add uprobe multi link detection Jiri Olsa
2023-07-07  4:20   ` Andrii Nakryiko
2023-07-11  9:03     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 16/26] libbpf: Add uprobe multi link support to bpf_program__attach_usdt Jiri Olsa
2023-07-07  4:29   ` Andrii Nakryiko
2023-07-11  9:04     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 17/26] selftests/bpf: Add uprobe_multi skel test Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 18/26] selftests/bpf: Add uprobe_multi api test Jiri Olsa
2023-07-07  4:32   ` Andrii Nakryiko
2023-07-11  9:06     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 19/26] selftests/bpf: Add uprobe_multi link test Jiri Olsa
2023-07-07  4:33   ` Andrii Nakryiko
2023-07-11  9:06     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 20/26] selftests/bpf: Add uprobe_multi test program Jiri Olsa
2023-07-07  4:35   ` Andrii Nakryiko
2023-06-30  8:33 ` [PATCHv3 bpf-next 21/26] selftests/bpf: Add uprobe_multi bench test Jiri Olsa
2023-07-07  4:38   ` Andrii Nakryiko
2023-07-11  9:07     ` Jiri Olsa [this message]
2023-06-30  8:33 ` [PATCHv3 bpf-next 22/26] selftests/bpf: Add usdt_multi test program Jiri Olsa
2023-07-07  4:39   ` Andrii Nakryiko
2023-06-30  8:33 ` [PATCHv3 bpf-next 23/26] selftests/bpf: Add usdt_multi bench test Jiri Olsa
2023-07-07  4:42   ` Andrii Nakryiko
2023-07-11  9:07     ` Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 24/26] selftests/bpf: Add uprobe_multi cookie test Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 25/26] selftests/bpf: Add uprobe_multi pid filter tests Jiri Olsa
2023-06-30  8:33 ` [PATCHv3 bpf-next 26/26] selftests/bpf: Add extra link to uprobe_multi tests Jiri Olsa
2023-07-05 12:45 ` [PATCHv3 bpf-next 00/26] bpf: Add multi uprobe link Daniel Borkmann
2023-07-05 19:10   ` 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=ZK0bteQwo7NPRDi4@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=sdf@google.com \
    --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