Article View: linux.kernel.netdev
Article #25931Re: [PATCH net v2 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory
From: Björn Töpel
Date: Wed, 02 Dec 2026 18:54
Date: Wed, 02 Dec 2026 18:54
88 lines
12799 bytes
12799 bytes
Maciej Fijalkowski <maciej.fijalkowski@intel.com> writes:
> On Mon, Nov 30, 2026 at 01:37:31PM +0100, Björn Töpel wrote:
>> A packet that AF_XDP receives in zero-copy mode over several buffers
>> keeps its shared info, the fragment list and its count, in the UMEM,
>> which userspace can write while the kernel uses it. A rewritten list
>> or count makes the kernel read and write out of bounds.
>>
>> Patch 4 moves the shared info into the buffer pool and lets the device
>> write up to the end of each chunk. Patch 1 makes libeth count XSk
>> XDP_TX buffers one by one, as it read the shared info at a later bulk
>> flush. Patches 2 and 3 fix skb builders that relied on the old
>> tailroom: the generic one sized the skb head from the frame size, and
>> i40e, igb, igc and ixgbe read past the data.
>
> The pool size doubles, 320 -> 640 bytes on x86_64 (1088 with
> MAX_SKB_FRAGS=45), but fq is ____cacheline_aligned_in_smp, so the data
> path members keep their layout. Nit: sinfo lands under "Members only
> used in the control path first", though ZC multi-buffer Rx writes it
> for every packet.
Ok, I'll spin a v3, that moves it to the data path part of the pool!
>>
>> Sashiko found the shared info issue in its review of the AF_XDP device
>> buffer layout series [1], and the issues fixed by patches 2 and 3 in
>> its review of v1. Clément reported the issue of patch 2 earlier [2].
>> Patch 3 was reproduced on igb in QEMU; the others were not triggered
>> at runtime.
>>
>> I tested this on mlx5 hardware, and on igb, virtio-net and veth in
>> QEMU. None of them receives multi-buffer packets in zero copy or uses
>> the generic skb builder, so i40e, ice, idpf and gve are only
>> build-tested. Intel folks, could you run your multi-buffer zero-copy
>> tests on them?
>>
>> Also for Intel, found while auditing the drivers and not touched here:
>> ice no longer sizes its zero-copy RX buffers from the XSK pool. Commit
>> 3a4f419f7509 ("ice: drop page splitting and recycling") programmed a
>> fixed 3072 bytes, and 93f53db9f9dc ("ice: switch to Page Pool")
>> changed ice_setup_rx_ctx() to use ring->rx_buf_len, which only the
>> page pool path sets. An XSK ring gets the length of its last page pool
>> setup, 3456 bytes on 4K pages, or 0 if it never had one. With 2K
>> chunks the device can write past the chunk into the next one. I found
>> this by reading the code and did not test it.
>
> Thanks for the heads-up, I noticed it too when I ran v1. I'll send an
> ice fix.
TY!
>>
>> Changes in v2:
>> - Patch 1: fix the kernel-doc of struct libeth_sqe (Sashiko)
>> - New patch 2: size zero-copy skbs from the data, and copy the exact
>> length (Sashiko, Clément)
>> - New patch 3: copy the exact length in i40e, igb, igc and ixgbe
>> (Sashiko)
>> - Patch 4: set the flag on every buffer when the pool is created, and
>> again in xp_alloc() and xsk_buff_set_size(), as virtio_net clears
>> the flags of some buffers (Sashiko)
>
> Hmm, a bit of a bummer. Now that I think about it, could we piggyback
> on the rxq mem type being MEM_TYPE_XSK_BUFF_POOL instead? The core
> already relies on it in xdp_convert_buff_to_frame(), xdp_return_buff(),
> xsk_rcv() and bpf_xdp_adjust_tail(), so the flag juggling and
> rxq->ext_sinfo would go away. ice_xmit_xdp_ring() would first have to
> take the shared info from the frame, as the buffer it builds has no
> rxq. Or would this not carry over to your provider work?
It would not. The provider backs regular page pools with UMEM, so its
rxqs are MEM_TYPE_PAGE_POOL like any other page pool queue, and it needs
the flag and ext_sinfo anyway. With the mem type, net would get one
scheme and net-next would add the other.
It would also add a load through xdp->rxq to
xdp_get_shared_info_from_buff() for every driver, and buffers without an
rxq, like the one ice_xmit_xdp_ring() builds, would need driver changes
in a net fix.
The flag stays inside the pool code, which sets it again whenever it
hands out a buffer, so drivers need no change. I'd like to keep it.
pw-bot: cr
Björn
Technical Details
Message-ID:
<87jylro6mn.fsf@all.your.base.are.belong.to.us>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376005-linux-kernel-netdev=dewy.ruReferences:
<20261130123737.125432-1-bjorn@kernel.org> <axAoA02RawPI4rRb@boxer>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376005-linux-kernel-netdev=dewy.ru From: bjorn@kernel.org (Björn Töpel) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Date: Wed, 02 Dec 2026 19:54:40 +0100 Organization: Usenet Network Message-ID: <87jylro6mn.fsf@all.your.base.are.belong.to.us> References: <20261130123737.125432-1-bjorn@kernel.org> <axAoA02RawPI4rRb@boxer> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="2034809"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:NkWFCGDRE8dmhA0z7Gy0yiJrnFI= sha256:SnP3e7GWugPdEnt0kIEn7Fy5598PsJJ/TLChfp0hyGg= sha1:moPJMWsJgFcaE5KCbVmVqtmtJHE= sha256:GiA5PL+iqR0716J6qjCKaKDdPC8mLYFKq8/bw/l8SI8= 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 E7C761176FA; Wed, 2 Dec 2026 21:55:01 +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 0MpSymhygPJj; Wed, 2 Dec 2026 21:54:58 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376005-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 615571176A7; Wed, 2 Dec 2026 21:54:47 +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 E5A0B29819; Wed, 2 Dec 2026 18:54:44 +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=1796237684; b=RkhZR9jsTziy98uzm0axZmcWR9hciEn/j8wgZlINJXxhlX+vemXBZzvmQWKRndu9NfiP wdwxlhorLf2ZsrsKdU5JcK17d+v3jJxGwvIJjheVxqJBf46h4wdlTo8+S4hlmr8l3SaV3 niOkIR/ynEo1o/NTaK5bo+YWHFCbrDLAR6NEzvEpB33H4pXlTgXjkkGd+2cxFKNJcMLUD j8HxQiuFC7PqzcQv3FRwA5MUWNW9ndo5ieqNSBF2zd1ynz8UhyXDci5oh8S9L/CgZlqR7 L7+kD395QNf6Z82DpREM8RcQVXp5FtBZmfCdzJe5XAGeMfEeF63e1e3j834Hkr0mw/A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796237684; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: In-Reply-To:References:Date:Message-ID:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=iYkVNlUi3PA64/Y8a7T7V4vDWwuwWBKvFqoAMgQ1ZKs=; b=4bUmagwVxjlU/aHI9HsMuAavi5PxSEpPQO5T41oZRq7W72tbbbnPZirG9jwhovTrqdMS Q5d9WXQWSO7ZZAICfmgLVA9WSZL49glgLHjx+EfB+l+9cTykx0g8mIplqZXUQ11A6x9w7 OatbA6ioF9Qs2MJGv+oaigCE1rYez8u6VvRFPLMqihKAd247peUFtOFq3LUx8Nb13Bs47 w5u1GZz5LhWgOBG1ERVOpTEgndMZptqEz2DeakB56KgyYSiV2G9SZRy5xmFBPHVJkPGCT 4scxbFO6ZHc4413HQ0Hk3of8m4xiVrKm6llMYxdTu0JekLy/j2fjIFuT6PLpRXyqE6A== 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=jxGM6uOK; 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 861BB606A696; Wed, 2 Dec 2026 18:54:44 +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=jxGM6uOK 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=1796237683; b=YjfZggHZ0HHcNC7T72UIeYMV4Egt8EHWUjlvXERdql6mpXVodXIFUrcTew3jRzKP+kGD Wi6TfVpXKw0y1j9C//DphSRU3Tge6CE20SYRBAlpEast9ap9GsZSFc4HiLKILvruMdEYE ZgKT/qSxmO+Wn6xMqbHti9LQvYhNrkRJupwpjprXQ7iJlO836/OMBSzCdZKEJkxzQjlJD usTdL4Fpo7sUms5qfLcVuZEsnSyolJz5xb3yr/ftUO+jgJZ3xCFmg14Ex47O1ElkPG2KB m9Njs2M4pDGimeZLdlPt7N2xf1sGcOJL/wHFwLPU5GT/3smSNPNMH/L3fSwLLxLloVQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796237683; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=iYkVNlUi3PA64/Y8a7T7V4vDWwuwWBKvFqoAMgQ1ZKs=; b=mcMkiENNHqByR2YkansRsJfhzmBwkOmOq2hPQsBDriMSQDevZ/rh/1WXB+Fa1C/T6dbv 1QyJ5BU2mrdt8CWY8CjWvF5Ih+n/a99g2X0uKyAfQApypSX9I/3mRc/eorcvqRFuMRujy IfhYdXc9UZoWiqtdnDlQpOHo6IG3KyFnON1rrmuADa3ZrDmtD0XkjH0ydZwCHfmB3vIPK 2g/vkHw+FFq9fUw8tyanhRna8J1vzUvQpZYnZ3m/Wzf9JWu0jF2zakBrep3zUVKEDdbmA l/szw5jIpXhTvhqkQTbqCPnwGdrThijKpT7rzmKEkKKetJ/AsBOCsqyE3/xOWmfZnMg== 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=jxGM6uOK; 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 A52E6606A322; Wed, 2 Dec 2026 18:54:43 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B914C1F000C1; Wed, 2 Dec 2026 18:54:42 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796237683; bh=iYkVNlUi3PA64/Y8a7T7V4vDWwuwWBKvFqoAMgQ1ZKs=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=jxGM6uOKa8F4CBKpUHalG0P917zMIzD0nuawbNIBDhaBz62kW9y1AM+avAIjaFZye oLcyryd24gPX9Rkeoqelekr3ybs/5RtsxJ+8pvJhh7wxvr2Fp2RcIGHLcrj6Ue9BDC qSN0MwAVlJUHVOaLOq5CC9gUMXgTGi7Dbrq871xx6V1Y7qeWzDf1XohE9OzxZQZxRS l69sDCMTrvdDbbXp98rtgTr41j76WIb/Fi8Xoa12FeII7/VVIly6LYwhH+UqiSlUY5 nSVHNBsXi7mKrqvocNkKSt1U6j9/KgxOA823V+RzOUYJk5Pb3xcgupZDA6GlIrz+Bw Ymk6YtSRuke4A== X-Cc: Magnus Karlsson <magnus.karlsson@intel.com>, Alexander Lobakin <aleksander.lobakin@intel.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Andrii Nakryiko <andrii@kernel.org>, Eduard Zingerman <eddyz87@gmail.com>, Kumar Kartikeya Dwivedi <memxor@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Willem de Bruijn <willemb@google.com>, netdev@vger.kernel.org, bpf@vger.kernel.org, Simon Horman <horms@kernel.org>, Stanislav Fomichev <sdf@fomichev.me>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, Jiri Olsa <jolsa@kernel.org>, Emil Tsalapatis <emil@etsalapatis.com>, Ihor Solodrai <ihor.solodrai@linux.dev>, Tony Nguyen <anthony.l.nguyen@intel.com>, Przemek Kitszel <przemyslaw.kitszel@intel.com>, intel-wired-lan@lists.osuosl.org, Clément Lecigne <clecigne@google.com> X-In-Reply-To: <axAoA02RawPI4rRb@boxer> 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