From: netdev-bot+sashiko@kernel.org
To: bjorn@kernel.org
Cc: magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
aleksander.lobakin@intel.com, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, willemb@google.com, andrew+netdev@lunn.ch,
anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
netdev@vger.kernel.org, bpf@vger.kernel.org, horms@kernel.org,
sdf@fomichev.me, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com,
ihor.solodrai@linux.dev, intel-wired-lan@lists.osuosl.org,
clecigne@google.com, michal.swiatkowski@linux.intel.com,
sriram.yagnaraman@ericsson.com, kurt@linutronix.de,
michal.kubiak@intel.com
Subject: Re: [PATCH net v4 1/5] libeth: xdp: Count completed XDP_TX buffers up
Date: Sat, 05 Dec 2026 15:17:31 +0000 [thread overview]
Message-ID: <179648385109.3146.5021762353826565156@kernel.org> (raw)
In-Reply-To: <20261204142030.626820-2-bjorn@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 2 (1) · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] On an idpf XDPSQ that has an XSk pool, the frag descriptors of a
non-XSk multi-buffer XDP_TX frame are counted as XSk xmit completions.
- [High] The restored in-flight counter still drifts for non-XSk XDP_TX
frames that are only partly sent.
Pre-existing issues:
- [High] When an idpf XDPSQ is in XSk mode, it can still be cleaned by
the non-XSk routine `idpf_xdpsq_complete()`.
--
libeth: xdp: Count completed XDP_TX buffers up
This patch changes __libeth_xdp_complete_tx() to add the completed
non-XSk-xmit buffers to cp->xdp_tx instead of subtracting them. With
that, idpf's in-flight XDP_TX counter can return to zero. It also updates
the struct libeth_cq_pp kernel-doc to say buffers rather than frames.
> diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
> index 898723ab62e81..38fcd3fdff70e 100644
> --- a/include/net/libeth/xdp.h
> +++ b/include/net/libeth/xdp.h
> @@ -1795,7 +1795,7 @@ __libeth_xdp_complete_tx(struct libeth_sqe *sqe, struct libeth_cq_pp *cp,
> case LIBETH_SQE_XDP_TX:
> case LIBETH_SQE_XDP_XMIT:
> case LIBETH_SQE_XSK_TX:
> - cp->xdp_tx -= sqe->nr_frags;
> + cp->xdp_tx += sqe->nr_frags;
[Severity: High]
The counter is exact now, but can idpf_xsksq_complete_slow() tell non-XSk
XDP_TX frags apart from XSk xmit descriptors?
A regular Rx queue picks its XDPSQ by CPU. __idpf_xdp_rxq_info_init() sets:
rxq->xdpsqs = &vport->txqs[rsrc->xdp_txq_offset];
and __libeth_xdp_tx_init_bulk() then picks xdpsqs[libeth_xdpsq_id(num)].
So XDP_TX from a regular Rx queue whose NAPI runs on CPU k lands on XDPSQ k,
even when that queue is in XSk mode.
For a multi-buffer XDP_TX frame, libeth_xdp_tx_fill_buf() sets a type only
on the head SQE:
if (!sinfo)
return desc;
sqe = &sq->sqes[i];
sqe->type = LIBETH_SQE_XDP_TX;
The non-first frag SQEs stay LIBETH_SQE_EMPTY. In contrast, ndo_xdp_xmit
frags get LIBETH_SQE_XDP_XMIT_FRAG and XSk XDP_TX frags get
LIBETH_SQE_XSK_TX_FRAG.
idpf_xsksq_complete_slow() counts every EMPTY slot as an XSk completion:
if (sqe->type)
libeth_xdp_complete_tx(sqe, &cp);
else
xsk_frames++;
idpf_xsksq_complete() then passes that count to
xsk_tx_completed(xdpsq->pool, xsk_frames).
For a frame with m frags, would the XSk completion ring producer move m
entries past what was reserved? Userspace would then get completions for
XSk xmit descriptors the NIC is still reading. The commit message says this
outcome is removed.
The next patch in the series, "libeth: xsk: Count each XDP_TX buffer on its
own", only changes libeth_xsk_tx_fill_buf() and the XSK_TX completion
accounting. libeth_xdp_tx_fill_buf() is unchanged at the end of the series.
[Severity: High]
Can xdpsq->xdp_tx still drift when a non-XSk XDP_TX frame is only partly
sent?
On the send side, libeth_xdp_tx_xmit_bulk() counts only the descriptors it
actually placed:
*sq.xdp_tx += n;
Here n can stop partway through a multi-buffer frame.
On the completion side, __libeth_xdp_tx_fill_stats() sets the head SQE's
nr_frags to the full frame:
ue->nr_frags += us->nr_frags;
The line above returns that full count. idpf then does
xdpsq->xdp_tx -= cp.xdp_tx.
A frame can be sent short in at least two ways. First,
__libeth_xdp_finalize_rx() flushes with:
flush_bulk(bq, flags | LIBETH_XDP_TX_DROP);
If the XDPSQ fills mid-frame, the head and some frags go out. Then
libeth_xdp_tx_exception()->libeth_xdp_tx_return_bulk() skips the unsent
frags without adjusting any counter:
if (!(frm->len_fl & LIBETH_XDP_TX_FIRST))
continue;
Second, libeth_xdp_tx_queue_bulk() breaks out of its frag loop when
flush_bulk(bq, 0) fails. That leaves a MULTI head in the bulk without its
remaining frags, so it is sent short later.
Each such event leaves the u32 xdpsq->xdp_tx lower by the number of missing
frags. On an XSk XDPSQ, could xdp_tx then read 0 while that many XDP_TX
buffers are still in flight? That would happen long before the 2^31 wrap
described in the commit message.
When that happens, idpf_xsksq_complete() takes the fast path:
if (likely(!xdpsq->xdp_tx)) {
...
xsk_frames = done_frames;
This reports in-flight XDP_TX descriptors through xsk_tx_completed(). It
also skips their SQEs without freeing the page-pool buffers.
Before this patch the fast path never ran after the first XDP_TX, so the
drift had no effect. The next patch in the series switches only
LIBETH_SQE_XSK_TX / LIBETH_SQE_XSK_TX_FRAG to per-buffer counting. The
LIBETH_SQE_XDP_TX case still adds sqe->nr_frags at the end of the series.
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. Can an
XSk-mode idpf XDPSQ be cleaned by idpf_xdpsq_complete() instead of
idpf_xsksq_complete()?
In struct idpf_tx_queue, dev and pool share a union:
union {
struct device *dev;
struct xsk_buff_pool *pool;
};
idpf_xsk_setup_txq() sets txq->pool = pool, so txq->dev then holds the pool
pointer.
idpf_xdp_xmit() passes &vport->txqs[xdp_txq_offset] to
libeth_xdp_xmit_do_bulk(), which picks a queue by CPU without checking XSK.
Regular-Rx XDP_TX goes through idpf_xdp_tx_flush_bulk, which uses the same
prep callback. idpf_xdp_tx_prep() then cleans with the non-XSk routine
whatever the queue mode:
if (free < xdpsq->thresh)
free += idpf_xdpsq_complete(xdpsq, xdpsq->thresh);
idpf_xdpsq_complete() builds:
struct libeth_cq_pp cp = {
.dev = xdpsq->dev,
For completed LIBETH_SQE_XDP_XMIT and LIBETH_SQE_XDP_XMIT_FRAG SQEs,
__libeth_xdp_complete_tx() then calls:
dma_unmap_page(cp->dev, dma_unmap_addr(sqe, dma),
dma_unmap_len(sqe, len), DMA_TO_DEVICE);
Does that hand a struct xsk_buff_pool to the DMA API as a struct device?
The DMA ops, IOMMU and swiotlb lookups would then read fields out of pool
memory.
In the same loop, XSk xmit SQEs are EMPTY. __libeth_xdp_complete_tx()
returns early for them, and next_to_clean moves past them, but
xsk_tx_completed() is never called. Would the completion ring entries
reserved for those frames be lost?
idpf_xsksq_complete() follows the intended rules: it uses
xdpsq->pool->dev and reports EMPTY slots. No patch in this series changes
idpf_xdp_tx_prep(), idpf_xdpsq_complete() or idpf_xdp_xmit().
>
> cp->xss->packets++;
> cp->xss->bytes += sqe->bytes;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204142030.626820-1-bjorn%40kernel.org
next prev parent reply other threads:[~2026-12-05 15:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 14:20 [PATCH net v4 0/5] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 1/5] libeth: xdp: Count completed XDP_TX buffers up Björn Töpel
2026-12-05 14:21 ` sashiko-bot
2026-12-05 15:17 ` netdev-bot+sashiko [this message]
2026-12-04 14:20 ` [PATCH net v4 2/5] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 3/5] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 4/5] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-12-04 14:20 ` [PATCH net v4 5/5] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-05 14:21 ` sashiko-bot
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=179648385109.3146.5021762353826565156@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clecigne@google.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=michal.kubiak@intel.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=sriram.yagnaraman@ericsson.com \
--cc=willemb@google.com \
--cc=yonghong.song@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.