🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27031

[PATCH net-next v2 12/15] net/mlx5e: Release XDP-only pages earlier

#27031
From: Björn Töpel
Date: Fri, 04 Dec 2026 16:27
89 lines
11958 bytes
Before this patch, a striding RQ released pages only when reposting
their WQE, so a provider page returned its chunk late, on an extra
empty descriptor. The chunks come back without this patch; it only
saves that descriptor.

On the linear path, release a provider page once XDP took the buffer
in its last stride, and let the WQE skip it, also at close. The chunk
then comes back on the packet's descriptor, as the socket drops its
references last. The device writes nothing to a page after its last
stride, so this cannot race with DMA.

Also skip the head and xdp_frame prefetches of XDP-only pages. Only
the program reads them, and after the early release each packet lands
in an untouched page, where a prefetch may cost a page walk.

On ConnectX-7, one core, 66-byte frames offered at 61 Mpps, a program
that parses headers and an application that reads the payload, this
and the batched reference drops took a 4 KiB-chunk queue from
12.40-12.66 to 15.65-15.92 Mpps.

Signed-off-by: Björn Töpel <bjorn@kernel.org>
---

Notes (v2changes):
    Changes in v2:
    - New in v2, from "eth: mlx5e: Let go of XDP-only pages after their
      last stride" and "eth: mlx5e: Skip head prefetches for XDP-only
      buffers" of the v1 full series. A striding RQ let go of a page only
      when it reposted its WQE, so its chunk came back on an extra empty
      descriptor, and the head prefetch of a page that the CPU had not
      touched cost a page walk. The message has the numbers.

 .../net/ethernet/mellanox/mlx5/core/en_rx.c   | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 43a382fcd3ad..a93eefa581c0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -2107,6 +2107,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
 	void *va, *data;
 	dma_addr_t addr;
 	u32 frag_size;
+	bool xdp_only;
 
 	/* Check packet size. Note LRO doesn't use linear SKB */
 	if (unlikely(cqe_bcnt > rq->hw_mtu)) {
@@ -2121,18 +2122,36 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
 	addr = page_pool_get_dma_addr_netmem(frag_page->netmem);
 	dma_sync_single_range_for_cpu(rq->pdev, addr, head_offset,
 				      frag_size, rq->buff.map_dir);
-	net_prefetch(data);
+	/* The kernel reads an XDP-only head only if the program does, and a
+	 * prefetch may cost a page walk
+	 */
+	xdp_only = netmem_is_net_iov(frag_page->netmem);
+	if (!xdp_only)
+		net_prefetch(data);
 
 	prog = rcu_dereference(rq->xdp_prog);
 	if (prog) {
 		struct mlx5e_xdp_buff *mxbuf = &rq->mxbuf;
 
-		net_prefetchw(va); /* xdp_frame data area */
+		if (!xdp_only)
+			net_prefetchw(va); /* xdp_frame data area */
 		mlx5e_fill_mxbuf(rq, cqe, va, rx_headroom, rq->buff.frame0_sz,
 				 cqe_bcnt, mxbuf);
 		if (mlx5e_xdp_handle(rq, prog, mxbuf)) {
 			if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags))
 				frag_page->frags++;
+			/* The device is done with a provider page after its
+			 * last stride. Letting go of it now, before the socket
+			 * drops its references, gives the chunk back on the
+			 * packet's descriptor rather than an empty one.
+			 */
+			if (xdp_only &&
+			    head_offset + BIT(rq->mpwqe.log_stride_sz) >=
+			    BIT(rq->mpwqe.page_shift)) {
+				mlx5e_page_release_fragmented(rq->page_pool,
+							      frag_page);
+				__set_bit(page_idx, wi->skip_release_bitmap);
+			}
 			return NULL; /* page/packet was consumed by XDP */
 		}
 
-- 
2.56.1
Technical Details
Message-ID: <20261204162723.755897-13-bjorn@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377494-linux-kernel-netdev=dewy.ru
References: <20261204162723.755897-1-bjorn@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377494-linux-kernel-netdev=dewy.ru
From: bjorn@kernel.org (Björn Töpel)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 12/15] net/mlx5e: Release XDP-only pages earlier
Date: Fri,  4 Dec 2026 17:27:17 +0100
Organization: Usenet Network
Message-ID: <20261204162723.755897-13-bjorn@kernel.org>
References: <20261204162723.755897-1-bjorn@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2807119"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ew/519mmIwLs+3Wp+gStmOPoGu8= sha256:AVbQs3ylAuJAFBDvoV205omreAgBwMRiK7lCfJYlEtI=
	sha1:tQxsOUWDo8Tdo+MLnJ5nC+lKKiA= sha256:4h8+CyLdChe0g1tJgnv0gHnjwyT6u4PJoaok9L8WBl0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CF53B117C6E; Fri,  4 Dec 2026 19:30:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.542
