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, 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,
anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
intel-wired-lan@lists.osuosl.org, clecigne@google.com
Subject: Re: [PATCH net v2 1/4] libeth: xsk: Count each XDP_TX buffer on its own
Date: Tue, 01 Dec 2026 12:39:13 +0000 [thread overview]
Message-ID: <179612875384.3146.6108168327530476978@kernel.org> (raw)
In-Reply-To: <20261130123737.125432-2-bjorn@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 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] The patch does not repair the idpf in-flight XDP_TX count it
says it fixes.
--
libeth: xsk: Count each XDP_TX buffer on its own
This patch stops libeth from reading the XSk XDP_TX buffer count from
the frame's shared info at flush time. Each XSk XDP_TX SQE, head or
fragment, now counts as one completed buffer and carries its own byte
count. The head SQE also counts the packet.
> diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
> index 898723ab62e81..66a3c4ec9967e 100644
> --- a/include/net/libeth/xdp.h
> +++ b/include/net/libeth/xdp.h
> @@ -1794,12 +1794,19 @@ __libeth_xdp_complete_tx(struct libeth_sqe *sqe, struct libeth_cq_pp *cp,
> switch (type) {
> case LIBETH_SQE_XDP_TX:
> case LIBETH_SQE_XDP_XMIT:
> - case LIBETH_SQE_XSK_TX:
> cp->xdp_tx -= sqe->nr_frags;
>
> cp->xss->packets++;
> cp->xss->bytes += sqe->bytes;
> break;
> + case LIBETH_SQE_XSK_TX:
> + cp->xss->packets++;
> + fallthrough;
> + case LIBETH_SQE_XSK_TX_FRAG:
> + /* One buffer per SQE, see libeth_xsk_tx_fill_buf() */
> + cp->xdp_tx--;
[Severity: High]
Does the sign of this decrement match what idpf expects?
The count is now one per SQE. On the send side, though,
libeth_xdp_tx_xmit_bulk() adds to the same counter:
include/net/libeth/xdp.h:libeth_xdp_tx_xmit_bulk() {
...
if (sq.xdp_tx)
*sq.xdp_tx += n;
...
}
For XSk XDP_TX, idpf_xsk_tx_prep() points sq.xdp_tx at
xdpsq->xdp_tx.
On completion, idpf_xsksq_complete_slow() starts with a zeroed cp. After
k XSk XDP_TX buffers complete, cp.xdp_tx holds (u32)-k. The driver then
does this:
drivers/net/ethernet/intel/idpf/xsk.c:idpf_xsksq_complete_slow() {
...
xdpsq->next_to_clean = ntc;
xdpsq->xdp_tx -= cp.xdp_tx;
...
}
That adds k to xdpsq->xdp_tx instead of subtracting it. Doesn't the
in-flight counter then grow on both send and completion?
The kernel-doc for struct libeth_cq_pp describes xdp_tx as "number of
XDP-not-XSk frames processed", which is a positive count. In idpf/xdp.c,
idpf_xdpsq_complete() uses the same "xdpsq->xdp_tx -= cp.xdp_tx" pattern
with the existing "cp->xdp_tx -= sqe->nr_frags" line. The new XSk case
copies that sign.
idpf_xsksq_complete() uses this counter to choose its fast path:
if (likely(!xdpsq->xdp_tx)) {
tx_ntc += done_frames;
...
xsk_frames = done_frames;
goto finalize;
}
After the first XSk XDP_TX the counter never goes back to zero, so the
slow path is always taken. Each XDP_TX buffer adds 2 to the counter. After
about 2^31 buffers the u32 wraps, and it can read exactly zero while
XDP_TX SQEs are still on the ring.
In that case, would the fast path pass those XDP_TX buffers to
xsk_tx_completed() as xmit completions and never call xsk_buff_free() on
them? Userspace would then see completion ring entries that were never
reserved for xmit, and those UMEM buffers would leak from the pool. That
looks like the same outcome the commit message describes: "idpf may then
complete XDP_TX buffers as XSk xmit frames".
The later patch in this series, "xsk: Keep the shared info of zero-copy
buffers in kernel memory", leaves both cp->xdp_tx-- and
xdpsq->xdp_tx -= cp.xdp_tx unchanged. The mismatch is still present at
the end of the series.
Would it work to have libeth return a positive count (cp->xdp_tx++ and
cp->xdp_tx += sqe->nr_frags)? Changing the idpf consumers to += would
also work.
> + cp->xss->bytes += sqe->bytes;
> + break;
> default:
> break;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130123737.125432-1-bjorn%40kernel.org
next prev parent reply other threads:[~2026-12-01 12:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 12:37 [PATCH net v2 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-11-30 12:37 ` [PATCH net v2 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-11-30 16:41 ` Alexander Lobakin
2026-12-01 12:39 ` netdev-bot+sashiko [this message]
2026-11-30 12:37 ` [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-11-30 16:54 ` Alexander Lobakin
2026-12-01 7:12 ` Björn Töpel
2026-12-01 12:39 ` netdev-bot+sashiko
2026-11-30 12:37 ` [PATCH net v2 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-11-30 16:56 ` Alexander Lobakin
2026-11-30 12:37 ` [PATCH net v2 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-01 12:39 ` netdev-bot+sashiko
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=179612875384.3146.6108168327530476978@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=aleksander.lobakin@intel.com \
--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=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox