On Mon, Nov 29, 2021 at 2:39 PM Joanne Koong <joannekoong@xxxxxx> wrote: > > This patch tests bpf_loop in pyperf and strobemeta, and measures the > verifier performance of replacing the traditional for loop > with bpf_loop. > > The results are as follows: > > ~strobemeta~ > > Baseline > verification time 6808200 usec > stack depth 496 > processed 554252 insns (limit 1000000) max_states_per_insn 16 > total_states 15878 peak_states 13489 mark_read 3110 > #192 verif_scale_strobemeta:OK (unrolled loop) > > Using bpf_loop > verification time 31589 usec > stack depth 96+400 > processed 1513 insns (limit 1000000) max_states_per_insn 2 > total_states 106 peak_states 106 mark_read 60 > #193 verif_scale_strobemeta_bpf_loop:OK > > ~pyperf600~ > > Baseline > verification time 29702486 usec > stack depth 368 > processed 626838 insns (limit 1000000) max_states_per_insn 7 > total_states 30368 peak_states 30279 mark_read 748 > #182 verif_scale_pyperf600:OK (unrolled loop) > > Using bpf_loop > verification time 148488 usec > stack depth 320+40 > processed 10518 insns (limit 1000000) max_states_per_insn 10 > total_states 705 peak_states 517 mark_read 38 > #183 verif_scale_pyperf600_bpf_loop:OK > > Using the bpf_loop helper led to approximately a 99% decrease > in the verification time and in the number of instructions. > > Signed-off-by: Joanne Koong <joannekoong@xxxxxx> > --- Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > .../bpf/prog_tests/bpf_verif_scale.c | 12 +++ > tools/testing/selftests/bpf/progs/pyperf.h | 71 +++++++++++++++++- > .../selftests/bpf/progs/pyperf600_bpf_loop.c | 6 ++ > .../testing/selftests/bpf/progs/strobemeta.h | 75 ++++++++++++++++++- > .../selftests/bpf/progs/strobemeta_bpf_loop.c | 9 +++ > 5 files changed, 169 insertions(+), 4 deletions(-) > create mode 100644 tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c > create mode 100644 tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c > [...] > /* Unwind python stack */ > for (int i = 0; i < STACK_MAX_LEN; ++i) { > if (frame_ptr && get_frame_data(frame_ptr, pidData, &frame, &sym)) { > @@ -251,6 +319,7 @@ int __on_event(struct bpf_raw_tracepoint_args *ctx) > frame_ptr = frame.f_back; > } > } > +#endif /* USE_BPF_LOOP */ > event->stack_complete = frame_ptr == NULL; > } else { > event->stack_complete = 1; > diff --git a/tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c b/tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c > new file mode 100644 > index 000000000000..bde8baed4ca6 > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c > @@ -0,0 +1,6 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (c) 2021 Facebook nit: should be /* ... */ > + > +#define STACK_MAX_LEN 600 > +#define USE_BPF_LOOP > +#include "pyperf.h" [...] > diff --git a/tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c b/tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c > new file mode 100644 > index 000000000000..e6f9f920e68a > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c > @@ -0,0 +1,9 @@ > +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) > +// Copyright (c) 2021 Facebook same > + > +#define STROBE_MAX_INTS 2 > +#define STROBE_MAX_STRS 25 > +#define STROBE_MAX_MAPS 100 > +#define STROBE_MAX_MAP_ENTRIES 20 > +#define USE_BPF_LOOP > +#include "strobemeta.h" > -- > 2.30.2 >