X-Spam-Status: No, score=-3.542 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id pJdxRJAaZgZw;
	Fri,  4 Dec 2026 19:30:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377494-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 6B0BA117C5C; Fri,  4 Dec 2026 19:30:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 0204AA3C8D; Fri,  4 Dec 2026 16:29:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796401768;
	b=E84bdb9bDHCnL8gQJJpgKwDG0+eppefI+Gsszlr3GhYlc+IjK2i1dgW3uQeJ4+2LvGOM
	 Nuuv5NriHlyzG6c8MNOzwZGF3H8GJh0anpDuJsHYQk/yMJvNYRpgXcuoTwaKQPjrhA7Zh
	 29XibeLtPFN7wSe90PCfj9vGMxmQhs3tQQIvnW1aS7x1RIIq+DchvPEeejyFSmeoP9ICs
	 CIeXOWx3Uh3qc0vuq3C19czQRSni62grW0fKkMCqB8XYglcFkj9EQ/q3ikIZA3GMNfvYD
	 GhJgQxxsttZSixBe576N+DFFARWg6717WwxWgv+M7XstWKjHRmkNsLF7j+clJ52xw/Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796401768;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=iG9kiobqq6148Oudx1rHuHsAEjQ47lWHibQd84biVh0=;
	b=rp2qJK9cCA5g14zfaIWtXAFLyFAlmLqTbO/XqFn9VhcY7MD4+H6uiusGS3qkY4P2TXeC
	 nXfs0+uZJmC0yXmCmuUprjntiuyROfLb5ke+jrTUal6TrAF2jPqFKxZmjZtRM86y1TWLy
	 fJZBqwl0Op2gKcOKsEWkFHgk9GJ+//Mej/Z9I3zThI2N8ZpBJ+n9YbtuRxmTp0z49b8Ul
	 9ceB2km+rDAlMAKuQ7LA6YvaqL5FyaBYURxnKV4LK+6Zn+BMjtA5B5NCy5mncUIW5VJPb
	 b0mpF9Wved/05++vp/FYy8wxI9iE0xYcvjBfjfetkPJ64oCDxHTmcof5rNNECfnKycg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="PSBgC/C7";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id B8E41606A684;
	Fri,  4 Dec 2026 16:29:28 +0000 (UTC)
X-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=PSBgC/C7
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796401767;
	b=mVFxm4avBkMNqiS3kTn69QaZFsXal84okNrsqgZQwFWXTuSATRujTRkEwkv1g8UbUHRp
	 vpOq76tsrBGi74rNHunuZmz0aM+QFiRT59Ghf/ruAFYkif9REo9VuKuKOuCVpZ3pcaytt
	 nm7JBeNZUcfqKjQ6d6k0Oio/UMII6n3yYlhWErVkmUQaOHbMgxCNerW5eLc/6kqF19RKn
	 AIu/JdU9sFRKujabfxUKlokUzU0uuZtjmnBiXa/RX32iC3WImkFb1Dd246qUwOUEYyWje
	 ORFvgg0GFQDtD1GBC8nwUAkNhjW0iQyT7CtDep8GRwwEzzzS8e0OqiFhys40se8IYuw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796401767;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=iG9kiobqq6148Oudx1rHuHsAEjQ47lWHibQd84biVh0=;
	b=c45Mujn5Wm/fohqk+3D8ImXOUPJYNdW9+hNHG34st4djA8uQyRNfKPhJk4LMT8zfmqZJ
	 C3Fw11PkeXH4mDpPCRBj2IvBfexAGRtPgETzcgcT57hcw0QLt3Q14ilZqP8y/6QCDwBAQ
	 bOZDdSvLiGfEbqjDeHqnI73pZ3kkmtlXxB+QYR6by8NYoaPa+Cjovy067oH/sd9EATCg8
	 0EfekXuj4alMu/KgskKdPgNig/eZMSNb/kjWtUFg6zyYo+j0gze8Lkm/7O/BnEq3BGv3l
	 SRyMctSOyDKdc7X1EyYVbYkweUROXuEYSbkanKjWAx21oR3XD1HbeezkzO+ojJAv/0Q==
X-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="PSBgC/C7";
	arc=none smtp.remote-ip=100.103.45.18
X-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 D796B606A32D;
	Fri,  4 Dec 2026 16:29:27 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B3DC1F00931;
	Fri,  4 Dec 2026 16:29:18 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796401767;
	bh=iG9kiobqq6148Oudx1rHuHsAEjQ47lWHibQd84biVh0=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=PSBgC/C7pmBi9xCqFlj13iowjyaw2DQgzPR/M+85NTWaF3mM3t3JOVfULTxtSuioC
	 Sg8kkkDPLuA50mVsjDp5ysGcWW5mkVZuOXppP3dtTdtEpoh8bkGHJdr37pfzzvJE3M
	 A3Pz3xN6nlsxKWMj6Wo/T3wRKCXHm6hhR0AFX6hF8EGR5cuBstEg6DSgqc/03KXiZi
	 YX+Ab+k35mAKFePMKZOsZ92d/YMFw7b4F5iEBIXZRSW4Y1tGxTJbi/SAe/7KSRuUya
	 QL35HvEVTkwy+3f8HhDtKPxS8AWc+bC1CI8Vdedg93LMTxu5+5MMvP1ZyTDnnpQkSU
	 wLO+w326g+UQA==
X-Cc: Björn Töpel <bjorn@kernel.org>,
	Simon Horman <horms@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	David Wei <dw@davidwei.uk>,
	Tao Cui <cuitao@kylinos.cn>,
	linux-kernel@vger.kernel.org,
	kernel-team@meta.com,
	"Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>,
	linux-rdma@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	linux-doc@vger.kernel.org
X-Mailer: git-send-email 2.56.1
X-In-Reply-To: <20261204162723.755897-1-bjorn@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list