Re: [PATCH bpf-next 3/3] selftests/bpf: add benchmark testing for kprobe-multi-all

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 21, 2025 at 6:54 AM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
>
> On Mon, Aug 18, 2025 at 8:40 PM Menglong Dong <menglong8.dong@xxxxxxxxx> wrote:
> >
> > For now, the benchmark for kprobe-multi is single, which means there is
> > only 1 function is hooked during testing. Add the testing
> > "kprobe-multi-all", which will hook all the kernel functions during
> > the benchmark. And the "kretprobe-multi-all" is added too.
> >
> > Signed-off-by: Menglong Dong <dongml2@xxxxxxxxxxxxxxx>
> > ---
> >  tools/testing/selftests/bpf/bench.c           |  4 ++
> >  .../selftests/bpf/benchs/bench_trigger.c      | 54 +++++++++++++++++++
> >  .../selftests/bpf/benchs/run_bench_trigger.sh |  4 +-
> >  .../selftests/bpf/progs/trigger_bench.c       | 12 +++++
> >  tools/testing/selftests/bpf/trace_helpers.c   |  3 ++
> >  5 files changed, 75 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/bench.c b/tools/testing/selftests/bpf/bench.c
> > index ddd73d06a1eb..29dbf937818a 100644
> > --- a/tools/testing/selftests/bpf/bench.c
> > +++ b/tools/testing/selftests/bpf/bench.c
> > @@ -510,6 +510,8 @@ extern const struct bench bench_trig_kretprobe;
> >  extern const struct bench bench_trig_kprobe_multi;
> >  extern const struct bench bench_trig_kretprobe_multi;
> >  extern const struct bench bench_trig_fentry;
> > +extern const struct bench bench_trig_kprobe_multi_all;
> > +extern const struct bench bench_trig_kretprobe_multi_all;
> >  extern const struct bench bench_trig_fexit;
> >  extern const struct bench bench_trig_fmodret;
> >  extern const struct bench bench_trig_tp;
> > @@ -578,6 +580,8 @@ static const struct bench *benchs[] = {
> >         &bench_trig_kprobe_multi,
> >         &bench_trig_kretprobe_multi,
> >         &bench_trig_fentry,
> > +       &bench_trig_kprobe_multi_all,
> > +       &bench_trig_kretprobe_multi_all,
> >         &bench_trig_fexit,
> >         &bench_trig_fmodret,
> >         &bench_trig_tp,
> > diff --git a/tools/testing/selftests/bpf/benchs/bench_trigger.c b/tools/testing/selftests/bpf/benchs/bench_trigger.c
> > index 82327657846e..c6634a64a7c0 100644
> > --- a/tools/testing/selftests/bpf/benchs/bench_trigger.c
> > +++ b/tools/testing/selftests/bpf/benchs/bench_trigger.c
> > @@ -226,6 +226,58 @@ static void trigger_fentry_setup(void)
> >         attach_bpf(ctx.skel->progs.bench_trigger_fentry);
> >  }
> >
> > +static void attach_ksyms_all(struct bpf_program *empty, bool kretprobe)
> > +{
> > +       LIBBPF_OPTS(bpf_kprobe_multi_opts, opts);
> > +       char **syms = NULL;
> > +       size_t cnt = 0;
> > +
> > +       if (bpf_get_ksyms(&syms, &cnt, true)) {
> > +               printf("failed to get ksyms\n");
>
> we seem to be using fprintf(stderr, "...") for emitting errors like
> this (at least in some benchmarks, and it makes sense to me). Do the
> same?

OK!

>
> > +               exit(1);
> > +       }
> > +
> > +       printf("found %zu ksyms\n", cnt);
>
> stray debug output?

OK!

Thanks!
Menglong Dong

>
> > +       opts.syms = (const char **) syms;
> > +       opts.cnt = cnt;
> > +       opts.retprobe = kretprobe;
> > +       /* attach empty to all the kernel functions except bpf_get_numa_node_id. */
> > +       if (!bpf_program__attach_kprobe_multi_opts(empty, NULL, &opts)) {
> > +               printf("failed to attach bpf_program__attach_kprobe_multi_opts to all\n");
> > +               exit(1);
> > +       }
> > +}
> > +
>
> [...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux