Joanne Koong <joannekoong@xxxxxx> 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).