The cold_lru mechanism generates a per-batch hash to XOR into the source address, ensuring each batch tests a fresh (uncached) flow: batch_hash = (batch_gen ^ cpu_id) * KNUTH_HASH_MULT; *saddr ^= batch_hash; When batch_gen equals the CPU ID, the XOR is zero and batch_hash becomes zero. The source address is left unchanged, so every iteration hits the warm LRU entry instead of testing cold lookups. During validation, batch_gen is 2 (one increment from seeding, one from the validation run itself). If the BPF program happens to execute on CPU 2, batch_hash is zero and all LRU lookups hit, producing: [udp-v4-lru-miss] COUNTER FAIL: LRU misses=0, expected 1 Validation FAILED - aborting benchmark This fails roughly 50% of the time depending on scheduler placement. Fix by forcing the multiplier input to be non-zero with | 1. Since KNUTH_HASH_MULT (2654435761) is odd, the product of two odd numbers is always odd, so batch_hash can never be zero. Fixes: 4b4f2229104c ("selftests/bpf: Add XDP load-balancer BPF program") Signed-off-by: Puranjay Mohan --- tools/testing/selftests/bpf/progs/xdp_lb_bench.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/progs/xdp_lb_bench.c b/tools/testing/selftests/bpf/progs/xdp_lb_bench.c index b9fd848c035d..f40e36aa183e 100644 --- a/tools/testing/selftests/bpf/progs/xdp_lb_bench.c +++ b/tools/testing/selftests/bpf/progs/xdp_lb_bench.c @@ -618,7 +618,7 @@ int xdp_lb_bench(struct xdp_md *xdp) __u32 *saddr = data + saddr_off; batch_gen++; - batch_hash = (batch_gen ^ bpf_get_smp_processor_id()) * KNUTH_HASH_MULT; + batch_hash = ((batch_gen ^ bpf_get_smp_processor_id()) | 1) * KNUTH_HASH_MULT; if ((void *)(saddr + 1) <= data_end) *saddr ^= batch_hash; } -- 2.53.0-Meta