Re: [PATCHv5 bpf-next 25/28] selftests/bpf: Add uprobe_multi usdt bench test

Jiri Olsa
2023-08-02T08:24:50Z

On Tue, Aug 01, 2023 at 10:51:35AM -0700, Alexei Starovoitov wrote:
> On Sun, Jul 30, 2023 at 6:46 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Adding test that attaches 50k usdt probes in usdt_multi binary.
> >
> > After the attach is done we run the binary and make sure we get
> > proper amount of hits.
> >
> > With current uprobes:
> >
> > # perf stat --null ./test_progs -n 254/6
> > #254/6 uprobe_multi_test/bench_usdt:OK
> > #254 uprobe_multi_test:OK
> > Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
> >
> > Performance counter stats for './test_progs -n 254/6':
> >
> > 1353.659680562 seconds time elapsed
> >
> > With uprobe_multi link:
> >
> > # perf stat --null ./test_progs -n 254/6
> > #254/6 uprobe_multi_test/bench_usdt:OK
> > #254 uprobe_multi_test:OK
> > Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
> >
> > Performance counter stats for './test_progs -n 254/6':
> >
> > 0.322046364 seconds time elapsed
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> > .../bpf/prog_tests/uprobe_multi_test.c | 39 +++++++++++++++++++
> > .../selftests/bpf/progs/uprobe_multi_usdt.c | 16 ++++++++
> > 2 files changed, 55 insertions(+)
> > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_usdt.c
> >
> > 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 56c2062af1c9..19a66431a61f 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
> > @@ -4,6 +4,7 @@
> > #include <test_progs.h>
> > #include "uprobe_multi.skel.h"
> > #include "uprobe_multi_bench.skel.h"
> > +#include "uprobe_multi_usdt.skel.h"
> > #include "bpf/libbpf_internal.h"
> > #include "testing_helpers.h"
> >
> > @@ -234,6 +235,42 @@ static void test_bench_attach_uprobe(void)
> > printf("%s: detached in %7.3lfs\n", __func__, detach_delta);
> > }
> >
> > +static void test_bench_attach_usdt(void)
> > +{
> > + struct uprobe_multi_usdt *skel = NULL;
> > + long attach_start_ns, attach_end_ns;
> > + long detach_start_ns, detach_end_ns;
> > + double attach_delta, detach_delta;
> > +
> > + skel = uprobe_multi_usdt__open_and_load();
> > + if (!ASSERT_OK_PTR(skel, "uprobe_multi__open"))
> > + goto cleanup;
> > +
> > + attach_start_ns = get_time_ns();
> > +
> > + skel->links.usdt0 = bpf_program__attach_usdt(skel->progs.usdt0, -1, "./uprobe_multi",
> > + "test", "usdt", NULL);
> > + if (!ASSERT_OK_PTR(skel->links.usdt0, "bpf_program__attach_usdt"))
> > + goto cleanup;
> > +
> > + attach_end_ns = get_time_ns();
> > +
> > + system("./uprobe_multi usdt");
> > +
> > + ASSERT_EQ(skel->bss->count, 50000, "usdt_count");
> > +
> > +cleanup:
> > + detach_start_ns = get_time_ns();
> > + uprobe_multi_usdt__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);
> > +}
>
> It fails CI.
> /tmp/work/bpf/bpf/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c:338:6:
> error: variable 'attach_start_ns' is used uninitialized whenever 'if'
> condition is true [-Werror,-Wsometimes-uninitialized]
> if (!ASSERT_OK_PTR(skel, "uprobe_multi__open"))

hum, one more change is needed.. will fix

thanks,
jirka