populate_lru() inserts LRU entries with atime zero-initialized: struct real_pos_lru lru = { .pos = real_idx }; The BPF program's connection_table_lookup() enforces a 30-second timeout for UDP flows: if (cur_time - dst_lru->atime > LRU_UDP_TIMEOUT) return NULL; Since cur_time (system uptime) is always much larger than 30 seconds, every pre-populated UDP entry is treated as expired on first access. The lookup returns NULL, counting as an LRU miss. This is masked by calibration: the BPF program runs during calibration on one CPU, misses the expired entry, and re-inserts it with a fresh atime. But if the scheduler moves the thread to a different CPU for validation, that CPU still has the atime=0 entry from populate_lru(), causing intermittent validation failures for UDP LRU-hit scenarios: [udp-v4-lru-hit] COUNTER FAIL: LRU misses=1, expected 0 Fix by initializing atime with the current CLOCK_MONOTONIC time for UDP flows, matching the clock source used by bpf_ktime_get_ns() in the BPF program. Fixes: a4b5ba8187cb ("selftests/bpf: Add XDP load-balancer benchmark driver") Signed-off-by: Puranjay Mohan --- tools/testing/selftests/bpf/benchs/bench_xdp_lb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/testing/selftests/bpf/benchs/bench_xdp_lb.c b/tools/testing/selftests/bpf/benchs/bench_xdp_lb.c index 0b6709a2b03c..8e25bccbde92 100644 --- a/tools/testing/selftests/bpf/benchs/bench_xdp_lb.c +++ b/tools/testing/selftests/bpf/benchs/bench_xdp_lb.c @@ -563,12 +563,23 @@ static void create_per_cpu_lru_maps(struct xdp_lb_bench *skel) nr_inner_maps = nr_cpus; } +static __u64 ktime_get_ns(void) +{ + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC, &ts); + return (__u64)ts.tv_sec * 1000000000ULL + ts.tv_nsec; +} + static void populate_lru(const struct test_scenario *sc, __u32 real_idx) { struct real_pos_lru lru = { .pos = real_idx }; struct flow_key fk; int i, err; + if (sc->ip_proto == IPPROTO_UDP) + lru.atime = ktime_get_ns(); + build_flow_key(&fk, sc); /* Insert into every per-CPU inner LRU so the entry is found -- 2.53.0-Meta