lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADxym3ZgRE-AN0YC50izuO63ipA-bc_Y+JAOMfJq8T3i7mKTzQ@mail.gmail.com>
Date: Thu, 21 Aug 2025 09:40:21 +0800
From: Menglong Dong <menglong8.dong@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org, 
	martin.lau@...ux.dev, eddyz87@...il.com, song@...nel.org, 
	yonghong.song@...ux.dev, john.fastabend@...il.com, kpsingh@...nel.org, 
	sdf@...ichev.me, haoluo@...gle.com, jolsa@...nel.org, mykolal@...com, 
	shuah@...nel.org, davem@...emloft.net, kuba@...nel.org, hawk@...nel.org, 
	nathan@...nel.org, nick.desaulniers+lkml@...il.com, morbo@...gle.com, 
	justinstitt@...gle.com, bpf@...r.kernel.org, linux-kselftest@...r.kernel.org, 
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH bpf-next 3/3] selftests/bpf: add benchmark testing for kprobe-multi-all

On Thu, Aug 21, 2025 at 6:54 AM Andrii Nakryiko
<andrii.nakryiko@...il.com> wrote:
>
> On Mon, Aug 18, 2025 at 8:40 PM Menglong Dong <menglong8.dong@...il.com> 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@...natelecom.cn>
> > ---
> >  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);
> > +       }
> > +}
> > +
>
> [...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