Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: maciej.fijalkowski@intel.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	magnus.karlsson@intel.com, stfomichev@gmail.com,
	pabeni@redhat.com, horms@kernel.org, bjorn@kernel.org,
	kerneljasonxing@gmail.com, kernelxing@tencent.com
Subject: Re: [PATCH v4 net 6/6] selftests/xsk: account reclaimed invalid Tx descriptors
Date: Thu, 23 Jul 2026 09:29:50 -0700	[thread overview]
Message-ID: <20260723162950.747417-1-kuba@kernel.org> (raw)
In-Reply-To: <20260719135609.147823-7-maciej.fijalkowski@intel.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
selftests/xsk: account reclaimed invalid Tx descriptors

This patch updates the AF_XDP selftests to count every Tx descriptor
submitted (including invalid ones) in valid_frags so the completion ring
accounting matches the kernel's new behavior of returning invalid Tx
descriptors through the completion ring. It also adjusts verbatim
fragment counting and adds explicit end fragments after invalid middle
descriptors.

> diff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.c b/tools/testing/selftests/bpf/prog_tests/test_xsk.c
> index de17dd48f176..38ce6060b8fa 100644
> --- a/tools/testing/selftests/bpf/prog_tests/test_xsk.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_xsk.c

[ ... ]

> @@ -665,11 +665,11 @@ static struct pkt_stream *__pkt_stream_generate_custom(struct ifobject *ifobj, s
>  			if (!frame->valid || !pkt_continues(frame->options))
>  				payload++;
>  		} else {
> -			if (frame->valid)
> +			if (frame->valid) {
>  				len += frame->len;
> -			if (frame->valid && pkt_continues(frame->options))
> -				continue;
> -
> +				if (pkt_continues(frame->options))
> +					continue;
> +			}
>  			pkt->pkt_nb = pkt_nb;
>  			pkt->len = len;
>  			pkt->valid = frame->valid;

[Low]
The commit message says "Update custom stream generation so an invalid
middle fragment terminates the generated Rx packet while Tx completion
accounting still covers the complete invalid packet."

Does this hunk actually change any behavior?

Walking through the four (valid, pkt_continues) combinations for the
non-verbatim branch shows the same control flow before and after:

  valid=1, continues=1  -> len += frame->len; continue
  valid=1, continues=0  -> len += frame->len; fall through to finalize
  valid=0, continues=1  -> fall through to finalize
  valid=0, continues=0  -> fall through to finalize

The Rx-packet termination described in the commit message appears to be
driven by the pkts[] additions and by removing the !pkt->valid early
exit in pkt_nb_frags(), not by this hunk. Would it be clearer to describe
this change as a pure refactor of __pkt_stream_generate_custom(), or
drop it from this commit?

[ ... ]

> @@ -2099,13 +2098,16 @@ int testapp_invalid_desc_mb(struct test_spec *test)
>  		{0, 0, 0, false, 0},
>  		/* Invalid address in the second frame */
>  		{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
> -		{umem_sz, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
> +		{umem_sz * 2, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
> +		{0, MIN_PKT_SIZE, 0, false, 0},

[Low]
Would it be worth calling out the umem_sz -> umem_sz * 2 change in the
commit message?

In shared_umem mode the UMEM size is doubled before registration:

  umem_sz *= 2;

so a descriptor address of umem_sz can fall inside the valid UMEM range
for the second socket. Bumping this to umem_sz * 2 ensures the address
is out of range regardless of shared_umem, which is a nice correctness
tweak, but bundling it with the accounting change makes the intent less
obvious and complicates bisection.

>  		/* Invalid len in the middle */
>  		{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
>  		{0, XSK_UMEM__INVALID_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
> +		{0, MIN_PKT_SIZE, 0, false, 0},
>  		/* Invalid options in the middle */
>  		{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
>  		{0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XSK_DESC__INVALID_OPTION},
> +		{0, MIN_PKT_SIZE, 0, false, 0},
>  		/* Transmit 2 frags, receive 3 */
>  		{0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, XDP_PKT_CONTD},
>  		{0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, 0},

[ ... ]

  reply	other threads:[~2026-07-23 16:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-19 13:56 [PATCH v4 net 0/6] xsk: fix AF_XDP multi-buffer Tx descriptor reclaim Maciej Fijalkowski
2026-07-19 13:56 ` [PATCH v4 net 1/6] xsk: fix buffer leak in xsk_drop_skb() for AF_XDP multi-buffer Tx Maciej Fijalkowski
2026-07-19 13:56 ` [PATCH v4 net 2/6] xsk: drain continuation descs after overflow in xsk_build_skb() Maciej Fijalkowski
2026-07-21 18:04   ` Maciej Fijalkowski
2026-07-22  3:09     ` Jason Xing
2026-07-23 16:29   ` Jakub Kicinski
2026-07-19 13:56 ` [PATCH v4 net 3/6] xsk: provide sufficient space in pool->tx_descs Maciej Fijalkowski
2026-07-19 13:56 ` [PATCH v4 net 4/6] xsk: reclaim invalid Tx descriptors in ZC batch path Maciej Fijalkowski
2026-07-23 16:29   ` Jakub Kicinski
2026-07-19 13:56 ` [PATCH v4 net 5/6] selftests/xsk: fix too-many-frags multi-buffer Tx test Maciej Fijalkowski
2026-07-19 13:56 ` [PATCH v4 net 6/6] selftests/xsk: account reclaimed invalid Tx descriptors Maciej Fijalkowski
2026-07-23 16:29   ` Jakub Kicinski [this message]
2026-07-20 19:30 ` [PATCH v4 net 0/6] xsk: fix AF_XDP multi-buffer Tx descriptor reclaim Stanislav Fomichev
2026-07-23 16:31 ` Jakub Kicinski

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=20260723162950.747417-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=horms@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kernelxing@tencent.com \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stfomichev@gmail.com \
    /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