๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22492

Re: [PATCH net-next v12 4/4] net: stmmac: rework stmmac_rx to support XDP rx multi-buff

#22492
From: netdev-bot+sashiko
Date: Wed, 25 Nov 2026 12:31
146 lines
13683 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 (1) ยท 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).

- [Medium] The patch makes __stmmac_dvr_probe() always add
  NETDEV_XDP_ACT_RX_SG to ndev->xdp_features.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
  extends it.

--

net: stmmac: rework stmmac_rx to support XDP rx multi-buff

This reworks stmmac_rx() to collect every descriptor of a frame into an
xdp_buff. The XDP program now runs on the whole frame, which may be
fragmented, and the skb is built with __xdp_build_skb_from_buff(). It also
saves the in-progress xdp_buff across NAPI polls and advertises
NETDEV_XDP_ACT_RX_SG.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index ca4c7fb11b73f..b657701f51f90 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

[ ... ]

> @@ -6023,120 +6038,79 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)

[ ... ]

> +		ctx.desc = p;
> +		ctx.ndesc = np;
> +
> +		skb = stmmac_xdp_run_prog(priv, &ctx.xdp);
> +		/* For Not XDP_PASS verdict */
> +		if (IS_ERR(skb)) {
> +			unsigned int xdp_res = -PTR_ERR(skb);
> +
> +			if (xdp_res & STMMAC_XDP_CONSUMED) {
> +				__xdp_return_buff(&ctx.xdp, true);
> +				rx_dropped++;
> +			} else if (xdp_res & (STMMAC_XDP_TX |
> +					      STMMAC_XDP_REDIRECT)) {
> +				xdp_status |= xdp_res;
> +			}
> +			goto next;
> +		}

[Severity: High]
This is a pre-existing issue, but now that multi-buffer frames can reach
XDP_TX, does it widen a race on the RX page_pool's lockless alloc cache?

XDP_TX frames go to a TX queue picked by CPU number, not by the RX queue
that owns the page_pool:

stmmac_xdp_xmit_back()
  stmmac_xdp_get_tx_queue(priv, smp_processor_id())
      while (index >= priv->plat->tx_queues_to_use)
          index -= priv->plat->tx_queues_to_use;

Completion then runs in that TX queue's tx_napi:

stmmac_tx_clean()
  xdp_return_frame_rx_napi(xdpf)
    __xdp_return(..., napi_direct=true)
      page_pool_put_unrefed_netmem(allow_direct=true)
        page_pool_recycle_in_cache()

allow_direct is already true, so page_pool_napi_local() is skipped. That
means pool->alloc.cache and pool->alloc.count are written without a lock.

Meanwhile the owning rx_napi on another CPU uses the same cache through
stmmac_rx_refill(), __xdp_return_buff(&ctx.xdp, true), and
page_pool_put_full_page(..., true) in stmmac_build_xdp_frags().

Here is one example. With multi-MSI and ethtool -L rx 4 tx 2, rx_napi 2
(hinted to CPU2) sends XDP_TX on TX queue 0. The tx_napi for TX queue 0
runs on CPU0 and recycles pool 2 pages while rx_napi 2 refills from pool 2
on CPU2. IRQ affinity changes can cause the same overlap.

Can these unsynchronized updates give the same page to two RX descriptors,
or lose pages? Before this patch only the linear head page went through
this path. Now every buf1/buf2 frag page of a multi-buffer XDP_TX frame
goes through it as well.

[ ... ]

