BENCH_BPF_LOOP uses the may_goto instruction (via can_loop) to bound its iteration loop. The kernel enforces a maximum of BPF_MAX_LOOPS (8,388,608) iterations per may_goto instruction. CALIBRATE_MAX_BATCH was set to 10,000,000, exceeding this limit. If calibration computed a batch_iters above 8M, the BPF loop would exit early when can_loop becomes false. The timing sample would cover fewer iterations than batch_iters, causing the per-op calculation to underestimate the true cost. Validation would also fail since map counters would not reach the expected batch_iters + 1. No current benchmark triggers this (the fastest, bpf-nop at ~1.8 ns/op, calibrates to ~5.5M), but future sub-1.25 ns/op benchmarks would. Lower the cap to 8,000,000 to stay within the may_goto limit. Fixes: 08158c111d7d ("selftests/bpf: Add BPF batch-timing library") Signed-off-by: Puranjay Mohan --- tools/testing/selftests/bpf/benchs/bench_bpf_timing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/benchs/bench_bpf_timing.c b/tools/testing/selftests/bpf/benchs/bench_bpf_timing.c index 75a39da69655..081e2e860cb4 100644 --- a/tools/testing/selftests/bpf/benchs/bench_bpf_timing.c +++ b/tools/testing/selftests/bpf/benchs/bench_bpf_timing.c @@ -166,7 +166,7 @@ void bpf_bench_timing_report(struct bpf_bench_timing *t, const char *name, const #define CALIBRATE_SEED_BATCH 100 #define CALIBRATE_MIN_BATCH 100 -#define CALIBRATE_MAX_BATCH 10000000 +#define CALIBRATE_MAX_BATCH 8000000 #define CALIBRATE_TARGET_MS 10 #define CALIBRATE_RUNS 5 #define PROPORTIONALITY_TOL 0.05 /* 5% */ -- 2.53.0-Meta