Netdev List
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Magnus Karlsson <magnus.karlsson@intel.com>
Cc: <netdev@vger.kernel.org>, <magnus.karlsson@gmail.com>,
	<sdf@fomichev.me>, <davem@davemloft.net>, <edumazet@kernel.org>,
	<kuba@kernel.org>, <pabeni@redhat.com>, <horms@kernel.org>,
	<bjorn@kernel.org>, <kerneljasonxing@gmail.com>
Subject: Re: [PATCH net] xsk: parse Tx batches in packet units for all shared-UMEM pools
Date: Tue, 24 Nov 2026 16:03:39 +0100	[thread overview]
Message-ID: <awWnS2rr3OT9OZ1L@boxer> (raw)
In-Reply-To: <20261124134808.1103307-1-magnus.karlsson@intel.com>

On Tue, Nov 24, 2026 at 02:48:08PM +0100, Magnus Karlsson wrote:
> Zero-copy drivers that use xsk_tx_peek_release_desc_batch() are meant to
> receive only complete packets of at most xdp_zc_max_segs descriptors.
> Single-socket pools and shared-UMEM pools with XDP_UMEM_SG_FLAG get this
> from xskq_cons_read_desc_batch(), which also drains invalid and
> oversized packets. Shared-UMEM pools without XDP_UMEM_SG_FLAG still use
> xsk_tx_peek_release_fallback(), which peeks one descriptor at a time,
> on the assumption that such pools never carry multi-buffer packets.
> 
> That assumption does not hold. Descriptor validation accepts
> XDP_PKT_CONTD whether or not the UMEM has XDP_UMEM_SG_FLAG, so
> descriptors from such a pool can form multi-buffer packets, as they
> already do on a single-socket pool. The fallback then hands the driver
> a batch that can end in the middle of a packet, packets longer than
> xdp_zc_max_segs, and, as xsk_tx_peek_desc() moves on to another socket
> when the per-socket budget runs out, descriptors of another socket in
> the middle of a packet. On ice, a packet with more than eight data
> descriptors triggers a malicious driver detection event.
> 
> Use xsk_tx_peek_release_shared_desc_batch() for all shared-UMEM pools,
> so that they are parsed like a single non-SG socket, and remove the now
> unused fallback.

Should have done it from day 1 - thanks!

> 
> Implemented a test for this in xskxceiver that opens two sockets in
> shared_umem mode and from one socket sends a packet with too many
> fragments in between two single-fragment packets. Without this patch,
> the NIC resets, but with it the two single-fragment packets are
> received and the test passes.

I don't see it anywhere so this reads a bit weird. I would appreciate the
follow-up with this new test case.

Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

> 
> Fixes: d5581966040f ("xsk: support ZC Tx multi-buffer in batch API")
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>  net/xdp/xsk.c | 17 -----------------
>  1 file changed, 17 deletions(-)
> 
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index ab2e4fa87a4f..7d0701e0e025 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -604,18 +604,6 @@ bool xsk_tx_peek_desc(struct xsk_buff_pool *pool, struct xdp_desc *desc)
>  }
>  EXPORT_SYMBOL(xsk_tx_peek_desc);
>  
> -static u32 xsk_tx_peek_release_fallback(struct xsk_buff_pool *pool, u32 max_entries)
> -{
> -	struct xdp_desc *descs = pool->tx_descs;
> -	u32 nb_pkts = 0;
> -
> -	while (nb_pkts < max_entries && xsk_tx_peek_desc(pool, &descs[nb_pkts]))
> -		nb_pkts++;
> -
> -	xsk_tx_release(pool);
> -	return nb_pkts;
> -}
> -
>  static void xsk_tx_commit_batch(struct xsk_buff_pool *pool,
>  				struct xsk_tx_batch *batch)
>  {
> @@ -763,11 +751,6 @@ u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 nb_pkts)
>  
>  	umem_shared = !list_is_singular(&pool->xsk_tx_list);
>  
> -	if (umem_shared && !(pool->umem->flags & XDP_UMEM_SG_FLAG)) {
> -		rcu_read_unlock();
> -		return xsk_tx_peek_release_fallback(pool, nb_pkts);
> -	}
> -
>  	/* This is the backpressure mechanism for the Tx path. Try to
>  	 * reserve space in the completion queue for all packets, but
>  	 * if there are fewer slots available, just process that many
> -- 
> 2.38.1
> 

      reply	other threads:[~2026-11-24 15:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 13:48 [PATCH net] xsk: parse Tx batches in packet units for all shared-UMEM pools Magnus Karlsson
2026-11-24 15:03 ` Maciej Fijalkowski [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=awWnS2rr3OT9OZ1L@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=bjorn@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=magnus.karlsson@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /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