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=1795912623; b=VYDdUsdzei4QfkHiI6vp7fBFvJRkiMwuarXRvNB7wVtBXN8fZzenyM9d9vN46mHn0Qu5 DV0mfsP/AnVz8CxTnpMbwifSTlEkw3UQfNh/0MgWDKY1La1ZLKWlkO4eIxomTVJEmyN/U 9T1TxveZgPoFkWs15oGs5U5tdcY5BDxjkSd2ui+JfGFobl5X2KnWIEQxtuKmIskweH068 IJ+jt9aux32hccWmVJ1IGGKRIoSARh+OLPV//eLPp6EoKSoXwrcs527SeXk2uFreBEJk+ zmSeS7CfT9QuZ0XQqWeh1nRg9+I/Z5XJ9cZ3fszBLJpfiSmHtbzjSj7KAj5WioVQygA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795912623; 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=9bQU8r5RX/UsBC/kSsT2+z0QnxEmJIL6qJmtdUca0tQ=; b=DAG5A3zBarIlOonraeqcMq8D5XIR2AKZe5rMGzP0DVdxT4n/RP1FFwT9pgnyWGMC4O6I kq893tQiao0+v97ilb2n5RLI4T+hF61kyhY135Y0vmE3a97vmyHp/aN2s53gFq4c4F9A0 Tl2/IVvFpctW4zKd5EYx8sew/ZFhquD24nzNSjPlUQE8NlhnaHy5IUXJC5rmHDAIZUlDh Sj/FbGaa5EXlRKGeIAwzgCMODnLEDN+b6ujqKsys85W10lsRsryQUunvbDYttorrOmSNI rTXDh6LlYnWsH1UCATu5xYGP6HcTgKCnmLpkhGfYSCA4AnCdv9SEKdGEuKrgusX2xbw== 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=lOGtwC4S; 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 98D72606A321; Sun, 29 Nov 2026 00:37:03 +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=lOGtwC4S Received: by smtp.kernel.org (Postfix) with ESMTPSA id A84741F0092F; Sun, 29 Nov 2026 00:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795912623; bh=9bQU8r5RX/UsBC/kSsT2+z0QnxEmJIL6qJmtdUca0tQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=lOGtwC4SswG+tgzT3cTlH9b2wOvO8J0kQ0beAfz0KBemcZAgPmJMwtmxqdSVsdELB jgBlyDez52geTmUnkRqV29/r2bCNncsqi8hEFGLeus2tMGSiRD/FeQ1dztE0GkBW1S iiSUZpX6rTVl+7jDIAoS1jOtei4vrsDKHhVd0uKhBBvu0xdVcdK7HtWzK9Ttu3nGS/ XM3NYteS/AYuNhwgQkl6UGCSIL1kLPH7kic/FG31c4rrtRWVJp0W8dRDhJ4KbWOrGB Nd3UuDf2RoJYdhoPNPCeUAd2Hhqg67zBOhkF+juX9NiJ89s0CW97zi4X/q4T7ONPrT Fy+avWuGb3QrA== Subject: Re: [PATCH net v5 1/6] igb: don't touch rings that don't exist when disabling an XSK pool From: netdev-bot+sashiko@kernel.org To: antonio@mandelbit.com Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, janislacis06@gmail.com, kurt@linutronix.de, joe@dama.to, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Sun, 29 Nov 2026 00:37:02 +0000 Message-ID: <179591262227.3135.16082413579804949790@kernel.org> In-Reply-To: <20261124235723.1135808-2-antonio@mandelbit.com> References: <20261124235723.1135808-2-antonio@mandelbit.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 1 (3) · Medium: 1 (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] At this commit, the new `qid < adapter->num_rx_queues` check in igb_xsk_pool_disable() and the num_tx_queues check in… - [Medium] The new comment in igb_xsk_pool_disable() (drivers/net/ethernet/intel/igb/igb_xsk.c:161-163) and the commit… Pre-existing issues: - [High] The new gate in igb_xsk_pool_disable() is `netif_running() && igb_xdp_is_enabled() && qid < adapter->num_rx_queues`… - [High] igb_txrx_ring_disable() zeroes TXDCTL for tx_ring[qid], then calls igb_clean_tx_ring() and later igb_configure_tx_ring() on it. - [High] In igb_xsk_pool_disable(), igb_realloc_rx_buffer_info(rx_ring, false) can fail with -ENOMEM (vmalloc). - [Medium] This patch adds igb_xsk_tx_ring() ("With VFs, the device has a single Tx queue but can have more Rx queues") and changes the pool-… -- igb: don't touch rings that don't exist when disabling an XSK pool This patch makes igb_txrx_ring_disable() and igb_txrx_ring_enable() skip the Tx ring when qid is at or beyond num_tx_queues. It also makes igb_xsk_pool_disable() skip ring teardown when qid is at or beyond num_rx_queues, covering 82576 with VFs and the MSI fallback on resume. Link: https://lore.kernel.org/netdev/20261116153041.3002666-2-antonio@mandelbit.com/ > diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c > index ce4a7b58cad2f..3b4212a9521e0 100644 > --- a/drivers/net/ethernet/intel/igb/igb_xsk.c > +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c > @@ -31,15 +31,22 @@ static int igb_realloc_rx_buffer_info(struct igb_ring *ring, bool pool_present) > return 0; > } > > +/* With VFs, the device has a single Tx queue but can have more Rx queues */ > +static struct igb_ring *igb_xsk_tx_ring(struct igb_adapter *adapter, u16 qid) > +{ > + return qid < adapter->num_tx_queues ? adapter->tx_ring[qid] : NULL; > +} > + [Severity: Medium] This isn't a bug introduced by this patch, but this helper now treats a queue that has an Rx ring using the pool and no Tx ring as a supported state. Does igb_xsk_wakeup() need the same handling? It still rejects such a queue before it gets to the XDP_WAKEUP_RX branch: igb_xsk_wakeup() { ... if (qid >= adapter->num_tx_queues) return -EINVAL; ring = adapter->tx_ring[qid]; if (!READ_ONCE(ring->xsk_pool)) return -EINVAL; ... } Take a socket bound to queue 1 on 82576, with VFs enabled afterwards. num_tx_queues becomes 1 while real_num_rx_queues stays 2, and igb_configure_rx_ring() keeps Rx ring 1 in zero-copy mode. Every need_wakeup Rx kick for that queue would then fail. Rx would only make progress on hardware or watchdog interrupts. igb_xsk_pool_enable() also uses a different validity rule: it checks num_rx_queues plus both real_num_*_queues. > static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid) > { > - struct igb_ring *tx_ring = adapter->tx_ring[qid]; > + struct igb_ring *tx_ring = igb_xsk_tx_ring(adapter, qid); > struct igb_ring *rx_ring = adapter->rx_ring[qid]; > struct e1000_hw *hw = &adapter->hw; > [ ... ] > @@ -47,24 +54,27 @@ static void igb_txrx_ring_disable(struct igb_adapter *adapter, u16 qid) > /* Rx/Tx share the same napi context. */ > napi_disable(&rx_ring->q_vector->napi); > > - igb_clean_tx_ring(tx_ring); > + if (tx_ring) { > + igb_clean_tx_ring(tx_ring); > + memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats)); > + } [Severity: High] This isn't a bug introduced by this patch, but does the "Rx/Tx share the same napi context" assumption hold when IGB_FLAG_QUEUE_PAIRS is clear? igb_set_flag_queue_pairs() leaves the flag clear on 82575/i211. On 82576/i350/i210 it also stays clear whenever rss_queues is at most max_rss_queues / 2, e.g. 82576 or i350 on a host with 4 or fewer CPUs. In that case igb_set_interrupt_capability() reserves one vector per Tx queue, and igb_alloc_q_vectors() allocates the Rx-only vectors first. So tx_ring[qid] sits on a different NAPI than rx_ring[qid], and that Tx NAPI is still enabled here. Three things can schedule that Tx NAPI: - an interrupt for descriptors completed before TXDCTL was cleared - the watchdog EICS kick - igb_xsk_wakeup(XDP_WAKEUP_TX) It would then run igb_clean_tx_irq() while igb_clean_tx_ring() walks the same tx_buffer_info entries. igb_clean_tx_irq() doesn't check IGB_RING_FLAG_TX_DISABLED. Can both paths free or unmap the same skb or xdp_frame, and both report xsk completions? The re-enable side has the same issue. igb_configure_tx_ring(), called from igb_txrx_ring_enable(), can memset tx_buffer_info and reset the indices while that NAPI is still walking them. [ ... ] > @@ -148,7 +158,12 @@ static int igb_xsk_pool_disable(struct igb_adapter *adapter, u16 qid) > return -EINVAL; > > rx_ring = adapter->rx_ring[qid]; > - if_running = netif_running(adapter->netdev) && igb_xdp_is_enabled(adapter); > + /* The stack can know more queues than the device has, e.g. after a > + * fallback to fewer queues on resume: skip the rings it doesn't have. > + */ [Severity: Medium] Is this comment still accurate once a resume has completed? __igb_resume() calls __igb_open(netdev, true), which passes the reduced counts to the stack: __igb_open() { ... /* Notify the stack of the actual queue counts. */ err = netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues); ... err = netif_set_real_num_rx_queues(adapter->netdev, adapter->num_rx_queues); ... } xsk_get_pool_from_qid() checks queue_id against real_num_rx_queues. After the resume, xsk_get_pool_from_qid(dev, 1) returns NULL, so igb_xsk_pool_disable() returns at the earlier check: pool = xsk_get_pool_from_qid(adapter->netdev, qid); if (!pool) return -EINVAL; It never reaches the new num_rx_queues test. xsk_pool_dma_unmap() is skipped, so the pool's DMA mapping leaks, and xp_disable_drv_zc() hits its "Failed to disable zero-copy!" WARN. The leak and the WARN predate this patch. The new check seems to help only during the resume window itself, or when __igb_open() fails before netif_set_real_num_*() runs. The same applies to this part of the commit message: "and igb can fall back from MSI-X to MSI with a single queue on resume" Two later patches in this series seem to fix this: - "igb: fix RTNL assertion when resuming from runtime suspend" stops lowering the real counts in __igb_open() on runtime resume. - "igb: keep the stack's Rx queues that still have an XSK pool" adds igb_set_real_num_queues(). Should the comment and commit message here describe only the cases this patch handles? > + if_running = netif_running(adapter->netdev) && > + igb_xdp_is_enabled(adapter) && > + qid < adapter->num_rx_queues; > + if (if_running) > + igb_txrx_ring_disable(adapter, qid); > [Severity: High] This isn't a bug introduced by this patch, since the old gate behaved the same way. Does this check catch states where the rings exist and num_rx_queues is non-zero, but the rings aren't actually up? One such state is a failed resume. __igb_resume() first calls igb_init_interrupt_scheme(adapter, true), which reallocates the rings and q_vectors and restores num_rx_queues. If __igb_open(netdev, true) then fails, the error labels free the ring resources, and napi_enable() is never reached: err_set_queues: igb_free_irq(adapter); err_req_irq: igb_release_hw_control(adapter); igb_power_down_link(adapter); igb_free_all_rx_resources(adapter); err_setup_rx: igb_free_all_tx_resources(adapter); netif_running() stays true. The real queue counts were not lowered either, so the pool is still found. Another is PCI error recovery. igb_io_error_detected() calls igb_down(), which napi_disable()s every q_vector, while netif_running() and the queue counts stay the same. Closing a zero-copy socket in either state takes this path: xp_release_deferred() rtnl_lock() ndo_bpf igb_xsk_pool_disable() igb_txrx_ring_disable() napi_disable() This NAPI is already disabled, or was never enabled. Would napi_disable_locked() then spin forever with RTNL held? If napi_disable() did return, igb_txrx_ring_enable() would call: - igb_configure_tx_ring(), which memsets the NULL tx_buffer_info - igb_configure_rx_ring(), which writes IGB_RX_DESC(ring, 0) with ring->desc == NULL This is still the case at the end of the series. The pm_runtime_get_sync() added to igb_xdp() later on doesn't help here. After a failed runtime resume it returns an error that is ignored, and it doesn't cover the PCI error path. Would checking test_bit(__IGB_DOWN, &adapter->state) here, as igb_xsk_wakeup() already does, close this? [Severity: High] Can this check race with a runtime resume? The new num_rx_queues test here and the num_tx_queues test in igb_xsk_tx_ring() rely on RTNL. __igb_resume(dev, true) rebuilds the same state without it: - igb_init_interrupt_scheme() runs before the "if (!rpm) rtnl_lock()" - __igb_open() also runs without RTNL when rpm is true igb_set_interrupt_capability() publishes the count: adapter->num_rx_queues = adapter->rss_queues; igb_alloc_q_vectors() only fills adapter->rx_ring[] after that, and the NAPIs are enabled later still, in __igb_open(). Suppose a zero-copy socket is closed while a runtime resume is running on pm_wq. Can this check pass while rx_ring[qid] is still NULL, so that igb_txrx_ring_disable() dereferences rx_ring->reg_idx? Or can it pass while the ring is allocated but its NAPI isn't enabled yet, so that napi_disable() never returns with RTNL held? If so, the "socket is closed while the device is runtime suspended" case from the commit message would still be reachable during the resume itself. The later patch "igb: resume the device before changing XDP or XSK settings" in this series adds pm_runtime_get_sync()/pm_runtime_put() around igb_xdp(). rpm_resume() waits for a resume that is already in progress, so the window is closed at the end of the series. [Severity: High] This isn't a bug introduced by this patch, but the error path right after this hunk seems to leave the queue half torn down: igb_xsk_pool_disable() { ... xsk_pool_dma_unmap(pool, IGB_RX_DMA_ATTR); if (if_running) { err = igb_realloc_rx_buffer_info(rx_ring, false); if (err) return err; igb_txrx_ring_enable(adapter, qid); } ... } Suppose the vmalloc in igb_realloc_rx_buffer_info() fails. By then igb_txrx_ring_disable() has already: - zeroed TXDCTL/RXDCTL - set IGB_RING_FLAG_TX_DISABLED - disabled the Rx NAPI - cleaned both rings None of that is undone. rx_ring->xsk_pool and tx_ring->xsk_pool also stay set. xp_disable_drv_zc() only warns on the error, and xp_release_deferred() goes on to xp_destroy(pool). Would the next igb_down() then spin in napi_disable() on the already-disabled NAPI with RTNL held? When queues aren't paired, can the Tx NAPI, which is still running, reach the freed pool through igb_clean_tx_irq()? xsk_pool = READ_ONCE(tx_ring->xsk_pool); if (xsk_pool) { if (xsk_frames) xsk_tx_completed(xsk_pool, xsk_frames); if (xsk_uses_need_wakeup(xsk_pool)) igb_xsk_pool_enable() has the same pattern. If igb_realloc_rx_buffer_info() fails there, the rings and NAPI disabled by igb_txrx_ring_disable() are never re-enabled. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124235723.1135808-1-antonio%40mandelbit.com