Article View: linux.kernel.netdev
Article #23568[PATCH net-next v3 0/3] tun: trim per-packet work on the write path
From: Antonio Quartulli
Date: Fri, 27 Nov 2026 14:14
Date: Fri, 27 Nov 2026 14:14
45 lines
10586 bytes
10586 bytes
Profiling a link-bonding daemon that writes every packet to a tun device showed tun doing per-packet work its packets do not need: - patch 1: a BH-disabled RCU section, only to check for tun's XDP program, which only TAP devices can have - patch 3: the parsing of an all-zero virtio-net header without IFF_VNET_HDR Patch 2 reads tun->flags once in tun_get_user(), so that patch 3 and the existing checks all see the same flags. The other paths read each flag only once and are left as they are. Together they cut the instructions per 1400-byte UDP packet written to a TUN device by 3.3% when an iptables raw-table rule drops it on ingress, and by 1.9% when it is forwarded to a dummy device. Counted under qemu -icount on x86_64, with ERMS/FSRM hidden so that user copies are not counted per byte; the counts include the syscall, so tun's own share of the saving is larger. The tun selftests pass. v3: - Add patch 2, reading tun->flags once in tun_get_user(), and base the vnet header check on it (Willem) v2: https://lore.kernel.org/netdev/20261124235959.1141963-1-antonio@mandelbit.com/ - Drop the patch that stopped probing the transport header: tc ematches and generic XDP rely on it (Sashiko) - Rename the XDP check variable, which shadowed another one (Sashiko) - Patch 2: adapt to the has_eth argument tun_vnet_hdr_tnl_to_skb() gained in 73e08d50eb13 v1: https://lore.kernel.org/netdev/20261112150612.3866546-1-antonio@mandelbit.com/ Antonio Quartulli (3): tun: don't disable BHs for the XDP program check of every packet tun: read tun->flags once in tun_get_user() tun: skip the virtio-net header parsing without IFF_VNET_HDR drivers/net/tun.c | 54 +++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 21 deletions(-) base-commit: f89726ffabef1b08c52e6163b7ab94b0d5f15503 -- 2.56.1
Technical Details
Message-ID:
<20261127141406.651406-1-antonio@mandelbit.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372762-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372762-linux-kernel-netdev=dewy.ru From: antonio@mandelbit.com (Antonio Quartulli) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v3 0/3] tun: trim per-packet work on the write path Date: Fri, 27 Nov 2026 15:14:02 +0100 Organization: Usenet Network Message-ID: <20261127141406.651406-1-antonio@mandelbit.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="747055"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:eB7MSN/yMghu4YRSK9+gf/qMjZc= sha256:a0Jcgc/GG+Of5nqEClIrhBcMcPYBsHZxf4P3Lc6osTc= sha1:KThOGmpanpIgXqFDyoP8ofPreGc= sha256:LttGUA/ejgo/YjWs8DOT+lvhhsG+FWxM3TvqFwXSIlw= 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 2B48B125F61; Fri, 27 Nov 2026 17:14:36 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.151 X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31 tests=[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] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=mandelbit.com 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 6b7p1c8ffL89; Fri, 27 Nov 2026 17:14:31 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-372762-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mandelbit.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 5A457125F5B; Fri, 27 Nov 2026 17:14:19 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id B9541603211; Fri, 27 Nov 2026 14:14:18 +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=1795788856; b=LEHlDGI2H7Ib3bG9XKPr0xOKTEOfQwlxkWfRuDUF6aybzFy8XwoBeAyOEqRXo59YF42i +S3wr/FrVOG+qeyQ36TgvJiu66oB3/7IigSYGv/N1f8Vw/MFm4af5gb4Io9AMTUiVuCrm 5Di/ufmRIiw5w0ArVHORmi1ZhUMk9gnqbmuuTHIRZx4NDL4Sm7djHdsIXI6OOo4fL1t7x CPzLobszx7sjZ8KJDMU06FQyPQXvlMxZWr9w+xi2NlkR2P7ULczMVS5VgkS5RZhw/sNCo ryy6N/0Jtn4Jsq50h3j/72pIIKZjTFMif5ajJWcFsFZ/i6Y3QKnuJMdEEUFRKe9/lNg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795788856; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=Rsmts2EOzDPxmWrjfgARbxt81aNFkdaXSifeh0H+Uew=; b=CPBvC+xF6Q3sUHMyWsKqlSPIUFLgLOh1wYfvTHwikOAcFY40Y4LKOG3u31Zbil5Ej7gs Im2IknpIKeou9WC4ZXLWa1Cwi0flu6FJTVvbTqoXbjMQF8ZR/wGFebfyA0akoxu2mFRCk yazULpM2CO7A1FgabyKLviH5OwgeON1W3BJ9VC5hG/kNPtWtr0piIF+XYzSiFgKVlTENb SL5EtDhtrHKjfwTNEiA6gg8qzw5+0oH5hBQDMRR9wVxuMgBFbhoiNk+XgeYddI774qfyb 16jAQm1Aoq/H+hFNKwpM/d/EN5TFlTw1AUO0OH7Yc1UOvZM+EunzuJC5SWepLk/3RxA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=ZLOqBDrF; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; 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 2CB80606A332; Fri, 27 Nov 2026 14:14:16 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=ZLOqBDrF X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.62 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795788855; b=11YpTSsnwEizG8d5nVVpRVjHdSplvEIrK3ajST21vtwuq7Qp7IMHw5OGtHRyuIaWaYlM 7W7tDPHLdaSi3MdCaLLoaIqbM9B3n7/fvarM1KRrw135EfMv/c/hIF04Fdn4vw8E5S2gu aQAL+5ZuzCUueQQt9JpY9H73cm7zlczrmPMg5H0x2Aa9mxPDj/5ZCSg6Rz3bWJrzbcCG5 oYUWijyOHSUC9mf5u9nbdiB8L1QYgQJ/s1+j7ghn8GyK/fS6KAhgPz9+giEyToPOIfOpP me7HyXjQyaP5DjplGLtJrMbnbkssRuplgCtODSgWr/XUt7BpMMba8U+9IgvQaPietLQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795788855; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-Rspamd-Queue-Id; bh=Rsmts2EOzDPxmWrjfgARbxt81aNFkdaXSifeh0H+Uew=; b=bcZ6GhsWU8DE6+yG9+spWFqSDAzNA+YDwWdRUEnKAkR+eHLLeNEkHnB0V8/M4HTL5mv8 0AEIIiGcnqJJE2jXjsYp8djk0G5HSqnoUPQibns2jKWFEpmN8SH5f+QhHuCl5zXw+EZmT hFZrIAkjbMy8QaPd9FAAVCdr6YLxlzLC+kpa9zJ71z2m7Ni4JjorDM9EAYALks7teUzRV V0h4WF/i0mQDsDCSCif0gY6q2ATUsoS2AbDeTW9mseuwSn7K1q/vMQ8S6ONnEKlcjbRKh lKiTCIP+CKOu0HyVZXHjsbddgO33PvYsFL2a8/5tQbDHekRLt8mAir0884zYoEJFxqQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=ZLOqBDrF; arc=none smtp.remote-ip=195.10.208.62 X-Received: from mout-b-202.mailbox.org (mout-b-202.mailbox.org [195.10.208.62]) (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 856C7606A31C; Fri, 27 Nov 2026 14:14:14 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 856C7606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com X-Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-202.mailbox.org (Postfix) with ESMTPS id 4jbb4y3BkQzKm3t; Fri, 27 Nov 2026 15:14:10 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1795788850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Rsmts2EOzDPxmWrjfgARbxt81aNFkdaXSifeh0H+Uew=; b=ZLOqBDrFq1+3MTlewRBAHX3k9p4L/oiUOtXAI5Wjz2Qhn/G8Hhgp5o27tm+Xj2I2N1CHo4 jGbCQV7hoMhT8zNLJwBr7MeXukBq9uXoi47Q0mZO57n2QKgORYTP8+BcBEAtlng+But54O ltm0XVookLBSytpNF8WoVW2mFOqSjNSKGTzPXXlCdF9BKaCNGPta3wBl9PKfcdVM8lzTVp cynVxnpSYRaNpH8psLqXDHgGQpFP/PCr+4EjzE4DrZHv3ExpryEPKOMoTXbkwWdA29oubf fPiaH2P36WREc8m4QkCphfWRqzBBkNENGfh6z223av/mV3XHm+oC05hYmoF9Zg== X-Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of antonio@mandelbit.com designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=antonio@mandelbit.com X-Cc: Antonio Quartulli <antonio@mandelbit.com>, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, netdev@vger.kernel.org, bpf@vger.kernel.org X-Mailer: git-send-email 2.56.1 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-Rspamd-Queue-Id: 4jbb4y3BkQzKm3t