Message ID | 20211118010404.2415864-1-joannekoong@fb.com (mailing list archive) |
---|---|
Headers | show |
Series | Add bpf_for_each helper | expand |
Joanne Koong <joannekoong@fb.com> writes: > This patchset add a new helper, bpf_for_each. > > 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_for_each helper moves the loop logic into the kernel and can thereby > guarantee that the loop will always terminate. The bpf_for_each 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_for_each 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. Small nit with the "by 100%" formulation: when giving such relative quantities 100% has a particular meaning, namely "eliminates entirely". Which this doesn't, obviously, it *almost* eliminates the verification overhead. So I'd change this to 99.5% instead (which is the actual value from your numbers in patch 2).
On 11/18/21 3:14 AM, Toke Høiland-Jørgensen wrote: > Joanne Koong <joannekoong@fb.com> writes: > >> This patchset add a new helper, bpf_for_each. >> >> 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_for_each helper moves the loop logic into the kernel and can thereby >> guarantee that the loop will always terminate. The bpf_for_each 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_for_each 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. > Small nit with the "by 100%" formulation: when giving such relative > quantities 100% has a particular meaning, namely "eliminates entirely". > Which this doesn't, obviously, it *almost* eliminates the verification > overhead. So I'd change this to 99.5% instead (which is the actual value > from your numbers in patch 2). > Great point!! I will change this to "~99%" (and make this change in patch #2's commit message as well). Thanks for reviewing this patchset!