From: sashiko-bot@kernel.org
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v4 5/5] selftests/xsk: drain CQ to wait for TX completion
Date: Sat, 30 May 2026 00:44:17 +0000 [thread overview]
Message-ID: <20260530004418.0BF251F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260520004244.55663-6-kerneljasonxing@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The newly added TX drain loop and `outstanding_tx` clamping introduce a race condition that causes premature exit from `wait_for_tx_completion()`, leaving valid packets in the TX ring and causing flaky test timeouts.
--
commit dbc5e902ae609e02c24da36756b02d3a7d8a3445
Author: Jason Xing <kerneljasonxing@gmail.com>
Subject: selftests/xsk: drain CQ to wait for TX completion
This commit addresses an issue where dropped multi-buffer descriptors publish
their addresses to the completion queue via the skb destructor. It modifies
complete_pkts() to clamp outstanding_tx to zero and adds a drain loop in
wait_for_tx_completion().
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.c b/tools/testing/selftests/bpf/prog_tests/test_xsk.c
> --- a/tools/testing/selftests/bpf/prog_tests/test_xsk.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_xsk.c
[ ... ]
> @@ -950,17 +950,11 @@ static int complete_pkts(struct xsk_socket_info *xsk, int batch_size)
>
> rcvd = xsk_ring_cons__peek(&xsk->umem->cq, batch_size, &idx);
> if (rcvd) {
> - if (rcvd > xsk->outstanding_tx) {
[ ... ]
> - return TEST_FAILURE;
> - }
> -
> xsk_ring_cons__release(&xsk->umem->cq, rcvd);
> - xsk->outstanding_tx -= rcvd;
> + if (rcvd > xsk->outstanding_tx)
> + xsk->outstanding_tx = 0;
[Severity: Medium]
Does this clamping of xsk->outstanding_tx to 0 cause the main wait loop in
wait_for_tx_completion() to exit prematurely?
> + else
> + xsk->outstanding_tx -= rcvd;
> }
>
> return TEST_PASS;
[ ... ]
> @@ -1293,6 +1289,17 @@ static int wait_for_tx_completion(struct xsk_socket_info *xsk)
> complete_pkts(xsk, xsk->batch_size);
> }
>
> + do {
> + if (xsk_ring_prod__needs_wakeup(&xsk->tx))
> + kick_tx(xsk);
> + rcvd = xsk_ring_cons__peek(&xsk->umem->cq, xsk->batch_size, &idx);
> + if (rcvd)
> + xsk_ring_cons__release(&xsk->umem->cq, rcvd);
> + } while (rcvd);
[Severity: Medium]
Can this drain loop exit early if the hardware is actively processing packets
but the completion queue is momentarily empty?
If rcvd == 0 is momentarily true, the loop exits. The 100 microsecond sleep
might be insufficient on real hardware, which would leave valid descriptors
stranded in the TX ring because the TX thread exits and stops issuing wakeups.
Would it be safer to increment outstanding_tx by the total number of
descriptors pushed to the TX ring instead of clamping it?
> +
> + usleep(100);
> + complete_pkts(xsk, xsk->batch_size);
> +
> return TEST_PASS;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260520004244.55663-1-kerneljasonxing@gmail.com?part=5
next prev parent reply other threads:[~2026-05-30 0:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 0:42 [PATCH net v4 0/5] xsk: fix meta and publish of cq issues Jason Xing
2026-05-20 0:42 ` [PATCH net v4 1/5] xsk: cache csum_start/csum_offset to fix TOCTOU in xsk_skb_metadata() Jason Xing
2026-05-21 12:04 ` Maciej Fijalkowski
2026-05-30 0:44 ` sashiko-bot
2026-05-20 0:42 ` [PATCH net v4 2/5] xsk: fix buffer leak in xsk_drop_skb() for AF_XDP multi-buffer Tx Jason Xing
2026-05-21 12:05 ` Maciej Fijalkowski
2026-05-20 0:42 ` [PATCH net v4 3/5] xsk: drain continuation descs after overflow in xsk_build_skb() Jason Xing
2026-05-20 16:10 ` Maciej Fijalkowski
2026-05-20 23:53 ` Jason Xing
2026-05-21 12:02 ` Maciej Fijalkowski
2026-05-21 13:10 ` Jason Xing
2026-05-22 9:06 ` Magnus Karlsson
2026-05-22 9:22 ` Jason Xing
2026-05-30 0:44 ` sashiko-bot
2026-05-20 0:42 ` [PATCH net v4 4/5] xsk: drain continuation descs on invalid descriptor in __xsk_generic_xmit() Jason Xing
2026-05-30 0:44 ` sashiko-bot
2026-05-20 0:42 ` [PATCH net v4 5/5] selftests/xsk: drain CQ to wait for TX completion Jason Xing
2026-05-30 0:44 ` sashiko-bot [this message]
2026-05-21 12:23 ` [PATCH net v4 0/5] xsk: fix meta and publish of cq issues Maciej Fijalkowski
2026-05-21 12:41 ` Jason Xing
2026-05-21 12:59 ` Maciej Fijalkowski
2026-05-21 13:07 ` Jason Xing
2026-05-21 14:24 ` Maciej Fijalkowski
2026-05-22 8:55 ` Jason Xing
2026-05-22 13:48 ` Jason Xing
2026-05-22 18:33 ` Maciej Fijalkowski
2026-05-22 23:49 ` Jason Xing
2026-05-26 19:43 ` Maciej Fijalkowski
2026-05-26 23:26 ` Jason Xing
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=20260530004418.0BF251F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=sashiko-reviews@lists.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.