diff options
| author | Puranjay Mohan <puranjay@kernel.org> | 2026-05-20 16:33:31 +0300 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-05-20 19:25:46 +0300 |
| commit | 12e896b9794bbd88f56aeac2a5807ae8d4bb5ad8 (patch) | |
| tree | 30660e2a9ab18c9c945fd6e8c598a558df924907 | |
| parent | fa747e9f843ba3a0fa4d3fabaf50c9e11aaf963f (diff) | |
| download | linux-12e896b9794bbd88f56aeac2a5807ae8d4bb5ad8.tar.xz | |
selftests/bpf: Fix expired UDP LRU entries in XDP LB benchmark
populate_lru() zero-initializes atime:
struct real_pos_lru lru = { .pos = real_idx };
connection_table_lookup() treats UDP entries with
cur_time - atime > 30s as expired, so every pre-populated entry
expires immediately. Calibration masks this on the CPU it runs on,
but if validation migrates to another CPU:
[udp-v4-lru-hit] COUNTER FAIL: LRU misses=1, expected 0
Initialize atime from CLOCK_MONOTONIC for UDP flows.
Fixes: a4b5ba8187cb ("selftests/bpf: Add XDP load-balancer benchmark driver")
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Link: https://lore.kernel.org/r/20260520133338.3392667-3-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
| -rw-r--r-- | tools/testing/selftests/bpf/benchs/bench_xdp_lb.c | 11 |
1 files changed, 11 insertions, 0 deletions
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 |
