Skip to content

xdpsock: Fix partial batch handling#567

Merged
tohojo merged 2 commits intoxdp-project:mainfrom
legezywzh:xdpsock_fix
Apr 26, 2026
Merged

xdpsock: Fix partial batch handling#567
tohojo merged 2 commits intoxdp-project:mainfrom
legezywzh:xdpsock_fix

Conversation

@legezywzh
Copy link
Copy Markdown

If l2fwd or rx_drop stops partway through a peeked batch, make sure the untouched descriptors are cancelled before we loop around again.

Copy link
Copy Markdown
Member

@tohojo tohojo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@legezywzh
Copy link
Copy Markdown
Author

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).

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.

@tohojo
Copy link
Copy Markdown
Member

tohojo commented Apr 23, 2026 via email

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>
Copy link
Copy Markdown
Member

@tohojo tohojo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thank you! :)

@tohojo tohojo merged commit 6c494c1 into xdp-project:main Apr 26, 2026
129 of 131 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants