Article View: linux.kernel.netdev
Article #25691Re: [PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure
From: Simon Schippers
Date: Wed, 02 Dec 2026 09:24
Date: Wed, 02 Dec 2026 09:24
107 lines
13889 bytes
13889 bytes
On 12/2/26 09:15, Jesper Dangaard Brouer wrote:
>
>
> 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.
Thanks!
>
> 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.
Exactly, the sender has to be faster than the NAPI consumer.
The benchmarks in 2/3 show that pretty well: many qdisc requeues mean
that the sender is faster than the consumer. With threaded NAPI,
pktgen and a single TCP sender are fast enough to fill the ring, while
a single UDP sender is too slow. With two senders, TCP fills it with
both softirq and threaded NAPI, and UDP with threaded NAPI.
I just ran a single UDP sender with 8 MB wmem and rmem. The throughput
did not change, so the sender is still slower than the NAPI consumer,
but I am pretty sure the socket limit matters.
Thanks,
Simon
>
> 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
Technical Details
Message-ID:
<3fe11ba8-ad5d-46a0-a0d3-6ec61f090079@tu-dortmund.de>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375671-linux-kernel-netdev=dewy.ruReferences:
<20261125152311.805325-1-simon.schippers@tu-dortmund.de> <c774f09d-9704-4da7-880d-21b6ac3d5983@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375671-linux-kernel-netdev=dewy.ru
From: simon.schippers@tu-dortmund.de (Simon Schippers)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 0/3] veth: earlier txq wake and stop under
backpressure
Date: Wed, 2 Dec 2026 10:24:00 +0100
Organization: Usenet Network
Message-ID: <3fe11ba8-ad5d-46a0-a0d3-6ec61f090079@tu-dortmund.de>
References: <20261125152311.805325-1-simon.schippers@tu-dortmund.de>
<c774f09d-9704-4da7-880d-21b6ac3d5983@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="1934654"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dXFND7rFzUIObGuVUXVLXNzwe2A= sha256:9RtI/o7x7/JQHhhvSqp4DOc772L2Z4Fr34aGLVcn6gk=
sha1:wgXH04KWhaPTQYMHYxnrD4VHnhA= sha256:w1eDVLn0ekWhx/RBQue2iZY2q260D9PWATIhUKgFxKk=
Content-Language: en-US
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 551F3117568; Wed, 2 Dec 2026 12:25:03 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
header.d=tu-dortmund.de
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id jc0fwsTVrcEb;
Wed, 2 Dec 2026 12:24:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375671-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=tu-dortmund.de
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 1725E117590; Wed, 2 Dec 2026 12:24:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 298B532A18; Wed, 2 Dec 2026 09:24:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796203485;
b=SkgXBVxR6Fja5m7ripTsG+JoQ3A1pScNfZ7ufmQ0WzjdlDAeJj7UJzsXdaDKOOpPHI3Z
jL6XhgC3zavXYprRj2nO/STXgBcL5ou8yzW7GSdTd8PHV4QmPXtkCIWdttEzx71+kJdO3
XDtzqNbN0eev1xrYzVAVT++d5s9wUiBAKapAJbGp5kvKcidGozo8fDUcObIRujc0IcjJk
eabm0UQQ8muaoVer7tq5+m28frtMIc9DiaXxVn1x26K0L8jwSX0TC+CGpO/zy49cCvGHC
78Bt74GQreGskFbfpCnSOjpt4Lsi62DEHIlwFRo14O9gPT7VerFPrrBlY/IkM4kXOvw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796203485;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:
Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To:
Content-Type:Content-Transfer-Encoding;
bh=Thbx6ZTNKqPdffVCqCzW5Je4fhf9S5BVhvRQu400q+w=;
b=o3b2wfewVMZ+WMhiHf39bqF5WGzJhmjQJUNEM/EXNm3srUh5wpDgni0jIBTi/HLM39Ax
WVxlxFP8vbI0kVOKKt3gOcPw2GI4FMBYKENJVNIpbGTYs7a91kRY5teWWLzN3YaYKbj0m
5UwcICjbpdJVbfsmVWNDQgsT2cgIa2v6sKSVeHmq9F4fDtL5vJp32x5qJiaosiDGl6UBo
V0BzgCIAbDVhkZ2y5g+2x6bH4+t5X9Xzb/LhBu3EcD8scWav1AeNgtjmgbpC0f6LenMj4
wwp0QFQE5gxtl458CcN+o8NftcPoSHVM4rwnRSUDP3YoU4x8T24ZkrOJZ9+ux7R9X9w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=tu-dortmund.de header.i=@tu-dortmund.de header.a=rsa-sha256 header.s=unimail header.b=FocL7Mbj;
dmarc=pass header.from=tu-dortmund.de;
spf=pass smtp.mailfrom=tu-dortmund.de;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id BA973606A32E;
Wed, 2 Dec 2026 09:24:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key) header.d=tu-dortmund.de header.i=@tu-dortmund.de header.a=rsa-sha256 header.s=unimail header.b=FocL7Mbj
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=129.217.128.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796203474;
b=v1C3acdgynNU8WU7AOKxXKhVND5HDmr7Xxvh/NWili45vEK0jrMysnpHLmMRxExS18kA
tzAvOzP8+hsNasqX2L8mAIlfHRVPPoHHDysyzCs+0MFScGpBel50pDqa3L5eokz9sB3+n
wOIbYojwlxcfR0UYdkKgJ/mhwMtdPJLOLvPEfdupxXtTQI6VMksVbPRWdazyMn0zsyrSI
VBbEjJ1MUncNJ4X0K89LuKefFzd4F3H8hPu4uw3dUYkkvbf/CcWOzCa+a6Cyrf1x0xL1w
/8XtBO+WhVy5TEfSFX4lpRsO6ykpmN9REde3NPuNbUh87Pdf868y5esmB3Mr2pw796w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796203474;
h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Date:MIME-Version:
User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To:
Content-Type:Content-Transfer-Encoding;
bh=Thbx6ZTNKqPdffVCqCzW5Je4fhf9S5BVhvRQu400q+w=;
b=5Vvuqo/5AUQDLbnFJ3vFNieVahHjKrPARBaBEFbfWzVUr6S1YQbfN7khhxuy9Anf2aLt
p4P4L1UrL38eju/lU6y375jFJujqYkc6q/+tEfXepruPA4IagMK68oYCBv/bBYF4eNH1+
GH4trYVYfrGj/+x9USP1WnQmCMSL7ZgyU1JCRvFxC1KYwcFuVDWKTStV+NHYZP2ulhO1j
IKDjSi18w0oDZf2NC2c91NqTp3JwO1e9vjLbPLdobvJrGhvZXKR6SD+y2nBtGNZ2Ek4n7
Uvq6VT89T1xX0A5BJsqj93bo0sddoedWAF7H15s7fspOLjlCyiFfxXBA7HMwNMAEzYw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=tu-dortmund.de;
spf=pass smtp.mailfrom=tu-dortmund.de;
dkim=pass header.d=tu-dortmund.de header.i=@tu-dortmund.de header.a=rsa-sha256 header.s=unimail header.b=FocL7Mbj;
arc=none smtp.remote-ip=129.217.128.51
X-Received: from unimail.uni-dortmund.de (mx1.hrz.uni-dortmund.de [129.217.128.51])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id C79D6606A31A;
Wed, 2 Dec 2026 09:24:32 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C79D6606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tu-dortmund.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tu-dortmund.de
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tu-dortmund.de;
s=unimail; t=1796203442;
bh=Thbx6ZTNKqPdffVCqCzW5Je4fhf9S5BVhvRQu400q+w=;
h=Date:Subject:To:Cc:References:From:In-Reply-To;
b=FocL7Mbj+fghnU7AnYY5qczDEbl7VlyLAz+JARxGHWA8MRQRYPzSvrtrbwfREWueI
iX+Mm5HBKms7Gjl3Nnw2Z32ei6lPBBjdhaGR0eRZf087QXY2KQv7+Il8EDG520Q6GT
q73NxHZMFPUKrVZHSXhxmq5yeN5sEx/kkvrazrHE=
X-Received: from [129.217.186.248] ([129.217.186.248])
(authenticated bits=0)
by unimail.uni-dortmund.de (8.19.0.2/8.19.0.2) with ESMTPSA id 6B29O0Yx008437
(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);
Wed, 2 Dec 2026 10:24:00 +0100 (CET)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-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
X-In-Reply-To: <c774f09d-9704-4da7-880d-21b6ac3d5983@kernel.org>