From: sashiko-bot@kernel.org
To: "Puranjay Mohan" <puranjay@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC PATCH bpf-next 4/6] selftests/bpf: Add XDP load-balancer BPF program
Date: Mon, 20 Apr 2026 13:57:10 +0000 [thread overview]
Message-ID: <20260420135711.22028C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260420111726.2118636-5-puranjay@kernel.org>
Sashiko AI review found 1 potential issue(s):
- [Medium] The `cold_lru` logic toggles the source IP using a constant `batch_hash` inside `BENCH_BPF_LOOP`, failing to simulate a cold LRU cache.
--
commit bb32650934d99141c2338de7bad7c3586c22bdd3
Author: Puranjay Mohan <puranjay@kernel.org>
selftests/bpf: Add XDP load-balancer BPF program
This commit adds the BPF datapath for the XDP load-balancer benchmark,
implementing a simplified L4 load-balancer. It includes L3/L4 parsing,
VIP lookup, and an LRU connection table.
> diff --git a/tools/testing/selftests/bpf/progs/xdp_lb_bench.c b/tools/testing/selftests/bpf/progs/xdp_lb_bench.c
> new file mode 100644
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/xdp_lb_bench.c
[ ... ]
> + if (cold_lru) {
> + __u32 *saddr = data + saddr_off;
> +
> + batch_gen++;
> + batch_hash = (batch_gen ^ bpf_get_smp_processor_id()) *
> + KNUTH_HASH_MULT;
> + if ((void *)(saddr + 1) <= data_end)
> + *saddr ^= batch_hash;
> + }
> +
> + return BENCH_BPF_LOOP(
> + process_packet(xdp),
> + ({
> + if (__bench_result == XDP_TX) {
> + if (strip_encap(xdp, &saved_eth))
> + return XDP_DROP;
> + if (rand_state)
> + randomize_src(xdp, saddr_off,
> + &rand_state);
> + }
> + if (cold_lru) {
> + void *d = (void *)(long)xdp->data;
> + void *de = (void *)(long)xdp->data_end;
> + __u32 *__sa = d + saddr_off;
> +
> + if ((void *)(__sa + 1) <= de)
> + *__sa ^= batch_hash;
Does this code accurately simulate a cold LRU cache?
Inside BENCH_BPF_LOOP, the source IP address is XORed with a constant
batch_hash on every iteration. Since batch_hash does not change within the
loop, the IP address will simply toggle back and forth between two unique
values.
Because the LRU cache is large enough to hold both IPs, this will result
in continuous cache hits after the first two iterations, instead of the
cache misses intended by the cold_lru simulation.
Should a different random or incrementing value be used for each iteration
to ensure a continuous stream of unique addresses?
> + }
> + })
> + );
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260420111726.2118636-1-puranjay@kernel.org?part=4
next prev parent reply other threads:[~2026-04-20 13:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 11:17 [RFC PATCH bpf-next 0/6] selftests/bpf: Add XDP load-balancer benchmark Puranjay Mohan
2026-04-20 11:17 ` [RFC PATCH bpf-next 1/6] selftests/bpf: Add bench_force_done() for early benchmark completion Puranjay Mohan
2026-04-20 12:41 ` sashiko-bot
2026-04-20 15:32 ` Mykyta Yatsenko
2026-04-20 11:17 ` [RFC PATCH bpf-next 2/6] selftests/bpf: Add BPF batch-timing library Puranjay Mohan
2026-04-20 13:18 ` sashiko-bot
2026-04-22 1:10 ` Alexei Starovoitov
2026-04-20 11:17 ` [RFC PATCH bpf-next 3/6] selftests/bpf: Add XDP load-balancer common definitions Puranjay Mohan
2026-04-20 13:26 ` sashiko-bot
2026-04-20 11:17 ` [RFC PATCH bpf-next 4/6] selftests/bpf: Add XDP load-balancer BPF program Puranjay Mohan
2026-04-20 13:57 ` sashiko-bot [this message]
2026-04-20 11:17 ` [RFC PATCH bpf-next 5/6] selftests/bpf: Add XDP load-balancer benchmark driver Puranjay Mohan
2026-04-20 17:11 ` sashiko-bot
2026-04-20 11:17 ` [RFC PATCH bpf-next 6/6] selftests/bpf: Add XDP load-balancer benchmark run script Puranjay Mohan
2026-04-20 17:36 ` sashiko-bot
2026-04-22 1:16 ` [RFC PATCH bpf-next 0/6] selftests/bpf: Add XDP load-balancer benchmark Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260420135711.22028C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=puranjay@kernel.org \
--cc=sashiko@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox