From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B14A1F0089C; Wed, 2 Dec 2026 08:15:14 +0000 (UTC) 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== Message-ID: Date: Wed, 2 Dec 2026 09:15:12 +0100 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next 0/3] veth: earlier txq wake and stop under backpressure To: Simon Schippers , netdev@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tim Gebauer , =?UTF-8?Q?Jonas_K=C3=B6ppeler?= , "Michael S. Tsirkin" , Jason Wang , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Stanislav Fomichev , bpf@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261125152311.805325-1-simon.schippers@tu-dortmund.de> Content-Language: en-US From: Jesper Dangaard Brouer In-Reply-To: <20261125152311.805325-1-simon.schippers@tu-dortmund.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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