> @@ -8218,6 +8199,7 @@ static int __stmmac_dvr_probe(struct device *device,
>  	ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
>  			    NETIF_F_RXCSUM;
>  	ndev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
> +			     NETDEV_XDP_ACT_RX_SG |
>  			     NETDEV_XDP_ACT_XSK_ZEROCOPY;

[Severity: Medium]
Should NETDEV_XDP_ACT_RX_SG be advertised while the driver still refuses
the setups where multi-buffer XDP is needed?

stmmac_xdp_set_prog() in stmmac_xdp.c still rejects every program once the
MTU is above ETH_DATA_LEN, including programs loaded with
BPF_F_XDP_HAS_FRAGS. It also still turns SPH off:

	if (prog && dev->mtu > ETH_DATA_LEN) {
		...
		NL_SET_ERR_MSG_MOD(extack, "Jumbo frames not supported");
		return -EOPNOTSUPP;
	}

stmmac_change_mtu() also refuses a jumbo MTU while XDP is attached:

	if (stmmac_xdp_is_enabled(priv) && new_mtu > ETH_DATA_LEN) {
		netdev_dbg(priv->dev, "Jumbo frames not supported for XDP\n");
		return -EINVAL;
	}

The commit message says as much:

  "it does not enable XDP jumbo support by itself."

The in-tree AF_XDP selftest in tools/testing/selftests/net/lib/xsk/test_xsk.c
turns on its multi-buffer tests based on this flag:

	if (query_opts.feature_flags & NETDEV_XDP_ACT_RX_SG)
		ifobj->multi_buff_supp = true;

Those tests include testapp_send_receive_mb(), testapp_xdp_metadata_mb(),
testapp_adjust_tail_grow_mb() and similar ones. They set the MTU to
MAX_ETH_JUMBO_SIZE (9000) and attach a program in DRV mode. On stmmac one
of those two steps is refused, depending on which comes first. So these
tests would go from SKIP to FAIL with this patch.

Could NETDEV_XDP_ACT_RX_SG be left out until the MTU and program checks
accept frags-capable programs at jumbo MTU?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121-stmmac-rx-mb-v12-0-3ae2f3bce174%40oss.qualcomm.com
Technical Details
Message-ID: <179560987080.3135.9418981958235641169@kernel.org>
Path: mbox-mo1.pugleaf.net!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-371306-linux-kernel-netdev=dewy.ru
References: <20261121-stmmac-rx-mb-v12-4-3ae2f3bce174@oss.qualcomm.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!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-371306-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v12 4/4] net: stmmac: rework stmmac_rx to support
 XDP rx multi-buff
Date: Wed, 25 Nov 2026 12:31:10 +0000
Organization: Usenet Network
Message-ID: <179560987080.3135.9418981958235641169@kernel.org>
References: <20261121-stmmac-rx-mb-v12-4-3ae2f3bce174@oss.qualcomm.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="203966"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:EQLS5D2jX14Wy4roUIUvoBsNoYI= sha256:UNWpHj/uIMONuZu0ZDeN5UlOFasP0lPiI5xLJpYbBWc=
	sha1:W4lZskYhmrqLensbo+FWSf0MMIc= sha256:UlLIOybtLyE13mYdFItcxnD8JdtezrJjH0rw2jX4N5M=
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 1654D125E66; Wed, 25 Nov 2026 15:31:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 ugTl3uOETpED;
	Wed, 25 Nov 2026 15:31:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-371306-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 8EEB5125E65; Wed, 25 Nov 2026 15:31:23 +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 889962AA0D; Wed, 25 Nov 2026 12:31:21 +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=1795609879;
	b=jn260QeOq5oq/91kTHljDb+7DfFkPpgMgncHyOZ9prSpxsA84xoA+gmWNOvYpJ9b866w
	 YiyFxruLKdCvSPYctHuQUGC6c3K7pPHNhIpUwMSExYuUvAcs1FZSMUIGTO4OmCtK1/uho
	 Gzcd3wKdJVwlqBzHZWhWDbq+1kcpr8GNwDinYpwWYPNB13Q4Eb8EqBxNEFGplR2LmEPO2
	 v7O3TgMBNBdG9xUJrH3+vVLBQDYBeSorFKLX3s5PlxmEY7hE2Z7STTomAAsGi83blr/ri
	 Hsec4P2r5qpX8Twzepql7mU0k+WBOzDm2OmF7Sn6+CigmUGvYNOORlez251Y7cm4HdA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795609879;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=YW/wH69a6msdALwLu/bQnPmudlA0vz81wQd6TeQpf3U=;
	b=I+oqumZmAF+XcOL2jnDD1FtckiYz02+iJh7QLrYBdkkOMWEnu1Vyll5yKspxSa+1XiQI
	 elH/pJ+EEc4y21Kll+3emSom0g3rV53Dkl64+0THEitCFRW52W58jkm2GUtuMQMtmEbqz
	 RB8m/0HDpTDbJuffU2psx/SLpL+AOW8FaBecfwMfahMMp6zu+fHhOHQc311dsj9xuymK1
	 DNnRLFRPiQCrVpYQVxYNHr9phpweV9KEFkJ6g65r34BvsX49CkMu5O/E3IefH15RL+L9b
	 BP1itdLQ98PGrhGDiQi9n7BjMB6zjkiaiSIYKYWm0JtTlrrPPhSPWEOk4aoeGABuZUg==
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=MCPTuUqF;
	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 453CA606A32A;
	Wed, 25 Nov 2026 12:31:19 +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=MCPTuUqF
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=1795609873;
	b=QGTh49TyAdfZ3S/oa3r17OKESuPM0VG1K+0qCH0vDVxtIZo4inEA0e8bIKJVz7jnpryw
	 cfrfVtWEi1C9bFdSerMN2LgoFQyXZrSVdvtLHXvCZJyiasBI+EXVfseV7vFKy7TUGBg1Y
	 oMpV9q815W/3D+WQ13G5kgd/KT3JfidiEbWoZcJ6ATf8FIet+eOgnTNIC7DZhyHvwaT5c
	 QxaJhay2hFQzil8JY5it+qh03zIkUoSWo6+Qf05zINCD93VFM816Ftry7a/AQkZoHY1V7
	 1laT81SomrSdwnM837dJ7ytA6x2Sew00SAgu0PkkPA1cgBtezGN1fCCpkI9nwDHrN1w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795609873;
	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=YW/wH69a6msdALwLu/bQnPmudlA0vz81wQd6TeQpf3U=;
	b=bvzIYx9s8yfQ2l6BtbMInjWDBOyM/hydX1ySVqvxXYgt/zM89NAmkayS8S3wX8OgpjZ+
	 Ssdr4YhY2d0KzSLMFZwhEzMc6Cp5lXoULeINnkSXm7b+YG/dMx5tP5AW7vk5QKjfQu0IT
	 cMqfkfUATICsAUtxXVab9OPZvF0txiVpYVHWkJUC3OWOcyxdB6xKQfbx6KlTSZSaeJRkn
	 qmAMkBauJwp6r8B8SJaY5kul5HRpX29PzoxzRQ8Fi+uO4/S6dKWkj0X2rr8tYucroMRBT
	 OIbnrfL0HcqTC8Pnqs/OeQXazVWewNgnazY8kaX+atXTYVxLVp6VaY+l4MbsCKJr6Kw==
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=MCPTuUqF;
	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 5F8A4606A31E;
	Wed, 25 Nov 2026 12:31:13 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43CD31F000C4;
	Wed, 25 Nov 2026 12:31:11 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795609872;
	bh=YW/wH69a6msdALwLu/bQnPmudlA0vz81wQd6TeQpf3U=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=MCPTuUqFt3zw+UNyh4BYvuzxLB6B+IDc/VhwWdBapfXfjl2RlXZhCqHwlsMK0RHVi
	 si3afs8RfkmgO8Wrcu6gnRJTLfcrFt2v9zGhfw7uygp65S+ZSO6YgCyKRdpOV1TbSv
	 iEEy4HEnbzBeOXZ5iOrD9qcik3oRyHFQL80dfEnMLvJMbkZbwIG8ryrpjjT9IW4/Cu
	 lT/o65ghUXTn7K0VRXmjNEX4cI1ORjj13/OYxLLgk3oIap4HvAQoFovW7OgZitwTUj
	 XiuPR9ExMyYnsSvl3lAE85FE9dU9JXPIPuriV72A7ojjLnjnlRJ0uhI5bwDgSbtFB/
	 w+qKdZTHIU0JQ==
X-Cc: maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, ast@kernel.org,
 daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
 sdf@fomichev.me, Jose.Abreu@synopsys.com, boon.leong.ong@intel.com,
 horms@kernel.org, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
 martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
 jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
 netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
 bpf@vger.kernel.org, nb@tipi-net.de
X-In-Reply-To: <20261121-stmmac-rx-mb-v12-4-3ae2f3bce174@oss.qualcomm.com>
X-sashiko-severity: Medium
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