mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
selftests/bpf: Fix cold_lru producing zero batch_hash in XDP LB benchmark
batch_hash = (batch_gen ^ cpu_id) * KNUTH_HASH_MULT;
When batch_gen == cpu_id the XOR produces zero, batch_hash is zero,
and *saddr ^= 0 is a no-op. Every iteration hits the warm LRU entry.
During validation batch_gen is 2, so running on CPU 2 triggers:
[udp-v4-lru-miss] COUNTER FAIL: LRU misses=0, expected 1
Replace XOR with addition so the multiplier input is always >= 1.
This also preserves the per-CPU salt for multi-producer runs.
Fixes: 4b4f222910 ("selftests/bpf: Add XDP load-balancer BPF program")
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Link: https://lore.kernel.org/r/20260520133338.3392667-2-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
523d2f42b4
commit
fa747e9f84
|
|
@ -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()) * KNUTH_HASH_MULT;
|
||||
if ((void *)(saddr + 1) <= data_end)
|
||||
*saddr ^= batch_hash;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user