From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.229.135 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794437263; b=Duli666pc8B9KZOTOSPW+4E4iwQdnm6L4fgS+lowTWQEVP1WZuhpBfe0SVlzO1M3bz2+ 2iOYzifrxr9oy4YgIQuLzEEw3RWF9TaPEymiBZemkqTga/YBtewtOWUDgEhSqqno2XECo 94ySpuqXeWz7QP4tIEVmA2tfSFIDCpTuzs4JCggFHnisapp48zzhVZpidaast2GIFXoa+ /19PPNRrp840pVzQMqyZ1yaAOMIO5tdQxgEJPxJcPlywd1PzUOeEAJbMjNPX1lsuLz8EV DqsokeBXxUvpiL89dGslmvVk90o7K8hxneHp/ka9YupPEFTHzV/rSs2pLK8sx+RzNQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794437263; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:X-Google-Original-From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=ji3jFp1wSqz7+lu20WnaH3a/SRQ7c4xRIo2XU78doao=; b=wpVEE/HNWd9e7HCW0pt1vGyaRfsVkDHubc6eg4sxSuqIKlhdloZr2DPoXYjairtvghtw kz2Zzmls55Jbc4phb0Gun+woM24cLH0dnpYka9Tb0WjISn/S0HWA5WnxKxjqylCoEOr1C zHyciP7m1CvvzIJ2R8bDfnJsXklYG5EBbwL2spKsyVH0XKUcFqmSF2rHKc5zYPp+0LQr3 932wffHoVOFGmM7Oi+eAf9nR7EEYDdeJQkebzBezfFVRqm069dd/xgbR2TComhgHyKsqQ Q06/Z1V1yzD72D+m/wOI7Teo0FaUEP0ICsKaJdrfbnEpsOebUncwcVVL1p0dSMSzTeQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=w14O00X3; arc=none smtp.remote-ip=74.125.229.135 Received: from mail-dl2-f7.google.com (mail-dl2-f7.google.com [74.125.229.135]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14BED606B744 for ; Wed, 11 Nov 2026 22:47:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 14BED606B744 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=w14O00X3 Received: by mail-dl2-f7.google.com with SMTP id a92af1059eb24-13985f8229aso3322097c88.1 for ; Wed, 11 Nov 2026 14:47:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794437262; x=1795042062; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ji3jFp1wSqz7+lu20WnaH3a/SRQ7c4xRIo2XU78doao=; b=w14O00X3MAea7CRAKjvuLoDbCE5nhypmw9DenJFGrL+8wUnY/NYtrU63h9HS0XRHcB EwOw3hCY4etLiYiVhUKJ9WIUKVDIR3bloDLuqJbxvjr2d/64k4HLYc/Zz4gweeyrDfb9 kfkycIWyUcQANgosZ05YOK1Fnwl7ivM4RouWyaQ0nOL2GAhQBo69JgMjrsDGZG4xZKxW UmJp99zGMV45SyqdjMVi62MuZd+rkc+2xepDb5os70xf0NE/FOVMRhRktFt5lBr1CzTn Y/F3J5e+CmRdY3D4t9+uCjqhAhvLqeV4k87gHxaFPnqJP7MWyHoCBgS6YmUOnWpk4f2K I6lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794437262; x=1795042062; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ji3jFp1wSqz7+lu20WnaH3a/SRQ7c4xRIo2XU78doao=; b=YwPUX+4k5Zr9/QOf6pglaoJCb2wDFc5vfCBYvysZ30/5fLhSkVx9nksC7VRYR2XSWd A05Tl38o7cY0ARNvpOz+cCMFWyEt6VRZLP4/1Yg3TI6hztLeI1oScxRUMrWfP7o+inba wa7kUS4phhZ9CgXCTlRu8p7V4vY3QzMrfYD/5vWI/CcPLzxQxU1pQiKA1Q8cRIMY6HTA PXW9gmc/1LzfU3+UgjGKTBvgD1wUyMBoI5Y3kx4PLf1X7d+1eUX8TEmAd/3I1tsiXzw2 Ndw8ZlN/67tvP9Zjmr5958aMHMbujXt7dJVErG0bxyfx1pWiAy6EIxu2ILEbm/g9gwAy mHNg== X-Forwarded-Encrypted: i=1; AL+hErET/AOhkK7vZrBwA1To4vGl86RU3201D+j6Z6AJd1Jjm+/14StXl7LHG1OUkZk8uzgpBi7zsMtiwCkPWtM=@vger.kernel.org X-Gm-Message-State: APuU4Z8y6Uc0Mt15GYY9PtH+c/cXJURY3/H3hGfbSRKieFUiHsnjvJ29 MyxrtCUEs+QRuSV6hwsWeCAC9HcPNM4hAtGspXUJSTCMuQTyygl/dYHG X-Gm-Gg: AYBFou09XQyRx0okxaBP//oLNRHAK+S+rl8w8XC3fDircmGFexsIMfFi/ebz2pEIixH lo9dz+P+6GpHnKlZ+xnBPK+JBXZK+3/wvi0pneJl4cs+QkwgXnIUvfwH0O7ycc3eyU32n7yx+5s YCeW95be5UuSzc7fgYD7jyx7QjCSC2iWJD0/u/d4B9l3YhQ1htBdIDyAoDJck4cvsECj9/VGQzf EYsrQdmQVJV6/7eM/UDw/dSlg24orxkV1a4PcW+2eTHYvQ4NtNTzaoxnveXxUhlFfTOuPXZuPit 4fWPZASlSqIUAf+2t6M8aoqJ02FosaFsl/KcDb/HHmwoAvY0GSEEDdwvrXEEJf7B4g5OFcGh9Dv hwElvt91wp6kYIQHBXBkW15tYrh4rSSW6UEqMbpZiVnVfAD68o/y67rgirNHlVckbtdBvqEkIZ+ sb/4wDKtVbPnugUN8FH07JytC2X+NRcCWoHd9Ob0U1BherelUWEvD9e7yQxC8YV4TKK3E5qSx09 kl+V52aekTbqi82V5rHwrMrQzNCQWEhnKW3Tis+/diTL0ZS+Zv2ZpQlGB7YV67iBs1uqNRj7wLT 24AWbhGtRoyrC+7S7PBABhM1 X-Received: by 2002:a05:7022:b0c5:b0:1b4:fa58:9d8 with SMTP id a92af1059eb24-1b4fa580c0fmr159091c88.20.1794437261896; Wed, 11 Nov 2026 14:47:41 -0800 (PST) Received: from localhost ([2a03:2880:9ff:6a::]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b3b5b1003fsm17745496c88.6.2026.11.11.14.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2026 14:47:41 -0800 (PST) From: Stanislav Fomichev X-Google-Original-From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch, edumazet@kernel.org, horms@kernel.org, shuah@kernel.org, almasrymina@google.com, sdf@fomichev.me, leitao@debian.org, dtatulea@nvidia.com, asml.silence@gmail.com, bobbyeshleman@meta.com, daniel@iogearbox.net, razor@blackwall.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH net-next v4 0/5] net: devmem: size TX net_iovs from the dmabuf layout Date: Wed, 11 Nov 2026 14:47:35 -0800 Message-ID: <20261111224740.2744522-1-sdf@fomichev.me> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit TX bindings use PAGE_SIZE net_iovs, so a frag covers at most a page. A 64KB skb needs 16 frags, and MAX_SKB_FRAGS caps devmem skbs at about 68KB, which makes BIG TCP ineffective for devmem TX. This series picks the TX net_iov size from the dmabuf sg table instead: the largest power of 2, up to 2MB, which aligns every DMA segment. With a 2MB hugepage-backed udmabuf a BIG TCP skb takes a few frags. There's no UAPI change since TX addresses are dmabuf offsets. This doesn't make skbs larger. TCP still sizes them with size_goal. Only the frags get larger, and a single frag can now cover the whole skb. An skb stays under 64KB unless BIG TCP is enabled. With BIG TCP, MSG_ZEROCOPY from huge pages can already create frags of 64KB or more. So drivers already have to handle them: - mlx5 has a 31-bit length per data segment - gve splits frags into 16KB descriptors - fbnic doesn't enable BIG TCP - bnxt has a 16-bit BD length. It is broken for such page frags today and will be fixed separately. Tested on two mlx5 400Gb/s hosts with kperf (udmabuf, 32KB RX net_iovs, 2MB hugepage-backed TX buffer), series backported to a 7.1 kernel on the sender only. 1 flow, MTU 4200, receiver tcp_rmem capped at 16MB so it doesn't drop, median of 5 x 60s runs: before after frags per skb (sender) 16-17 1-2 throughput (Gb/s) 208.6 211.2 sender sendmsg CPU (sys) 40.8% 19.5% (-52%) The receiver's CPU is the bottleneck, so the gain is CPU, not throughput. More of the transmit runs from the ACK path, so the sender's softirq grows (52% -> 59%), but sys + sirq still drops by 16%. kperf output (sender side) of runs near the median, before: client: == Source client: Tx213.826 Gbps (1603901849600 bytes in 60007723 usec) client: Rx 0.000 Gbps (0 bytes in 60007723 usec) client: TCP retrans reord rtt rttvar d_ce snd_wnd cwnd client: 0 0 633 2 0 15556608 7657 client: net CPU 49: usr: 0.01% sys: 0.10% idle:44.13% iow: 0.00% irq: 3.21% sirq:52.53% client: app CPU 50: usr: 0.05% sys:41.55% idle:53.88% iow: 0.00% irq: 1.40% sirq: 3.10% after: client: == Source client: Tx211.242 Gbps (1584440279040 bytes in 60004741 usec) client: Rx 0.000 Gbps (0 bytes in 60004741 usec) client: TCP retrans reord rtt rttvar d_ce snd_wnd cwnd client: 0 0 556 3 0 15499264 7650 client: net CPU 13: usr: 0.01% sys: 0.08% idle:37.75% iow: 0.00% irq: 3.87% sirq:58.26% client: app CPU 14: usr: 0.06% sys:19.48% idle:77.23% iow: 0.00% irq: 1.19% sirq: 2.02% The bnxt patch was tested on two 50Gb/s bnxt hosts with CONFIG_MAX_SKB_FRAGS=45. With the default of 17 its check compiles out. ncdevmem sending 1KB chunks builds skbs with up to 45 frags. The stack segments them and the data arrives intact. Patches: - 1: bnxt: segment GSO skbs with too many frags in the stack - 2-3: devmem TX prep (truesize, niov_shift in the TX lookup) - 4: pick the TX net_iov size from the sg table - 5: selftest for TX from a hugepage-backed dmabuf v4: - drop the per-device frag size limit and the bnxt, fbnic and mlx5 patches. Drivers already have to handle large page frags (Jakub). v3: https://lore.kernel.org/netdev/20261105222058.944293-1-sdf@fomichev.me/ - default the netmem TX frag size limit to PAGE_SIZE, opt in bnxt, fbnic and mlx5 (Mina) v2: https://lore.kernel.org/netdev/20261103235152.1904727-1-sdf@fomichev.me/ - reword the TX truesize commit message (Mina) - explain why the TX net_iov size ignores the device limit (Mina) - use 1 flow results in the cover letter (Mina) v1: https://lore.kernel.org/netdev/20261102191438.1059771-1-sdf@fomichev.me/ Stanislav Fomichev (5): bnxt_en: let the stack segment GSO skbs with too many frags net: devmem: charge the frag length to TX skb truesize net: devmem: use niov_shift in net_devmem_get_niov_at() net: devmem: size TX net_iovs from the dmabuf sg table selftests: drv-net: devmem: TX from a hugepage-backed dmabuf drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +++ net/core/datagram.c | 2 +- net/core/devmem.c | 36 +++++++++++++--- net/core/netdev-genl.c | 2 +- .../selftests/drivers/net/hw/devmem.py | 10 ++++- .../selftests/drivers/net/hw/devmem_lib.py | 43 +++++++++++++++++-- .../selftests/drivers/net/hw/ncdevmem.c | 8 +++- .../selftests/drivers/net/hw/nk_devmem.py | 11 ++++- 8 files changed, 101 insertions(+), 16 deletions(-) -- 2.53.0-Meta