Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Simon Schippers
Wed, 25 Nov 2026 15:23
[PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure
Author: Simon Schippers
Date: Wed, 25 Nov 2026 15:23
Date: Wed, 25 Nov 2026 15:23
67 lines
11536 bytes
11536 bytes
While working on the veth BQL series [1], I noticed that veth was
sometimes faster with BQL enabled than without it. Debugging this showed
two reasons, both in how veth handles a full ptr_ring since commit
dc82a33297fc ("veth: apply qdisc backpressure on full ptr_ring to reduce
TX drops"):
- With BQL, the completions inside the NAPI loop wake the txq in the
middle of the poll. Without BQL, veth_poll() wakes the stopped peer
txq only at the end of the poll. The wake raises NET_TX_SOFTIRQ on the
consumer CPU, which then refills the ring from the qdisc itself
instead of consuming. Patch 2 wakes the txq in the middle of the poll,
so that the producer refills the ring on its own CPU. Patch 1 adds
PTR_RING_BATCH, which sets the wake point.
- With BQL, veth_xmit() stops the txq after a successful produce.
Without BQL, it stops the txq only after a produce has failed, so
every refill ends with NETDEV_TX_BUSY and a requeue, which adds up to
many requeues under a flood. Patch 3 stops the txq as soon as the
ring is full, with a __ptr_ring_check_produce() right after the
produce, as in my tun patch [2].
Here are some highlights for the whole series against net-next, with
fq_codel on a veth pair with GRO on and TSO off, so that all traffic
takes the NAPI ptr_ring path, as with an XDP program on the peer. In a
virtme-ng VM on isolated host CPUs at a fixed frequency, 95% confidence
intervals over 50 boots per kernel, 40 boots for two senders:
one sender, threaded NAPI net-next series
pktgen, 64 byte UDP 1078122 pps +24.8 +-0.5%
iperf3 TCP 32682 Mbit/s +1.4 +-0.6%
iperf3 UDP, 64 byte 362 Mbit/s +1.4 +-0.5%
two iperf3 senders, one queue
TCP, softirq NAPI 25798 Mbit/s +51.9 +-0.8%
TCP, threaded NAPI 22480 Mbit/s +15.0 +-1.2%
UDP, threaded NAPI 701 Mbit/s +15.2 +-0.5%
With a single sender and softirq NAPI the consumer runs on the sender's
CPU and the ring does not fill. iperf3 stays within 0.4% there, and
pktgen is 1.8% slower, which I could not separate from a shift of the
code layout, see patch 3. No other regressions were found.
With two senders and softirq NAPI, TCP through fq_codel was 36% slower
than with noqueue. With this series the gap is 2%.
The measurement setup, the test scripts, the isolation of the host CPUs
and the benchmark runs, were done with Claude Code (Claude Opus 5.5).
The scripts are in [3].
[1] https://lore.kernel.org/netdev/20260612083530.1650245-1-hawk@kernel.org/
[2] https://lore.kernel.org/netdev/20260803183641.96882-1-simon.schippers@tu-dortmund.de/
[3] https://github.com/simoschip2000/veth-txq-wake-bench
Simon Schippers (3):
ptr_ring: add PTR_RING_BATCH
veth: wake the peer txq in the middle of the NAPI poll
veth: stop the txq as soon as the ptr_ring is full
drivers/net/veth.c | 52 +++++++++++++++++++++++++++++++++-------
include/linux/ptr_ring.h | 7 +++++-
2 files changed, 50 insertions(+), 9 deletions(-)
base-commit: 612848d37e68b858e15815175f1c5e609e09d719
--
2.43.0
[PATCH net-next 1/3] ptr_ring: add PTR_RING_BATCH
Author: Simon Schippers
Date: Wed, 25 Nov 2026 15:23
Date: Wed, 25 Nov 2026 15:23
38 lines
10027 bytes
10027 bytes
Name the batch size in which the consumer frees entries, so that users
of a ring can size their own work to it. The next patch uses it in veth.
No functional change.
Signed-off-by: Simon Schippers <simon.schippers@tu-dortmund.de>
---
include/linux/ptr_ring.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
index 631c43fde4407..b851a9c170bf6 100644
--- a/include/linux/ptr_ring.h
+++ b/include/linux/ptr_ring.h
@@ -27,6 +27,11 @@
#include <asm/errno.h>
#endif
+/* Consumed entries are freed in batches of this size, unless the ring is
+ * smaller than two batches
+ */
+#define PTR_RING_BATCH (SMP_CACHE_BYTES * 2 / (int)sizeof(void *))
+
struct ptr_ring {
int producer ____cacheline_aligned_in_smp;
spinlock_t producer_lock;
@@ -506,7 +511,7 @@ static inline void **__ptr_ring_init_queue_alloc_noprof(unsigned int size, gfp_t
static inline void __ptr_ring_set_size(struct ptr_ring *r, int size)
{
r->size = size;
- r->batch = SMP_CACHE_BYTES * 2 / sizeof(*(r->queue));
+ r->batch = PTR_RING_BATCH;
/* We need to set batch at least to 1 to make logic
* in __ptr_ring_discard_one work correctly.
* Batching too much (because ring is small) would cause a lot of
--
2.43.0
Re: [PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure
Author: Simon Schippers
Date: Thu, 26 Nov 2026 18:06
Date: Thu, 26 Nov 2026 18:06
12 lines
9358 bytes
9358 bytes
On 11/25/26 16:23, Simon Schippers wrote:
> While working on the veth BQL series [1], I noticed that veth was
> sometimes faster with BQL enabled than without it. Debugging this showed
> two reasons, both in how veth handles a full ptr_ring since commit
> dc82a33297fc ("veth: apply qdisc backpressure on full ptr_ring to reduce
> TX drops"):
I looked at the sashiko review. Both points are right, but they are
low-severity comment nits with no effect on the code, and addressing
them would only lengthen the comments. But I can change them in a v2 if
preferred.
Re: [PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure
Author: patchwork-bot+netdevbpf
Date: Wed, 02 Dec 2026 04:00
Date: Wed, 02 Dec 2026 04:00
35 lines
9519 bytes
9519 bytes
Hello:
This series was applied to netdev/net-next.git (main)
by Willem de Bruijn <willemb@google.com>:
On Wed, 25 Nov 2026 16:23:08 +0100 you wrote:
> While working on the veth BQL series [1], I noticed that veth was
> sometimes faster with BQL enabled than without it. Debugging this showed
> two reasons, both in how veth handles a full ptr_ring since commit
> dc82a33297fc ("veth: apply qdisc backpressure on full ptr_ring to reduce
> TX drops"):
>
> - With BQL, the completions inside the NAPI loop wake the txq in the
> middle of the poll. Without BQL, veth_poll() wakes the stopped peer
> txq only at the end of the poll. The wake raises NET_TX_SOFTIRQ on the
> consumer CPU, which then refills the ring from the qdisc itself
> instead of consuming. Patch 2 wakes the txq in the middle of the poll,
> so that the producer refills the ring on its own CPU. Patch 1 adds
> PTR_RING_BATCH, which sets the wake point.
>
> [...]
Here is the summary with links:
- [net-next,1/3] ptr_ring: add PTR_RING_BATCH
https://git.kernel.org/netdev/net-next/c/48f93560e2f3
- [net-next,2/3] veth: wake the peer txq in the middle of the NAPI poll
https://git.kernel.org/netdev/net-next/c/5c959d1a51fd
- [net-next,3/3] veth: stop the txq as soon as the ptr_ring is full
https://git.kernel.org/netdev/net-next/c/241e0324d7c1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads