🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22734

Re: [PATCH net-next 12/15] eth: mlx5e: Receive into XDP-only memory providers

#22734
From: Björn Töpel
Date: Wed, 25 Nov 2026 20:26
193 lines
17098 bytes
netdev-bot+sashiko@kernel.org writes:

> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
>
> Critical: 0 · High: 2 · Medium: 1 · 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] net/mlx5e: deferred close in mlx5e_switch_priv_channels()
>   starves XDP-only MP
> - [High] net/mlx5e: NAPI busy loop and refill rollback in
>   mlx5e_post_rx_wqes()
> - [Medium] The mlx5 patch lets the nonlinear striding RQ take an XDP-only
>   (AF_XDP sink) provider, but the commit message only describes the…
>
> --
>
> eth: mlx5e: Receive into XDP-only memory providers
>
> This patch lets the page pools of mlx5 RQs that run an XDP program take
> XDP-only memory providers such as the AF_XDP sink. It also allows queue
> restarts while a program is attached, and it skips the minimum posted
> WQE wait for provider-backed RQs. Buffer addresses are now taken with
> xdp_netmem_address() so XDP-only net_iovs are covered.
>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
>> index 06a8a4be4be7c..a8d46508b6fc3 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
>> @@ -1012,6 +1012,9 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
>>  
>>  		pp_params.order     = pool_order;
>>  		pp_params.flags     = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
>> +		/* Trap and PTP RQs use queue 0 too, without a program */
>> +		if (params->xdp_prog)
>> +			pp_params.flags |= PP_FLAG_ALLOW_XDP_ONLY_NETMEM;
>
> [Severity: Medium]
> How does this behave for the nonlinear striding RQ? The flag is also set
> there, but the commit message only talks about the linear striding RQ:
>
>     The RQ keeps its layout. A stride of the linear striding RQ still
>     holds the shared info of the skb that XDP_PASS builds, ...
>
> The nonlinear striding RQ is used with XDP when the program is frags
> aware and the MTU is above the linear XDP limit. With a program attached,
> mlx5e_skb_from_cqe_mpwrq_nonlinear() builds an empty head in the linear
> page:
>
> drivers/net/ethernet/mellanox/mlx5/core/en_rx.c:mlx5e_skb_from_cqe_mpwrq_nonlinear() {
>     ...
> 	if (prog) {
> 		...
> 		va = mlx5e_mpwqe_get_linear_page_frag(rq);
> 		...
> 		linear_hr = XDP_PACKET_HEADROOM;
> 		linear_data_len = 0;
>     ...
> }
>
> mlx5e_mpwqe_linear_page_refill() allocates that linear page from
> rq->page_pool. With this flag set, the page is a UMEM chunk taken from
> the socket's FILL ring, and it is only ever used for empty heads.
>
> mlx5e_fill_mxbuf() calls xdp_prepare_buff(..., true), so the program can
> call bpf_xdp_adjust_meta() into that headroom. When an empty head
> reaches the sink, xsk_sink_rcv() does this:
>
> net/xdp/xsk_sink.c:xsk_sink_rcv() {
>     ...
> 	if (!hlen) {
> 		/* An empty linear part, as mlx5 builds for nonlinear RQs */
> 		empty = niov;
> 		headroom = 0;
> 	} else {
>     ...
> 	if (metalen > headroom)
> 		goto drop;
>     ...
> }
>
> Won't every packet on this RQ type whose program wrote metadata (RX hash,
> timestamp and so on) be dropped and counted in rx_dropped? The same
> program works on the linear striding RQ and on the cyclic RQ.
>
> That also seems to contradict the documentation added in this series,
> which says bpf_xdp_adjust_meta() and the RX metadata kfuncs work as with
> pages.
>
> Should the commit message and docs describe the nonlinear striding RQ
> case, both the dropped metadata and the UMEM chunks spent on empty heads?
> Or should this mode be handled differently?

Will fix, and document. Metadata must work!

>>  		pp_params.pool_size = pool_size;
>>  		pp_params.nid       = node;
>>  		pp_params.dev       = rq->pdev;
>
> [ ... ]
>
>> @@ -3050,6 +3053,14 @@ static int mlx5e_wait_channels_min_rx_wqes(struct mlx5e_channels *chs)
>>  		if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
>>  			continue;
>>  
>> +		/* An RQ that an XDP-only provider backs fills from the FILL
>> +		 * ring of its socket, which stays empty until the socket
>> +		 * gets its chunks back, so a queue that restarts under a
>> +		 * slow reader would never meet the bound.
>> +		 */
>> +		if (netif_rxq_has_xdp_only_mp(c->netdev, c->ix))
>> +			continue;
>> +
>>  		err |= mlx5e_wait_for_min_rx_wqes(&c->rq, timeout);
>>  
>>  		/* Don't wait on the XSK RQ, because the newer xdpsock sample
>
> [Severity: High]
> How does this behave on a cyclic RQ? The flag is set for both RQ
> types, and mlx5e_skb_from_cqe_linear() and
> mlx5e_skb_from_cqe_nonlinear() now take XDP-only net_iovs. A provider
> can therefore back an RQ that runs with striding RQ disabled through
> the priv flag, or on a device that lacks it.
>
> There, rq->post_wqes is mlx5e_post_rx_wqes(), which asks
> mlx5e_refill_rx_wqes() for the whole missing part of the ring as one
> wqe_bulk. The FILL ring of the socket may hold fewer chunks than
> that, which is the normal case at bind time and under a slow reader.
> mlx5e_alloc_rx_wqes() then stops short, and mlx5e_refill_rx_wqes()
> jumps to err_free. It frees everything it allocated with
> mlx5e_free_rx_wqes() and returns 0.
>
> mlx5e_post_rx_wqes() then sees count != wqe_bulk and sets busy
> regardless of rq->xsk_pool. mlx5e_napi_poll() returns the full budget
> without calling napi_complete_done(). NAPI keeps rescheduling itself
> in softirq, posts nothing to the hardware, and never parks to wait
> for the socket to wake it. If the UMEM has fewer chunks than the
> ring, the bulk can never be satisfied and the CPU spins
> indefinitely.
>
> The striding path posts what it got and only reports busy when
> rq->xsk_pool is set, so it idles until xsk_sink_wakeup(). Should the
> cyclic path do the same for a provider-backed RQ, posting partial
> bulks and not reporting busy? Or should
> PP_FLAG_ALLOW_XDP_ONLY_NETMEM be limited to the striding RQ until it
> does?

Yeah, bind on cyclic RQ will fail in the next version.

> [Severity: High]
> Can the new RQ end up with no posted WQEs at all when the channels
> are switched while a provider is bound? Before this change, the wait
> here would at least time out and queue rx_timeout_work. Now the RQ is
> skipped silently.
>
> On devices with tis_tir_td_order, mlx5e_switch_priv_channels() only
> deactivates the old channels. mlx5e_close_channels_xsk() then closes
> just the RQs that have MLX5E_CHANNEL_STATE_XSK set. The regular RQ of
> old_chs and its page_pool stay open while
> mlx5e_activate_priv_channels() activates the new channels and
> mlx5e_trigger_napi_icosq() runs their first refill.
> mlx5e_safe_switch_params() closes old_chs only after that.
>
> The chunks that the old page_pool has taken from the provider keep it
> as their owner. When the new RQ refills, sink->released is still
> empty. A chunk from the FILL ring that the old pool owned is put back
> into the old pool's ring rather than handed to the new one. The
> allocation fails. mlx5e_post_rx_mpwqes() posts nothing and returns
> false, since rq->xsk_pool is NULL, and NAPI completes.
>
> When mlx5e_close_channels(old_chs) later destroys the old pool, its
> chunks move to sink->released, but nothing schedules NAPI on the new
> channel. No RX WQEs are posted and no UMR is in flight on the ICOSQ,
> so no completion will arrive to wake it. The queue stops receiving.
>
> This is reachable from MTU changes, ethtool ring and channel changes,
> priv flag changes, and mlx5e_safe_reopen_channels() during recovery.
> Should the RQ that a provider backs be closed before the new channels
> are activated, as is already done for the XSK RQ? Or should NAPI on
> the new channel be kicked once old_chs is closed?

Hmm... I think you're right. Let's try that.
Technical Details
Message-ID: <87tsl4lkry.fsf@all.your.base.are.belong.to.us>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371657-linux-kernel-netdev=dewy.ru
References: <20261124125654.183091-12-bjorn@kernel.org> <179561570896.3135.8953893024403211017@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371657-linux-kernel-netdev=dewy.ru
From: bjorn@kernel.org (Björn Töpel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 12/15] eth: mlx5e: Receive into XDP-only memory
 providers
Date: Wed, 25 Nov 2026 21:26:57 +0100
Organization: Usenet Network
Message-ID: <87tsl4lkry.fsf@all.your.base.are.belong.to.us>
References: <20261124125654.183091-12-bjorn@kernel.org>
 <179561570896.3135.8953893024403211017@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="295469"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:e0tOrKSExWzY7q0cPUKA2jqPJJk= sha256:pQO0hInraoKm07GdHlN/wZMmf99vuue+3vCFYLCJByg=
	sha1:TGITB2h8cylaNIPN8vDzmBLJL60= sha256:PKo1AgR6wpCyNks9LGy0bLtdm/sGd1o2EHXcDj1ZKzM=
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 9332C125E9D; Wed, 25 Nov 2026 23:27:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 lgD782OpAQVh;
	Wed, 25 Nov 2026 23:27:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-371657-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id EDB83125E94; Wed, 25 Nov 2026 23:27:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 28BA4355CA; Wed, 25 Nov 2026 20:27:10 +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=1795638427;
	b=jSMkEhMcgnWxKnQIyihAis/blTMArfQaery0FFpPWk9g/jeptKpHcBFdExRffZDq2TyS
	 Zw0cTMLCYcQs6PxkJT5XXovPTq+AAG/q2vOoeuQe5KnKnVIrUk0JuQHLegk+z1gENLWO3
	 OCGx3SQuNujT+tEerRVHa2BgYx6bLnhVqjWteOzKOPDaiUha+9VfaJ1F2DwL8eIYUKKJR
	 zBKrF1ljTLrixZQHxY+DJLaxVQ+2Ry8oDLTXExF1DrXVMrYh3p5BU4u6zCjjEsqhfuFba
	 yr+OuFsseol9WqI79nXA/FtxpiZB1HeTRB5DUKZ8K3RL9JnDYRMOKHYCyAkhhIBA7GQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795638427;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 In-Reply-To:References:Date:Message-ID:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding;
	bh=ZeI0AGTd97czsolzOlbnXFbpYQc5tCXGUex9w6md5FQ=;
	b=xHznrTY1IvOpWhcNsfKI7hwNnaOplw59RBzXLyg2YUJWVrn3V6adoc9owAlFaB3FpQpi
	 WjO5iuTI1w3MTi8hUaBx8KLP1ve++kZJcGlSF7roT8yQxq/Jv70Li3n7WKiPK/hMgM8RQ
	 dapm9rp9SRO7eKcJ4hlJ8dUgl714sZNJIwFbuIkRVnCBK5emK3zlVmD7irNQbB66XvOi1
	 ZbWLtzPSeGvMDWQIFIjy8DWlWhaOLic3m5Of3LgyhLruTP9ziB8Vvun3ae2PxFmDsD5rJ
	 WP5La1yooncXYJ/YfWIR5RmLncExT516bmaJvMYCpk2xSSwWYHFPNMWdJxnRAP0YBWQ==
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=PGCAiqT+;
	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 B4368606A32C;
	Wed, 25 Nov 2026 20:27:07 +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=PGCAiqT+
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=1795638421;
	b=Me7mkCFW0TbipoyusOjbRVunP//QqkM5KAhR7pKGw+Cd6FoADep3ws44s251KHsIdBfZ
	 7zflJ7ow6CgFqzEU9Yf9YF6exmupB7dgwpahU/CjJlTLQrYJDPedTX/+7mvyEtRYRb3Da
	 kIHizHMVf0HBxJbz8H/tC10vPM+hWVxtMuGGewQkjlUtCjYkFs7RytBwyLxLkq1Pjy79B
	 Eo+34zzPdmpfQAtiG0+MQrFRZFTugqpfaPN3ZpAiH5zOmqPjkSSBb4CL0FBA5XXOgZyDF
	 TJ5DFlFYoyGdTfpyEWq0ZnE1iEZskegUQ8xX0JKjmAfo7g1XCYkLjMlbKv9yHMOizYw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795638421;
	h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References:
	 Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding;
	bh=ZeI0AGTd97czsolzOlbnXFbpYQc5tCXGUex9w6md5FQ=;
	b=P9T8Mdv/PFRBUYHbSO8+rK/5uwl3cRt2J38Y34KZzJMR70uf1rhgpM/18PWEhav1c9ma
	 lyVKFh23BF4+rO27VfWnCumCkkEUghYGoKINm9SxmcWwAjvNiFy1mdPUG+DXfyEeoaBIU
	 0UZ/Fb4MNAFV3FkfWeuynV93AnfruX/GXu/LCiHO6/f6wX7yxWDbEe/JDlOZU6DFtEKtC
	 TaVk+tmGoAx1qQlP8etjDQlORi+DawFc8IWkkkhWnPduyxtrmcLU7S4At7VCmF7Uxg75l
	 FASJ1X7HbELUe9h0KxRXg8sjLmEcCu70d8dGN3mEODuyI8d1qrEV7hoZWhYO0FXkrsg==
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=PGCAiqT+;
	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) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFA90606A326;
	Wed, 25 Nov 2026 20:27:01 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C08D1F000CF;
	Wed, 25 Nov 2026 20:27:00 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795638421;
	bh=ZeI0AGTd97czsolzOlbnXFbpYQc5tCXGUex9w6md5FQ=;
	h=From:To:Cc:Subject:In-Reply-To:References:Date;
	b=PGCAiqT+Cr5Xm0z7RchrnJVJTmAuvoCt1912rq67bQoYYP49MbcqJOVi/26A3yxLz
	 lIdHVQpfxG8x5xvZsRWYpbNIy7gi/aleII8GzT3ZwcTD2O0yxnesqm2uD4pOnnk3/n
	 TOESmUGnCN56BM42n3VPVq6+Jd3ZdbjDwqPKyJ8WrjOwDiZKsunTKTP1vns8YhvmGd
	 kBkFXuLpJIjimllwtg/vtO7iHbvr4iw/k5TEfNUy5TDS23Djq8BEA8SkzySC85lW+J
	 yrg8YVOI28GEKO1e7koCSvd1H/v7B1yMUD3GMX/SGqkXZc5jf5/5BsHaZKkvAs+0go
	 cHG9eak9Gi37A==
X-Cc: magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
 pabeni@redhat.com, andrew+netdev@lunn.ch, ast@kernel.org,
 daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
 andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
 ilias.apalodimas@linaro.org, alexanderduyck@fb.com, saeedm@nvidia.com,
 tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org,
 michael.chan@broadcom.com, pavan.chebbi@broadcom.com, corbet@lwn.net,
 shuah@kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org,
 stuclar@meta.com, sdf@fomichev.me, horms@kernel.org, martin.lau@linux.dev,
 almasrymina@google.com, song@kernel.org, yonghong.song@linux.dev,
 jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
 rdunlap@infradead.org, kernel-team@meta.com,
 dimitri.daskalakis1@gmail.com, bobbyeshleman@meta.com,
 mohsin.bashr@gmail.com, kees@kernel.org, leitao@debian.org,
 maxime.chevallier@bootlin.com, cuitao@kylinos.cn,
 vadim.fedorenko@linux.dev, mike.marciniszyn@gmail.com, kuniyu@google.com,
 jiayuan.chen@linux.dev, mkarsten@uwaterloo.ca, razor@blackwall.org,
 dw@davidwei.uk, asml.silence@gmail.com, linux-rdma@vger.kernel.org,
 linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <179561570896.3135.8953893024403211017@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