From: "Björn Töpel" <bjorn@kernel.org>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
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>
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 [thread overview]
Message-ID: <87jylro6mn.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <axAoA02RawPI4rRb@boxer>
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
prev parent reply other threads:[~2026-12-02 18:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 12:37 [PATCH net v2 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-11-30 12:37 ` [PATCH net v2 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-11-30 16:41 ` Alexander Lobakin
2026-12-01 12:39 ` netdev-bot+sashiko
2026-12-01 15:57 ` Björn Töpel
2026-11-30 12:37 ` [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-11-30 16:54 ` Alexander Lobakin
2026-12-01 7:12 ` Björn Töpel
2026-12-01 14:08 ` Alexander Lobakin
2026-12-01 12:39 ` netdev-bot+sashiko
2026-12-01 15:58 ` Björn Töpel
2026-11-30 12:37 ` [PATCH net v2 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-11-30 16:56 ` Alexander Lobakin
2026-11-30 12:37 ` [PATCH net v2 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-01 12:39 ` netdev-bot+sashiko
2026-12-01 16:01 ` Björn Töpel
2026-12-02 14:15 ` [PATCH net v2 0/4] " Maciej Fijalkowski
2026-12-02 18:54 ` Björn Töpel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jylro6mn.fsf@all.your.base.are.belong.to.us \
--to=bjorn@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=andrii@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clecigne@google.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=willemb@google.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox