From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 2D217606A68C for ; Fri, 4 Dec 2026 10:39:44 +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=GM0SZJBE; 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: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id F318740E0E; Fri, 4 Dec 2026 10:39:43 +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 FmE_RhkcUdMu; Fri, 4 Dec 2026 10:39:42 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org 5F4AA40D4E Authentication-Results: smtp4.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=1796380782; b=imfa/1W7qma/1xeWYhqrVMpmSJBYQsRsXlPQUUnTlc4F32N7/91cS4p6u9dFJX1bMhIU 8enfns48iLUNArejlY/77sor7ZzUFMXhFK6UA6W76doHr25b3nXWh63CWAFCTSihhVrCg K3n0tmkluP8N5UeZTb1r16DOMP6bQMLhQfwBh0ahcNYgD1q4uXLSUdSlvh4IBStbgcZLu pkEmGkAujVmZ38nBWnxeS4H/WJthezq5OhKo4LfaVdAl2lzms9ayTjBbHLm8WxKh5DDUR ezS/T4Z2V8qWm97FPLSPi6eW9JoeAXqNUwRb7T7SxZ60RQ+lkLDIvwZK89dYbsUjjLg== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796380782; 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=01GPd3po7dauFBY70VCg6ZoG1f2PpPQfMizTEnfy6zc=; b=Zh2de5Qf34XPoSjvA57eKSHk7ypPGCaFn5+0n1IWjVxpWKvtzKZNSE2dTCoBUof0TdIy 49btbu2G6ST8zyrRqDfirLupS4P3qG5rMXSiVduHXSj02hwTWx/lWnuYfp/qKrrdc89dN ZTcad3vq+KJjSF1zIiCbEgqf8KB6XBKgXOdd9H8HS3vmrqp1k56T+sJZLnGUz+/OdoiMd MMPLF962lT1NwzPjNRAzo6mbtuTSKkYdF5MTbO5tpfiBqNjiVxV9ZUxGYb6yVHsj+m0o6 wizlJxrWzeuvh5v3I9Xqu8V6FYV5bFlLzx3y+Kwz8lV3QXIfg9hMEjSKCBYLPlrBYYQ== ARC-Authentication-Results: i=1; smtp4.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=1796380782; bh=01GPd3po7dauFBY70VCg6ZoG1f2PpPQfMizTEnfy6zc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GM0SZJBEE0/bLWPL2R05GIJBw4ftM43nl6koVOztL+te1OJpfRMnsRZZ+UeL6GMR5 c6/X21yLPlcW1UNKON1BE3fbl5ExatZIho4Jzp7Zo4dpzCUn6uRjI2sMigHym0H50I 22/F3dPAYbyLjOCy7Xg1NncchVgTOBiRY2E01XY/QeWDusCcIKHCZJkDkIpbIQwlLY r7F52cJiHYvl/ib3Q9D3XIqabgvKYIjcwexYtpoeVmI49UTyPR7UsFAORNBw++v1Zs jHuoA6HFnC8r2uQ3azoAgV08bHEWVFNdUurn3QvTdpB/TqstIqVH6iXCMpaHkz8OsH z0UVPC5teIL5g== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 5F4AA40D4E; Fri, 4 Dec 2026 10:39:42 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists1.osuosl.org (Postfix) with ESMTP id 000912FF for ; Fri, 4 Dec 2026 10:39:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E4DDB615F8 for ; Fri, 4 Dec 2026 10:39:39 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id MMyiIoCW6LB2 for ; Fri, 4 Dec 2026 10:39:39 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp3.osuosl.org C5E2A6086C Authentication-Results: smtp3.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: smtp3.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp3.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=Oy+ILzf4 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by smtp3.osuosl.org (Postfix) with ESMTPS id C5E2A6086C for ; Fri, 4 Dec 2026 10:39:38 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id EC65F62D5E; Fri, 4 Dec 2026 10:39:36 +0000 (UTC) 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-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.3 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_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: 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