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=1796401767; b=mVFxm4avBkMNqiS3kTn69QaZFsXal84okNrsqgZQwFWXTuSATRujTRkEwkv1g8UbUHRp vpOq76tsrBGi74rNHunuZmz0aM+QFiRT59Ghf/ruAFYkif9REo9VuKuKOuCVpZ3pcaytt nm7JBeNZUcfqKjQ6d6k0Oio/UMII6n3yYlhWErVkmUQaOHbMgxCNerW5eLc/6kqF19RKn AIu/JdU9sFRKujabfxUKlokUzU0uuZtjmnBiXa/RX32iC3WImkFb1Dd246qUwOUEYyWje ORFvgg0GFQDtD1GBC8nwUAkNhjW0iQyT7CtDep8GRwwEzzzS8e0OqiFhys40se8IYuw== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B3DC1F00931; Fri, 4 Dec 2026 16:29:18 +0000 (UTC) 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== From: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Nikolay Aleksandrov , Andrew Lunn , Ilias Apalodimas , Magnus Karlsson , Maciej Fijalkowski , Donald Hunter , Alexander Duyck , Saeed Mahameed , Tariq Toukan , Mark Bloch , Leon Romanovsky , Shuah Khan , Jonathan Corbet , netdev@vger.kernel.org, bpf@vger.kernel.org Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Simon Horman , Stanislav Fomichev , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , David Wei , Tao Cui , linux-kernel@vger.kernel.org, kernel-team@meta.com, "Mike Marciniszyn (Meta)" , linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan , Randy Dunlap , linux-doc@vger.kernel.org Subject: [PATCH net-next v2 12/15] net/mlx5e: Release XDP-only pages earlier Date: Fri, 4 Dec 2026 17:27:17 +0100 Message-ID: <20261204162723.755897-13-bjorn@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204162723.755897-1-bjorn@kernel.org> References: <20261204162723.755897-1-bjorn@kernel.org> 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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