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=1796483853; b=wTxG4yDQ29EfC8/0XBKdmIpMkGm3GNojiAgpDgq5nR1coQCvce3LRuaJWYG7b1stW4jb KIfRO3OOgCLW7VJA9sKTMYJzQPfahwSpzqzX914HgEom2SCBGK+MCHYGLYE4tcZg1vYcF 35QeO83A4e2j4cQmW2/VYgQioGAxXXfOGWL/2qMgQEu47RkvzI6OK6KmdLdRTmXWEHwgG WR6iq4uH2LTgcK67scyab98081Bz67A2YoquATC8DTGuy6NcQOKBHvkTriRB7R69wPvlU RLyrTdgqIbWGqz5uUfOB4t+UX3ZyoG4EJIybQPqxc9eisZZn4KWOhMz/RKjahIhHxyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796483853; 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=bnE5qquqS7Pv3MDSCJobyu9X9Nhbpq8gJ1eAS7xaSuI=; b=R/mb2/vLZem7/1nKeNDI6jOVIOBQOoAsoSfLQInmkz+cOJr72iBWi3Iflqm3ojdLbfSt xHtsHQBPkCpGxLWVEZigA3qorDZQBK0Ba3fof5nzrgIk3FkIXVmxoYtF4l3qJlSbyeEuV F0NqpRzlW6k3Zff7tM2PeoIrtNAfFJqUbx06RNmcoU6nlcKh84nmd29grIzzGndaiInEe Lm43IINBuKkcFU0lLeNqtTUHoHdCuy8QgCLVtGOkTGCR3QAQEXIaJlanNMq5Vsk7Cz1AT WTq2lOEWDSKRMjgcbrS04va8X+x1RdsycYV5tiADTUaTkpo1eejfpMdiySLPN8uP2Vg== 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=Md+xzacc; 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 D854D606A322; Sat, 5 Dec 2026 15:17:33 +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=Md+xzacc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9999E1F0092B; Sat, 5 Dec 2026 15:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796483853; bh=bnE5qquqS7Pv3MDSCJobyu9X9Nhbpq8gJ1eAS7xaSuI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Md+xzaccqjLZ9Eyk3uRixSyYdCq6+I5IR03CcM66xq5UkwRJF8ZEVDB7qJCUNsAvq Kd9Z4I/KlDZLa+He+d8Oawt4WHp8xh4xGUxmv6FtJcTWh4uDpEwkcafI94l/gEHchq I+5SE70ybeB4B1zzPtWptQuMSJnIv1wf7de8A7Wa5TsNib4Py2+nvBfKpEiTn82u06 8p1AlUK7vLFOi7LIB2wwYVEvHDHFe+00ozJA7/+Ab46w+aloIwf7XjrHIJm5dFugr/ OmUCNsD+vjVV5Lkrcswnow0sd2FIYuWtJHWh6hDAkjiBAGDWOfmhqks1BX3OCv6t8D ILLSHaN+kSV2w== Subject: Re: [PATCH net v4 1/5] libeth: xdp: Count completed XDP_TX buffers up 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 Date: Sat, 05 Dec 2026 15:17:31 +0000 Message-ID: <179648385109.3146.5021762353826565156@kernel.org> In-Reply-To: <20261204142030.626820-2-bjorn@kernel.org> References: <20261204142030.626820-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: 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