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
Subject: Re: [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own
Date: Fri, 04 Dec 2026 10:39:34 +0000 [thread overview]
Message-ID: <179638077454.3146.35797073950689629@kernel.org> (raw)
In-Reply-To: <20261203095647.3448925-2-bjorn@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
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 in-flight XDP_TX count uses opposite signs on the two sides,
so this patch does not fix the count it is meant to fix.
- [Low] The commit message names two causes for the wrong XSk XDP_TX in-
flight count: userspace rewriting the shared info in the UMEM, and a…
--
libeth: xsk: Count each XDP_TX buffer on its own
This commit changes libeth so that each XSk XDP_TX SQE counts one
completed buffer and its own byte length. It no longer reads the frame's
shared info at bulk flush time, because that shared info lives in the UMEM
and can change before the flush. The goal is to keep the idpf in-flight
XDP_TX count on XSk queues correct.
> libeth takes the number of buffers of an XSk XDP_TX frame from its
> shared info, and reports that many completed buffers to the driver. It
> reads the shared info when it flushes the bulk, not when it queues the
> frame. The shared info of a zero-copy buffer lives in the UMEM, which
> userspace may write at any time, so a rewritten count makes libeth
> report a wrong number.
[ ... ]
> Make libeth count each buffer on its own SQE. Head and fragments each
> count one completed buffer, and the head counts the packet. Stats stay
> the same for frames sent in full.
>
> Found by an AI agent while reviewing this code. Not triggered at
> runtime.
[Severity: Low]
This isn't a bug, but should the message mention another trigger? It needs
no userspace action and was reachable before this patch: a multi-buffer
XSk XDP_TX frame that is only partly sent when the XDPSQ ring is full.
libeth_xdp_tx_xmit_bulk() limits the send to the free ring space and only
counts what it wrote:
n = min(n, prep(xdpsq, &sq));
...
if (sq.xdp_tx)
*sq.xdp_tx += n;
__libeth_xdp_finalize_rx() then does the final flush with drop set:
if (bq->count)
flush_bulk(bq, flags | LIBETH_XDP_TX_DROP);
libeth_xdp_tx_exception() then drops the unsent tail through
libeth_xsk_tx_return_bulk(). That tail can include trailing frags of a
frame whose head was already sent.
Before this patch, the head SQE's nr_frags covered the whole frame
(1 + sinfo->nr_frags), and frag SQEs counted nothing. So the in-flight
count was off by the number of dropped frags.
The per-SQE counting in this patch also covers that case. The message only
hints at it with "Stats stay the same for frames sent in full". Bytes
reported for a partly sent frame also change, from the full frame size to
the sum of the buffers that were sent.
Could the message describe this path, since normal load can reach it?
> 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 this decrement move the idpf in-flight count the wrong way?
cp.xdp_tx is a u32, and idpf starts it at 0 because its initializer does
not set the field. idpf then expects a positive count of completed
buffers:
drivers/net/ethernet/intel/idpf/xsk.c:idpf_xsksq_complete_slow() {
struct libeth_cq_pp cp = {
.dev = xdpsq->pool->dev,
.bq = &bq,
.xss = &ss,
.napi = true,
};
...
xdpsq->xdp_tx -= cp.xdp_tx;
}
idpf_xdpsq_complete() in idpf/xdp.c works the same way. The kernel-doc
for struct libeth_cq_pp also describes @xdp_tx as "number of XDP-not-XSk
frames processed".
After k XSk XDP_TX completions, cp.xdp_tx is 2^32 - k. The subtraction in
idpf therefore adds k to xdpsq->xdp_tx. The send side in
libeth_xdp_tx_xmit_bulk() also adds to it:
if (sq.xdp_tx)
*sq.xdp_tx += n;
So the count goes up by two for each XDP_TX buffer and does not get back
to 0.
Would that stop idpf_xsksq_complete() from ever taking its fast path
again?
if (likely(!xdpsq->xdp_tx)) {
...
xsk_frames = done_frames;
goto finalize;
}
After about 2^31 XDP_TX buffers the u32 can wrap to exactly 0 while
XDP_TX SQEs are still in flight. In that case, can those SQEs be reported
through xsk_tx_completed() as XSk xmit frames? libeth_xdp_complete_tx()
would never be called for them.
Their UMEM buffers would not be freed. The SQEs would keep
LIBETH_SQE_XSK_TX as their type and a stale xsk pointer. That seems to be
the same "idpf may then complete XDP_TX buffers as XSk xmit frames" result
the commit message says this patch prevents.
The existing cp->xdp_tx -= sqe->nr_frags for LIBETH_SQE_XDP_TX and
LIBETH_SQE_XDP_XMIT uses the same sign, and the new branch copies it.
Should this fix change the sign on one side, either in the libeth
completion code or in the idpf consumers? No later patch in the series
appears to touch include/net/libeth/ or drivers/net/ethernet/intel/idpf/.
> + cp->xss->bytes += sqe->bytes;
> + break;
> default:
> break;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203095647.3448925-1-bjorn%40kernel.org
next prev parent reply other threads:[~2026-12-04 10:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 9:56 [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-12-04 10:39 ` netdev-bot+sashiko [this message]
2026-12-04 14:08 ` Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-12-03 14:04 ` Maciej Fijalkowski
2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-04 14:09 ` Björn Töpel
2026-12-03 9:56 ` [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-12-03 14:07 ` Maciej Fijalkowski
2026-12-04 14:51 ` Loktionov, Aleksandr
2026-12-03 9:56 ` [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 15:16 ` Maciej Fijalkowski
2026-12-04 9:57 ` sashiko-bot
2026-12-04 10:39 ` netdev-bot+sashiko
2026-12-04 14:12 ` Björn Töpel
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=179638077454.3146.35797073950689629@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.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox