All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
To: netdev-bot+sashiko@kernel.org
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
Subject: Re: [PATCH net-next v12 4/4] net: stmmac: rework stmmac_rx to support XDP rx multi-buff
Date: Wed, 25 Nov 2026 15:55:26 +0100	[thread overview]
Message-ID: <awb23jFbMuiQLhzO@lore-desk> (raw)
In-Reply-To: <179560987080.3135.9418981958235641169@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 5873 bytes --]

On Nov 25, netdev-bot+sashiko@kernel.org wrote:
> 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.

ack, I will fix it in v13.

Regards,
Lorenzo

> 
> 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2026-11-25 14:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 17:28 [PATCH net-next v12 0/4] net: stmmac: introduce XDP rx multi-buff support Lorenzo Bianconi
2026-11-21 17:28 ` [PATCH net-next v12 1/4] net: xdp: add __xdp_build_skb_from_buff() helper Lorenzo Bianconi
2026-11-22 19:21   ` Nicolai Buchwitz
2026-11-22 19:45   ` Maxime Chevallier
2026-11-24  9:04     ` Lorenzo Bianconi
2026-11-24  9:14       ` Maxime Chevallier
2026-11-21 17:28 ` [PATCH net-next v12 2/4] net: xdp: add xdp_buff_shrink_tail() helper Lorenzo Bianconi
2026-11-21 17:28 ` [PATCH net-next v12 3/4] net: xdp: add __xdp_return_buff() helper Lorenzo Bianconi
2026-11-21 17:28 ` [PATCH net-next v12 4/4] net: stmmac: rework stmmac_rx to support XDP rx multi-buff Lorenzo Bianconi
2026-11-25 12:31   ` netdev-bot+sashiko
2026-11-25 14:55     ` Lorenzo Bianconi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awb23jFbMuiQLhzO@lore-desk \
    --to=lorenzo.bianconi@oss.qualcomm.com \
    --cc=Jose.Abreu@synopsys.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=boon.leong.ong@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=martin.lau@linux.dev \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=memxor@gmail.com \
    --cc=nb@tipi-net.de \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.