From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380776; b=C3kmOZZp+ATZ+bYEL7l2fb6LzEOPRkNfq5yGU0ZhVE/ifrZFtXvHbR3isRMpxIq0RD9D RtR2fkPBgSWE1lNYR4IoluS6tHP+5KeuMeMdCpg/boAbTLixXB60uB45mLrHUDfIW6u7o fQ4/swyaSt+KpCc21aycbGqKZcIYL9SzC2hUQoLOG65+EeGbgEsYeYgnn/Lgdn3P3XdUl hMOCoPUehL5DsjSoNzr9WIWBGw6SIobhhbxBwnhHCA+/JjDe7i8l3d+ACYZ8jTmdJf3JU O0FRntabXvjXPqXs/ZfWw3DR2cOx3wNJ5lFIQiGDEm9Wy7qLbma+Qn+NjNBtdIjd3IQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380776; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=01GPd3po7dauFBY70VCg6ZoG1f2PpPQfMizTEnfy6zc=; b=sPHf/AG4vx8XxAA7liTGqvlutTaIaL/8v5VpB6m1tHpOeunKtH4v9mLrEiukcCxEa+HH sx/I4R6pbZlisFDmU6OsSeCE73aOPJGfgzjL7MFNVFnrKrdu1WimBP+WjXZnuoiLcSfOQ DYyA1gDMrQegAcuJDKrFQOBt4ByLxrYHCNrn6GVYpcasLySn23ZvqMZs/MhGIh/fj+AxJ bkwD8gq4LFuukJuqoS3/dKyyUYVFKSKiOh8Tv7Gdl6202SlRe6kM+Ro0JVEZfz2vZQpKF /SZJnmDpdvoS3Av5ZCAPQdEGXKdhEEWJCIPnXbtSthbIB/VHf3GkBDKkJ4CNz8plBdw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Oy+ILzf4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDC75606A32D; Fri, 4 Dec 2026 10:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Oy+ILzf4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01B411F000CE; Fri, 4 Dec 2026 10:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796380776; bh=01GPd3po7dauFBY70VCg6ZoG1f2PpPQfMizTEnfy6zc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Oy+ILzf4XJiJcj1m9DFdFGOgA9RBskLZg3p5ogGXD9z3KTPhnQRP0N8hNMTYUwnfj UR0DE4vVWBPncCsCJ0uh3/h6icOUmGxz3fK1CV58Lreefs5sfoblbL1mIQgFrKhjZC 6qD1CBe8R7qx11EAwlinxRVjcZxLbfiOBc/YglO2MbKFMm5fQG02KQrKgrGDRMUgih glCapiw09FF/fSLYzGUk5SsRuCmiT3a+CP3SlseqwTXJgtPAz5nQByLOJX56gPM5nr eNfAVTwTt70WkZJs//kILfiYHeYnga3J/UOochzKY9UiPFA1pEZqnej9VNIYMivtc+ VhGu2ukiHvSOQ== Subject: Re: [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own 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 Date: Fri, 04 Dec 2026 10:39:34 +0000 Message-ID: <179638077454.3146.35797073950689629@kernel.org> In-Reply-To: <20261203095647.3448925-2-bjorn@kernel.org> References: <20261203095647.3448925-2-bjorn@kernel.org> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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