xdpsock: Fix partial batch handling#567
Merged
tohojo merged 2 commits intoxdp-project:mainfrom Apr 26, 2026
Merged
Conversation
tohojo
requested changes
Apr 20, 2026
Member
tohojo
left a comment
There was a problem hiding this comment.
OK, so I think you're correct that this is needed, but it's by no means obvious why. So please update the commit message with an explanation of why this change is needed (and by extension, what buggy behaviour it fixes).
Author
OK, sure. This issue was found while testing AF_XDP with the xdp-bench tool. I'll update the commit message to explain why this change is needed and what bug it fixes, and send a revised version soon. |
Member
|
Great, thank you! :)
|
While running xdp-bench with AF_XDP sockets, the benchmark could run for a few seconds and then suddenly stop seeing packets. It turned out that xsk_ring_cons__peek() advances cached_cons immediately. If l2fwd(), rx_drop() or complete_tx_l2fwd() peeks a batch and then cannot reserve enough entries in the TX or FQ ring to process all of it, the remaining descriptors need to be cancelled explicitly. Otherwise the untouched descriptors can get stranded in the RX/CQ rings, so buffers are not recycled and the kernel eventually cannot deliver more packets or completions to the AF_XDP socket. Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If l2fwd or rx_drop stops partway through a peeked batch, make sure the untouched descriptors are cancelled before we loop around again.