On 11/18/26 01:18, Jakub Kicinski wrote:
On Mon, 16 Nov 2026 23:55:42 +0000 Tianyi Gao wrote:
[...]
On the setup we want to build: an XDP program on the NIC does the
decap for all traffic. The services run in namespaces, so the packets
must be delivered into them. Some services attach their own XDP
program to the veth, and some do not. The host does not control the
service's program.

The host doesn't have to control the program, just know whether the
program will be attached, and therefore whether to use TC or XDP.
True, the host can know. But TC does not fit our setup, because it
builds the skb on the isolated RX CPU. The reason why we avoid that is
in [1]. With bpf_redirect_peer() it is even more work: the RX CPU also
runs the whole receive path into the netns, up to the socket.

bpf_redirect_peer() is great in a micro-benchmark, where one CPU does
all the work. In production we handle much more concurrent traffic.
There we split the netstack processing into pipeline stages: XDP on
the RX CPUs, the skb and the netns stack on other CPUs. This scales to
more CPUs.

[...]
In a minimal benchmark, pktgen sends UDP, and perf stat counts the
cycles on the RX CPU. bpf_redirect_peer() from tc costs 3% more
cycles per packet than XDP_REDIRECT with the checksum status kept
(mlx5, one extra __netif_receive_skb_core()). So one XDP_REDIRECT path
for all namespaces is both simpler and cheaper.

That's noise.
Agreed, but the test measured the wrong thing. veth runs its NAPI on
the sending CPU unless NAPI is threaded. So both paths did all the
work on the RX CPU, and the test compared two ways to do the same work
on one CPU.

The number that matters is the cost on the RX CPU, with veth NAPI
threaded on a CPU outside the RX set. I will work with Tianyi on a
better test that shows this.

I answered the rest of your mail in [2].

--Jesper

[1] https://lore.kernel.org/all/[email protected]/ [2] https://lore.kernel.org/all/[email protected]/

Reply via email to