[PATCH bpf-next v9 3/3] selftests/bpf: add testcase for TRACING with 6+ arguments

Menglong Dong menglong8.dong at gmail.com
Wed Jul 12 08:11:43 PDT 2023


On Wed, Jul 12, 2023 at 10:54 PM Alexei Starovoitov
<alexei.starovoitov at gmail.com> wrote:
>
> On Wed, Jul 12, 2023 at 1:50 AM <menglong8.dong at gmail.com> wrote:
> >
> > From: Menglong Dong <imagedong at tencent.com>
> >
> > Add fentry_many_args.c and fexit_many_args.c to test the fentry/fexit
> > with 7/11 arguments. As this feature is not supported by arm64 yet, we
> > disable these testcases for arm64 in DENYLIST.aarch64. We can combine
> > them with fentry_test.c/fexit_test.c when arm64 is supported too.
> >
> > Correspondingly, add bpf_testmod_fentry_test7() and
> > bpf_testmod_fentry_test11() to bpf_testmod.c
> >
> > Meanwhile, add bpf_modify_return_test2() to test_run.c to test the
> > MODIFY_RETURN with 7 arguments.
> >
> > Add bpf_testmod_test_struct_arg_7/bpf_testmod_test_struct_arg_7 in
> > bpf_testmod.c to test the struct in the arguments.
> >
> > And the testcases passed on x86_64:
> >
> > ./test_progs -t fexit
> > Summary: 5/14 PASSED, 0 SKIPPED, 0 FAILED
> >
> > ./test_progs -t fentry
> > Summary: 3/2 PASSED, 0 SKIPPED, 0 FAILED
> >
> > ./test_progs -t modify_return
> > Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
> >
> > ./test_progs -t tracing_struct
> > Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
> >
> > Signed-off-by: Menglong Dong <imagedong at tencent.com>
> > Acked-by: Yonghong Song <yhs at fb.com>
> > ---
> > v9:
> > - change the way to test fmod_ret
> > v8:
> > - split the testcases, and add fentry_many_args/fexit_many_args to
> >   DENYLIST.aarch64
> > v6:
> > - add testcases to tracing_struct.c instead of fentry_test.c and
> >   fexit_test.c
> > v5:
> > - add testcases for MODIFY_RETURN
> > v4:
> > - use different type for args in bpf_testmod_fentry_test{7,12}
> > - add testcase for grabage values in ctx
> > v3:
> > - move bpf_fentry_test{7,12} to bpf_testmod.c and rename them to
> >   bpf_testmod_fentry_test{7,12} meanwhile
> > - get return value by bpf_get_func_ret() in
> >   "fexit/bpf_testmod_fentry_test12", as we don't change ___bpf_ctx_cast()
> >   in this version
> > ---
> >  net/bpf/test_run.c                            | 14 ++++-
> >  tools/testing/selftests/bpf/DENYLIST.aarch64  |  2 +
> >  .../selftests/bpf/bpf_testmod/bpf_testmod.c   | 49 ++++++++++++++++-
> >  .../selftests/bpf/prog_tests/fentry_test.c    | 43 +++++++++++++--
> >  .../selftests/bpf/prog_tests/fexit_test.c     | 43 +++++++++++++--
> >  .../selftests/bpf/prog_tests/modify_return.c  | 10 ++--
> >  .../selftests/bpf/prog_tests/tracing_struct.c | 19 +++++++
> >  .../selftests/bpf/progs/fentry_many_args.c    | 39 ++++++++++++++
> >  .../selftests/bpf/progs/fexit_many_args.c     | 40 ++++++++++++++
> >  .../selftests/bpf/progs/modify_return.c       | 40 ++++++++++++++
> >  .../selftests/bpf/progs/tracing_struct.c      | 54 +++++++++++++++++++
> >  11 files changed, 340 insertions(+), 13 deletions(-)
> >  create mode 100644 tools/testing/selftests/bpf/progs/fentry_many_args.c
> >  create mode 100644 tools/testing/selftests/bpf/progs/fexit_many_args.c
> >
> > diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> > index 63b11f7a5392..7d47f53f20c1 100644
> > --- a/net/bpf/test_run.c
> > +++ b/net/bpf/test_run.c
> > @@ -565,6 +565,13 @@ __bpf_kfunc int bpf_modify_return_test(int a, int *b)
> >         return a + *b;
> >  }
> >
> > +__bpf_kfunc int bpf_modify_return_test2(int a, int *b, short c, int d,
> > +                                       void *e, char f, int g)
> > +{
> > +       *b += 1;
> > +       return a + *b + c + d + (long)e + f + g;
> > +}
> > +
> >  int noinline bpf_fentry_shadow_test(int a)
> >  {
> >         return a + 1;
> > @@ -600,6 +607,7 @@ __diag_pop();
> >
> >  BTF_SET8_START(bpf_test_modify_return_ids)
> >  BTF_ID_FLAGS(func, bpf_modify_return_test)
> > +BTF_ID_FLAGS(func, bpf_modify_return_test2)
> >  BTF_ID_FLAGS(func, bpf_fentry_test1, KF_SLEEPABLE)
> >  BTF_SET8_END(bpf_test_modify_return_ids)
> >
> > @@ -667,7 +675,11 @@ int bpf_prog_test_run_tracing(struct bpf_prog *prog,
> >         case BPF_MODIFY_RETURN:
> >                 ret = bpf_modify_return_test(1, &b);
> >                 if (b != 2)
> > -                       side_effect = 1;
> > +                       side_effect++;
> > +               b = 2;
> > +               ret += bpf_modify_return_test2(1, &b, 3, 4, (void *)5, 6, 7);
> > +               if (b != 2)
> > +                       side_effect++;
>
> Looks better, but now two tests are failing:
> Error: #85 get_func_args_test
> Error: #252 trampoline_count
>
> See BPF CI.
>
> I suspect you haven't rerun the whole test_progs after your changes.
> Please do so in the future.

......Yes, I didn't run the whole tests, and it seems that
some other test cases also use the bpf_modify_return_test().

I'll run the whole test_progs, sorry for the bother......

Thanks!
Menglong Dong



More information about the linux-arm-kernel mailing list