Article View: linux.kernel.netdev
Article #25655Re: [PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure
From: Jesper Dangaard Brouer
Date: Wed, 02 Dec 2026 08:15
Date: Wed, 02 Dec 2026 08:15
87 lines
12441 bytes
12441 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"):
>
> - 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
Technical Details
Message-ID:
<c774f09d-9704-4da7-880d-21b6ac3d5983@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!feed-us-ny.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375623-linux-kernel-netdev=dewy.ruReferences:
<20261125152311.805325-1-simon.schippers@tu-dortmund.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!feed-us-ny.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375623-linux-kernel-netdev=dewy.ru From: hawk@kernel.org (Jesper Dangaard Brouer) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure Date: Wed, 2 Dec 2026 09:15:12 +0100 Organization: Usenet Network Message-ID: <c774f09d-9704-4da7-880d-21b6ac3d5983@kernel.org> References: <20261125152311.805325-1-simon.schippers@tu-dortmund.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1921147"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:hfcUdlQtOLEe/TT8V0B3iXT2qCs= sha256:M8c8CYY1ro+d7ILtiTTkZpCztj0ddBj858wF5PMr7wk= sha1:UKzcsUZ3gwTR2mm6MRRnR7v6Y40= sha256:Nqc45p/tPVquJc8QWAghTADb4bRqA4XCP8VpV95JzPw= 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 D89F811759C; Wed, 2 Dec 2026 11:16:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 M9MXq27A4fSZ; Wed, 2 Dec 2026 11:16:03 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375623-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id D870111758D; Wed, 2 Dec 2026 11:15:54 +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 8C79E2EC0D; Wed, 2 Dec 2026 08:15:25 +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=1796199318; b=OXeNj0y/0Gs/REC6MD+YNshlkWqDlML5rrBdoQLiS0X9ZthAbcv1eMTFhegen6zagnl5 y1j7W4oy+9N1ouE3jwoHy+SJ8ZC8tPrhf/RtLZm807qwNQVH3GS0pO/cEocBr9a2624y3 RS40yNa/Sw5i/O5lHaLwiNr7+vH9LsWo4eMQZGijh7yeDhmND6wNBwifsI5i1wDpyptWv 74FZqkI/jpqDBF8Ntx8/wStkcEw0I/WDy2VX4qOTT9nzeDS6KvPRrl/9jISTPB4Vk9RjC HExi39vXR7pDejIQRi4rj6gs8xDRXtvj2Lfvo9utUBB7yl1WzWY8pDidgsRgNR3tw6g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796199318; h=X-Original-To:Received:Received:DKIM-Signature: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=TyIkgymwlElC/w0nJrUpRNROkpkPpJzZocZd71uTOeM=; b=Uf9mDn/HamxBj4aIz53uSn0ytFuSK2D9QOWu8r6axu2c/gXaf5L6vM2OyRA5oxEHvDYI QAFnGrvE5w8ebb/wZZuW8l77qk16fpxzOon34nD7EHrH2b7pAvgcIANXDodMmwZusLkNC gVGucyxFq8oZM7+wXPkF2TanrvKsgxUV1You/SrrbaXv7EZuyIESBFxOSUwiZPua3SU77 vnzuL189VfsS1BNuTwC+yhV5RVg5kiwWzcJ9tBsdt6O7YMcD8NrRjTvmo/31wMXpSnvLX ilLXgPXzGovyAy1LFl80wfzUqOuqlJddge6J/tSmdkuJmnGbBWxXH88sjfWMM8mjnHw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d5pohuPB; 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 9BD8F606A697; Wed, 2 Dec 2026 08:15:18 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d5pohuPB X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796199317; b=XhM64udOKuaInYyHPySw+ED7doAw9YJKWrFHHwP46yfq0dXTjC1esKxCr0M8uR8ZxCSo H5SMTbGI2EQDzGUwJ5aN1X9OMhJl93yoLZGlDxJI0u8Xd+8LGKaRGZgW5IStc5MzeNaoH rNWn8Ol+kb9WKcunEm4Ua6jPyHn5AU0/wUr3M57a04gwQVCegb7ac2kqSwsMk8qfO1sJO NcxCg2vI2JQTL6vtTG6DjOjfJp/opx2Zul1K/tj9it7PfKTS+IJzKKoQUKzIxT0Xzn9b1 FkxOsnVSxia1VvZOrWK9K2hVNCkgAc9D5uF8PZUYbICjgyxSuv924GcKAr9M1rAGNgA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796199317; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=TyIkgymwlElC/w0nJrUpRNROkpkPpJzZocZd71uTOeM=; b=bJ+Pw9LpG4m/TrWcz3vp52b+iJdmJWj0JRa1vTH8uJOUvfawaxYfKZz7p5XeIOk11Cn9 hos+LpPWVEuJ5u2wjALPwbQCutLp/JmlM32a0MZMVp1XWYH0RptzNxgnGMIPDGNvWyESS ps1zOscjnTZd3akVaDP3E1j0Zd45OHfuEPfhPTxtu5HBTftkQHqi8cTwlyDU9qFyp1EA7 hmlbqfMkD2U5yjq5k/sIAKb+FvHsGZDRoMFtcLi9t1K/YFA59vjCytUoAZWcfa5o5SeL3 f/6qp8YAt934CYSAA/FFpKmiKfORcCxP+8r8jle3WbfYzBkx/kv+j37dQVG7GIHaV7A== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d5pohuPB; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF2D6606A33E; Wed, 2 Dec 2026 08:15:17 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B14A1F0089C; Wed, 2 Dec 2026 08:15:14 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796199317; bh=TyIkgymwlElC/w0nJrUpRNROkpkPpJzZocZd71uTOeM=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=d5pohuPBTHwEFkOgF/VF9KN+aBL5cB50JgV8zSuDayqz7UdB/fLDBn83IDMCeg/SJ 84nQ6fa5377nICVHlZNXxU3eNINpwFSc3jJMHi5H1Z0PUGL4pXgqdxmktCaU1AbpAb XoiJsShnRKde+QzRJ+QRieD1192EgpJzWVKnrBX9bIYrAVboSzhubYEuUv5efQ5qb5 DFM2kj/R8qvNcG+XiFPNxSzk0AKnZ3gGUF/35x2JaFRMdd0DdLE//tPW78BsBlBOLX 6sngIhI39zKIlQCWktNvmKYvvCSJLhgCJaDlbJFNfnKzkBivhbLpFb0f/fKOHVJCOb XxpNi//c+L+Kw== 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: <20261125152311.805325-1-simon.schippers@tu-dortmund.de>