mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <hawk@kernel.org>
To: Simon Schippers <simon.schippers@tu-dortmund.de>, netdev@vger.kernel.org
Cc: "Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Tim Gebauer" <tim.gebauer@tu-dortmund.de>,
	"Jonas Köppeler" <j.koeppeler@tu-berlin.de>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowangio@gmail.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure
Date: Wed, 2 Dec 2026 09:15:12 +0100	[thread overview]
Message-ID: <c774f09d-9704-4da7-880d-21b6ac3d5983@kernel.org> (raw)
In-Reply-To: <20261125152311.805325-1-simon.schippers@tu-dortmund.de>



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"):
> 
> - 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.
>

Nice results, and a careful test setup.

A note for others who test veth with a local sender. In my own veth
tests, the socket send limit can be the bottleneck, before the
ptr_ring or the qdisc. The test then measures the socket limit, not
the veth backpressure. So if you want to test the qdisc or the
ptr_ring, first make sure that one of them is the bottleneck.

veth does not orphan the skb. A local skb is charged to the sending
socket (skb->truesize in sk_wmem_alloc). Its destructor releases the
charge: sock_wfree() for UDP, tcp_wfree() for TCP. This happens only
when the skb is freed, or orphaned in ip_rcv_core() on the peer. So
every skb in the qdisc and in the ptr_ring counts against the sender's
socket.

The limits are:
  - UDP: SO_SNDBUF, default net.core.wmem_default, max net.core.wmem_max
  - TCP: net.ipv4.tcp_wmem, and TCP Small Queues via
    net.ipv4.tcp_limit_output_bytes

The default wmem_default is 212992 bytes, defined as
256 * SKB_TRUESIZE(256). Each skb counts with its truesize, not its
packet length. Even a 64-byte UDP packet uses at least
SKB_TRUESIZE(256), so at most about 256 skbs fit. Larger packets fit
fewer. That is the size of the 256-entry ptr_ring alone, before the
qdisc holds anything. pktgen skbs have no socket, so pktgen is not
affected.

--Jesper

> 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

  parent reply	other threads:[~2026-12-02  8:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 15:23 Simon Schippers
2026-11-25 15:23 ` [PATCH net-next 1/3] ptr_ring: add PTR_RING_BATCH Simon Schippers
2026-11-27 18:58   ` Michael S. Tsirkin
2026-11-25 15:23 ` [PATCH net-next 2/3] veth: wake the peer txq in the middle of the NAPI poll Simon Schippers
2026-11-25 15:23 ` [PATCH net-next 3/3] veth: stop the txq as soon as the ptr_ring is full Simon Schippers
2026-11-26 18:06 ` [PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure Simon Schippers
2026-12-02  4:00 ` patchwork-bot+netdevbpf
2026-12-02  8:15 ` Jesper Dangaard Brouer [this message]
2026-12-02  9:24   ` Simon Schippers

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=c774f09d-9704-4da7-880d-21b6ac3d5983@kernel.org \
    --to=hawk@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=j.koeppeler@tu-berlin.de \
    --cc=jasowangio@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=simon.schippers@tu-dortmund.de \
    --cc=tim.gebauer@tu-dortmund.de \
    /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

all inboxes | Powered by JetHome®