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