Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog
From: Andrii Nakryiko
Date: Sun Aug 02 2020 - 21:51:49 EST
On Sat, Aug 1, 2020 at 1:50 AM Song Liu <songliubraving@xxxxxx> wrote:
>
> Add a benchmark to compare performance of
> 1) uprobe;
> 2) user program w/o args;
> 3) user program w/ args;
> 4) user program w/ args on random cpu.
>
Can you please add it to the existing benchmark runner instead, e.g.,
along the other bench_trigger benchmarks? No need to re-implement
benchmark setup. And also that would also allow to compare existing
ways of cheaply triggering a program vs this new _USER program?
If the performance is not significantly better than other ways, do you
think it still makes sense to add a new BPF program type? I think
triggering KPROBE/TRACEPOINT from bpf_prog_test_run() would be very
nice, maybe it's possible to add that instead of a new program type?
Either way, let's see comparison with other program triggering
mechanisms first.
> Sample output:
>
> ./test_progs -t uprobe_vs_user_prog -v
> test_uprobe_vs_user_prog:PASS:uprobe_vs_user_prog__open_and_load 0 nsec
> test_uprobe_vs_user_prog:PASS:get_base_addr 0 nsec
> test_uprobe_vs_user_prog:PASS:attach_uprobe 0 nsec
> run_perf_test:PASS:uprobe 0 nsec
> Each uprobe uses 1419 nanoseconds
> run_perf_test:PASS:user_prog_no_args 0 nsec
> Each user_prog_no_args uses 313 nanoseconds
> run_perf_test:PASS:user_prog_with_args 0 nsec
> Each user_prog_with_args uses 335 nanoseconds
> run_perf_test:PASS:user_prog_with_args_on_cpu 0 nsec
> Each user_prog_with_args_on_cpu uses 2821 nanoseconds
> Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
>
> Signed-off-by: Song Liu <songliubraving@xxxxxx>
> ---
> .../bpf/prog_tests/uprobe_vs_user_prog.c | 101 ++++++++++++++++++
> .../selftests/bpf/progs/uprobe_vs_user_prog.c | 21 ++++
> 2 files changed, 122 insertions(+)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/uprobe_vs_user_prog.c
> create mode 100644 tools/testing/selftests/bpf/progs/uprobe_vs_user_prog.c
>
[...]