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=1796128756; b=nnqaIptSnaolQ2eLZ2cRgh1E4KdZelZoXS60bTYsfzuPbxiDhhcKxauKDc2j3Wxbigdv HyqY+5cxemZWvlDUtiaYxYd7VLqpirlj9BLI/svfzxNuP5fg50pQibOGNgS/cgJAFoQUY ZqA+Jnjv2smuHCGaAClvMe0bsfD3fhJaVuOZHA9fBCMgZQOybl8p3E5xDXygMOACQeAnX OrcVkRxZW/E0X6TaE/pdTH5jixuWShcsl2T2mWHIYz2yxfzBw6SH3tujkReF4cvqbjQch B4oTPkINEcOmJKSwaHYLRmDIPK0+dCyUIYbo4IGrVXYP1D5mCC1NwyzceisFdaKlasQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128756; 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=K6zl8YKeskOlOtznJtW97ZpUSZeVZqxKltRE18zDrXc=; b=LHhu9fHiHh84jaP9eJoH9Y4K5VfIQQY1Sn6o1VDNDa0TqMm4FPKgg9F48AO8mTyidmJm qJq42UOQfnFLY9wnUQXi2CaNk2k+44zd7PVfHH/Fj0bVw/Ua3IgGbnhOxeEWulswC5RlZ +/ZLoz4YhtGwkLzez4XYuzEQVcMggVonG+43r5M2w7rRXjqO4Erp3IjJWCwODC3K3s1v1 wKM+DKcWRgkd5YFJA5PxBtYMqfvvMSOfdFF+I5PBh9AX1HsdetaubHuS/V/itaHWJKNm6 5kOrcmaIIDA/ERo9KchO3yoYAvaXO5XGSOC+rtqTyAUE+3EN+NX6QBJNRCaENZ5R/xQ== 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=XhJim6GY; 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 92FF2606A31A; Tue, 1 Dec 2026 12:39:16 +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=XhJim6GY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AA0C1F0089B; Tue, 1 Dec 2026 12:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796128755; bh=K6zl8YKeskOlOtznJtW97ZpUSZeVZqxKltRE18zDrXc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=XhJim6GYWCzByF3IsupA0ZfQZ8HJXrQSgxWVfYYELi5mCA+J5BXsQAm/Uu5lzR4GL 91OEbwdIPWnRkOX2wIhPWwXohGsBe+qIIxuggJsrB5rasCDgr3pKJ83CN5im3MsSfk D3il7lT28+qBAxqmS972drJjmKLRgqX2C+Om6F0d4IZvw6uzh4bEelfbggef2J1R/h duvqM4kOJJJpOVCsh+l72D7U9fJ2I883syYnlcI3saFduujNnICjgFuXgvVWAcRLIx M1jR1a3rYhKfPoHpQJSZEXPM9uzysgg7V9qqrqTZuV5e7JuSZOi02klKc9YdjyVUt5 8DAVBLpMV07hg== Subject: Re: [PATCH net v2 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, 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, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, intel-wired-lan@lists.osuosl.org, clecigne@google.com Date: Tue, 01 Dec 2026 12:39:13 +0000 Message-ID: <179612875384.3146.6108168327530476978@kernel.org> In-Reply-To: <20261130123737.125432-2-bjorn@kernel.org> References: <20261130123737.125432-2-bjorn@kernel.org> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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 1 potential issue(s) to consider. Critical: 0 · High: 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] The patch does not repair the idpf in-flight XDP_TX count it says it fixes. -- libeth: xsk: Count each XDP_TX buffer on its own This patch stops libeth from reading the XSk XDP_TX buffer count from the frame's shared info at flush time. Each XSk XDP_TX SQE, head or fragment, now counts as one completed buffer and carries its own byte count. The head SQE also counts the packet. > 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 the sign of this decrement match what idpf expects? The count is now one per SQE. On the send side, though, libeth_xdp_tx_xmit_bulk() adds to the same counter: include/net/libeth/xdp.h:libeth_xdp_tx_xmit_bulk() { ... if (sq.xdp_tx) *sq.xdp_tx += n; ... } For XSk XDP_TX, idpf_xsk_tx_prep() points sq.xdp_tx at xdpsq->xdp_tx. On completion, idpf_xsksq_complete_slow() starts with a zeroed cp. After k XSk XDP_TX buffers complete, cp.xdp_tx holds (u32)-k. The driver then does this: drivers/net/ethernet/intel/idpf/xsk.c:idpf_xsksq_complete_slow() { ... xdpsq->next_to_clean = ntc; xdpsq->xdp_tx -= cp.xdp_tx; ... } That adds k to xdpsq->xdp_tx instead of subtracting it. Doesn't the in-flight counter then grow on both send and completion? The kernel-doc for struct libeth_cq_pp describes xdp_tx as "number of XDP-not-XSk frames processed", which is a positive count. In idpf/xdp.c, idpf_xdpsq_complete() uses the same "xdpsq->xdp_tx -= cp.xdp_tx" pattern with the existing "cp->xdp_tx -= sqe->nr_frags" line. The new XSk case copies that sign. idpf_xsksq_complete() uses this counter to choose its fast path: if (likely(!xdpsq->xdp_tx)) { tx_ntc += done_frames; ... xsk_frames = done_frames; goto finalize; } After the first XSk XDP_TX the counter never goes back to zero, so the slow path is always taken. Each XDP_TX buffer adds 2 to the counter. After about 2^31 buffers the u32 wraps, and it can read exactly zero while XDP_TX SQEs are still on the ring. In that case, would the fast path pass those XDP_TX buffers to xsk_tx_completed() as xmit completions and never call xsk_buff_free() on them? Userspace would then see completion ring entries that were never reserved for xmit, and those UMEM buffers would leak from the pool. That looks like the same outcome the commit message describes: "idpf may then complete XDP_TX buffers as XSk xmit frames". The later patch in this series, "xsk: Keep the shared info of zero-copy buffers in kernel memory", leaves both cp->xdp_tx-- and xdpsq->xdp_tx -= cp.xdp_tx unchanged. The mismatch is still present at the end of the series. Would it work to have libeth return a positive count (cp->xdp_tx++ and cp->xdp_tx += sqe->nr_frags)? Changing the idpf consumers to += would also work. > + cp->xss->bytes += sqe->bytes; > + break; > default: > break; > } [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130123737.125432-1-bjorn%40kernel.org