From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEDBE606A32F for ; Sat, 5 Dec 2026 15:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=0RibVzcm; 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: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 93F218121E; Sat, 5 Dec 2026 15:17:38 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5IH3DYN_982b; Sat, 5 Dec 2026 15:17:37 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org 8213881221 Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796483857; b=hjStyRAkaJbLHygXuCBm26tfdQRgtRT37jfHVGZypSURRmJeDUvrdFulN6Tn652dIpuT sXhstqq82FgpWuq+szw9X/ug4xXTgq+grKNjgSd83ULLtpcwnbNmzw7HpzOaY6UzJXSUx NvB/YjJhnfnz3+EmOPi5PWHI3gLBe99CMN7ManOMf/wST3DQKgjelRzxaCt71EGP3scBK HlkHfFDHijjdkDiacr6wYF2l/RJ63FfNLRhm3OJLJX12zpt42RJqqRQshbd+h5NXaM2PK 30Rpj4rcmO5v5hStIBVoT/ch78GdsUE2AsDfNp86VbxLBBclUAsM4jeCkPZUVS5dHXQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796483857; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version:X-BeenThere:X-Mailman-Version: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:Errors-To; bh=bnE5qquqS7Pv3MDSCJobyu9X9Nhbpq8gJ1eAS7xaSuI=; b=fs+yJlzMQuyJ/XDQ9VKZUiypfXU60DhUQrjE2gCsbWQWllSPj4mgV6qCh7T1DSuU3NOp aGjaYBRvwrNzSN8Tlq9vWfMRQxD+tuXb0Lz1NlCPH4D8Y0je1UvfrlhWaETZ3vJidMyF2 gXpvOZ2i0v3XinMZ8goMSNRTID4GRsxtWw3o9sYdpJPj1aGfqiPKMGEqXk31hwUwodX7p xY5wjoVFmBXeXK//R9xe9hmfSemSmR+GQ2SojPHDexDMEcEtUOHXj1WYSJo2qEPYKwz9J LKOsEDxQhVAUmzZom/aLsYEZCyIB41m+ygN8DZ6CTBOdTTxTOA+BCb9ljTmfEvYv4HA== ARC-Authentication-Results: i=1; smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1796483857; bh=bnE5qquqS7Pv3MDSCJobyu9X9Nhbpq8gJ1eAS7xaSuI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=0RibVzcmZJ8X8QOeAzljQjS7w7E7fCPTBDxuJQO+RUuOsznArdlxwxWI/T0QvuCaF R5AnP4VYrMnnwCXMmRbPwW75E6VX1Pkka9U2ecmiWw1BsqzcNRtruaywDlGWg0GoNo kaYjduWtCRSAV92Qi6mcUzy391lhhNND5A2od1mWYw7PCAj4rH0z9P8mmDVQgwkcGx i9NWpkN/48zCwfMEwGKrE2LKtzY1xgcZUGGYYQHc0JFw+p4zPgjv6e+Rcfl4NudYkM r3Oz7fDxPCj9EpmOG1XI+bt6CFzmZbkSQwZxPK94+a3arKJiTEW7rwK6GnCUraRoPW xFeSbK6VZz/nQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 8213881221; Sat, 5 Dec 2026 15:17:37 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists1.osuosl.org (Postfix) with ESMTP id 5F4E0158 for ; Sat, 5 Dec 2026 15:17:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 45382408E3 for ; Sat, 5 Dec 2026 15:17:36 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id kGCensbLW3Tr for ; Sat, 5 Dec 2026 15:17:35 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org F357C40688 Authentication-Results: smtp4.osuosl.org; arc=none smtp.remote-ip=172.105.4.254 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=netdev-bot+sashiko@kernel.org; receiver= Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Md+xzacc Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by smtp4.osuosl.org (Postfix) with ESMTPS id F357C40688 for ; Sat, 5 Dec 2026 15:17:34 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id B4B7A60E3F; Sat, 5 Dec 2026 15:17:33 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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