From: Joanne Koong <joannekoong@fb.com>
To: <bpf@vger.kernel.org>
Cc: <andrii@kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
<Kernel-team@fb.com>
Subject: Re: [PATCH v2 bpf-next 0/4] Add bpf_loop_helper
Date: Tue, 23 Nov 2021 10:47:03 -0800 [thread overview]
Message-ID: <80cd38c9-37b5-6713-c634-15ffa4d88065@fb.com> (raw)
In-Reply-To: <20211123183409.3599979-1-joannekoong@fb.com>
On 11/23/21 10:34 AM, Joanne Koong wrote:
> This patchset add a new helper, bpf_loop.
>
> One of the complexities of using for loops in bpf programs is that the verifier
> needs to ensure that in every possibility of the loop logic, the loop will always
> terminate. As such, there is a limit on how many iterations the loop can do.
>
> The bpf_loop helper moves the loop logic into the kernel and can thereby
> guarantee that the loop will always terminate. The bpf_loop helper simplifies
> a lot of the complexity the verifier needs to check, as well as removes the
> constraint on the number of loops able to be run.
>
> From the test results, we see that using bpf_loop in place
> of the traditional for loop led to a decrease in verification time
> and number of bpf instructions by 100%. The benchmark results show
> that as the number of iterations increases, the overhead per iteration
> decreases.
I will change the wording here to "led to a decrease in verification
time and number
of bpf instructions by approximately ~99%". I changed this in patch 3
but forgot to update
this here as well.
> The high-level overview of the patches -
> Patch 1 - kernel-side + API changes for adding bpf_loop
> Patch 2 - tests
> Patch 3 - use bpf_loop in strobemeta + pyperf600 and measure verifier performance
> Patch 4 - benchmark for throughput + latency of bpf_loop call
>
> v1 -> v2:
> ~ Change helper name to bpf_loop (instead of bpf_for_each)
> ~ Set max nr_loops (~8 million loops) for bpf_loop call
> ~ Split tests + strobemeta/pyperf600 changes into two patches
> ~ Add new ops_report_final helper for outputting throughput and latency
>
>
> Joanne Koong (4):
> bpf: Add bpf_loop helper
> selftests/bpf: Add bpf_loop test
> selftests/bpf: measure bpf_loop verifier performance
> selftest/bpf/benchs: add bpf_loop benchmark
>
> include/linux/bpf.h | 1 +
> include/uapi/linux/bpf.h | 25 ++++
> kernel/bpf/bpf_iter.c | 35 +++++
> kernel/bpf/helpers.c | 2 +
> kernel/bpf/verifier.c | 97 +++++++-----
> tools/include/uapi/linux/bpf.h | 25 ++++
> tools/testing/selftests/bpf/Makefile | 4 +-
> tools/testing/selftests/bpf/bench.c | 26 ++++
> tools/testing/selftests/bpf/bench.h | 1 +
> .../selftests/bpf/benchs/bench_bpf_loop.c | 105 +++++++++++++
> .../bpf/benchs/run_bench_bpf_loop.sh | 15 ++
> .../selftests/bpf/benchs/run_common.sh | 15 ++
> .../selftests/bpf/prog_tests/bpf_loop.c | 138 ++++++++++++++++++
> .../bpf/prog_tests/bpf_verif_scale.c | 12 ++
> tools/testing/selftests/bpf/progs/bpf_loop.c | 99 +++++++++++++
> .../selftests/bpf/progs/bpf_loop_bench.c | 26 ++++
> 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 ++
> 20 files changed, 745 insertions(+), 42 deletions(-)
> create mode 100644 tools/testing/selftests/bpf/benchs/bench_bpf_loop.c
> create mode 100755 tools/testing/selftests/bpf/benchs/run_bench_bpf_loop.sh
> create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_loop.c
> create mode 100644 tools/testing/selftests/bpf/progs/bpf_loop.c
> create mode 100644 tools/testing/selftests/bpf/progs/bpf_loop_bench.c
> create mode 100644 tools/testing/selftests/bpf/progs/pyperf600_bpf_loop.c
> create mode 100644 tools/testing/selftests/bpf/progs/strobemeta_bpf_loop.c
>
prev parent reply other threads:[~2021-11-23 18:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 18:34 [PATCH v2 bpf-next 0/4] Add bpf_loop_helper Joanne Koong
2021-11-23 18:34 ` [PATCH v2 bpf-next 1/4] bpf: Add bpf_loop helper Joanne Koong
2021-11-23 22:46 ` Andrii Nakryiko
2021-11-23 18:34 ` [PATCH v2 bpf-next 2/4] selftests/bpf: Add bpf_loop test Joanne Koong
2021-11-23 18:34 ` [PATCH v2 bpf-next 3/4] selftests/bpf: measure bpf_loop verifier performance Joanne Koong
2021-11-23 18:34 ` [PATCH v2 bpf-next 4/4] selftest/bpf/benchs: add bpf_loop benchmark Joanne Koong
2021-11-23 19:19 ` Toke Høiland-Jørgensen
2021-11-24 0:20 ` Joanne Koong
2021-11-24 12:56 ` Toke Høiland-Jørgensen
2021-11-24 19:26 ` Andrii Nakryiko
2021-11-24 21:59 ` Toke Høiland-Jørgensen
2021-11-25 0:04 ` Joanne Koong
2021-11-25 11:35 ` Toke Høiland-Jørgensen
2021-11-29 19:41 ` Joanne Koong
2021-11-23 18:47 ` Joanne Koong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=80cd38c9-37b5-6713-c634-15ffa4d88065@fb.com \
--to=joannekoong@fb.com \
--cc=Kernel-team@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox