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=1796428036; b=4NOlmmzySO4NgJDuvQvke+5L63HRIQ21VycW/G/TR+Masx8Mvoh5TEREB3uAFjYdeMkT JMfiNpGUPYqHHwr7HuoRwGvfCSN7Az+Cyna4sLoWX8CuvqV9b1RfY0z/v8r1TTuwEmSm4 oBcTDdGgljbzJtLmWJzGequwIUGZx6HmznFeFmHXfLdnzF21id2aMlu6R4Y9w1ETAS4qq gBKLB7xkaLI5pQkbQRFLL0VeDE1IP4rwjxHHE4T05BxVHdJyG0OvghKoE3tCBUm0M4Nbh qYmm49K0rruiPRbq5PWUCiiIvQ4J7e5+QvuYM3/qJdy06ad/K5GM8BMgDHJbagY5CEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796428036; 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=pKHrwfJcvE78yZYGYSRgkVuTzSox/roeIpZeTNUkP7Y=; b=2Urf0XeUKfaALu6g82NC1/CMf1bahhGSY9CcBOeAh4FKbACI7XH871AGmhLh3fkkj8F3 VII1v2vMkIYas3keMr/L7CPYMih8DUr48dPLvffxlsYaH3ch19qINeNzObaYA6wiFa4cH /0EBQsokNv6qS3zVAAZRraX5K4sQnPy9gFFZAgszBg68i+sRpP/f6W0saPVkYw4bshEmB bm+rQ1oIhkKBtz4sBSCB6VeaWJznw6qE9HZkI4YjjpVmpBiIxTXJDJUPkdwxvkB8ygdS2 epIrzfdDfekN3oOZDo1OahnHWw4b0eOvV1vW8fyMeighWJt13CEq0sGrk8SqxQhT4cg== 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="Y/eClI/x"; 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 03E19606A32C; Fri, 4 Dec 2026 23:47:15 +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=Y/eClI/x Received: by smtp.kernel.org (Postfix) with ESMTPSA id A33621F00936; Fri, 4 Dec 2026 23:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796428035; bh=pKHrwfJcvE78yZYGYSRgkVuTzSox/roeIpZeTNUkP7Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Y/eClI/xRMn3lDgCZtcqvqFhpKFcKy7bL8gPrz1XFRWNV4bHDAVG+2WG2hoidVyww QvPCBJFdR8rm7xRWD6WSD58NaBZFunOKcw58WJx1aNFutGwndUUtRzovZ4wKuj7nHr BXpyz9llBujb5uvsxkSQq4gA6iQWNBx+2FlkbhpH6WvEWRlue130ZXjAK7A322kgjs f43UkE8hQS7mNCwiKOmlSYr/WVWHg6v6GRtF00vO1u1FnlOodfGC+rMmwUywtcBTib LnUvzfurdLaA84dP3UnllmwPlMUDhBvQXNlcvdYStKPFrfIRrLyUDqyydjIHF4cO5A SONv0vnf8Nacg== Subject: Re: [PATCH net v2] i40e: stop XSK queue pairs in VSI shutdown order From: netdev-bot+sashiko@kernel.org To: matt@boondocker.io Cc: 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, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org Date: Fri, 04 Dec 2026 23:47:14 +0000 Message-ID: <179642803419.3146.8192971095663256302@kernel.org> In-Reply-To: <20261203-b4-i40e-xsk-queue-order-v2-1-e14b712d5fc2@boondocker.io> References: <20261203-b4-i40e-xsk-queue-order-v2-1-e14b712d5fc2@boondocker.io> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: bpf@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 5 potential issue(s) to consider. Critical: 0 · High: 1 (1) · Medium: 1 · Low: 3 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] If a queue-pair disable times out, the error path still frees buffers the device may own and leaves the PF stuck in… - [Medium] i40e: i40e_pf_txq_wait() 20 ms timeout multiplies sequentially across VFs - [Low] The patch changes timing for every caller of the shared helper i40e_pf_txq_wait(), but the commit message only describes the AF_XDP… - [Low] In the rewritten enable branch of i40e_queue_pair_toggle_rings(), an Rx enable timeout is now silent. - [Low] The concern is that the kernel-doc of i40e_pf_txq_wait() ("Returns -ETIMEDOUT in case of failing to reach the requested state… Pre-existing issues: - [High] The per-queue-pair disable path never stops the netdev Tx subqueue before tearing down the regular Tx ring. -- i40e: stop XSK queue pairs in VSI shutdown order This commit makes the i40e per-queue-pair disable path follow the whole-VSI shutdown sequence, and on enable it brings Rx up before Tx. It also converts i40e_pf_txq_wait() to read_poll_timeout() with a 1ms enable deadline and a 20ms disable deadline. The per-queue disabled wait moves into a new helper, i40e_queue_pair_wait_queues_disabled(). > diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c > index abbc71e815ae3..555eac07e28b8 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_main.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c [ ... ] > @@ -4660,6 +4661,8 @@ static void i40e_netpoll(struct net_device *netdev) > #endif > > #define I40E_QTX_ENA_WAIT_COUNT 50 > +#define I40E_TXQ_ENABLE_TIMEOUT_US 1000 > +#define I40E_TXQ_DISABLE_TIMEOUT_US 20000 > > /** > * i40e_pf_txq_wait - Wait for a PF's Tx queue to be enabled or disabled > @@ -4674,20 +4677,16 @@ static void i40e_netpoll(struct net_device *netdev) > **/ > static int i40e_pf_txq_wait(struct i40e_pf *pf, int pf_q, bool enable) > { > - int i; > u32 tx_reg; > [Severity: Medium] Could the longer disable deadline turn into a multi-second stall on SR-IOV setups? i40e_reset_all_vfs() walks every VF up to pf->num_alloc_vfs and calls i40e_vsi_wait_queues_disabled() for each VF VSI. It ignores the return value. i40e_free_vfs() does the same for VFs without I40E_VF_STATE_INIT set. Neither loop stops on the first -ETIMEDOUT, and neither shares one deadline across VFs. The earlier VPGEN_VFRSTAT wait in i40e_reset_all_vfs() does share one. i40e_pf_wait_queues_disabled() stops on the first error. Before this patch, a Tx queue that never cleared QENA_STAT cost about 100-200us per VSI. With I40E_TXQ_DISABLE_TIMEOUT_US it costs 20ms per VSI. With I40E_MAX_VF_COUNT (128) VFs, that adds up to about 2.56 seconds. A surprise removal or PCIe link loss is enough to hit this. rd32() then returns 0xffffffff, so QENA_STAT reads as set forever and every call runs for the full 20ms. i40e_control_tx_q(), i40e_control_rx_q() and the VFRSTAT loop all finish quickly on such reads. That leaves i40e_pf_txq_wait() as the bottleneck. When lock_acquired is true, i40e_rebuild() keeps rtnl held across i40e_reset_all_vfs(). That covers callers such as i40e_do_reset_safe() and the i40e_io_resume() path, so the whole stall happens under rtnl. Should i40e_pf_txq_wait() give up early on an all-ones read? Or should the VF loops share a single deadline, or stop after the first timeout? Is the 20ms disable deadline needed for VF queues at all, or only for the XSK queue-pair path this patch is fixing? [ ... ] > + /* QENA_STAT stays set until the disable marker leaves the Tx pipe. > + * The pipe can take milliseconds to drain even when the ring is empty. > + */ > + return read_poll_timeout(rd32, tx_reg, > + enable == !!(tx_reg & I40E_QTX_ENA_QENA_STAT_MASK), > + 200, enable ? I40E_TXQ_ENABLE_TIMEOUT_US : > + I40E_TXQ_DISABLE_TIMEOUT_US, false, &pf->hw, > + I40E_QTX_ENA(pf_q)); > } [Severity: Low] i40e_pf_txq_wait() is shared by every Tx queue enable and disable in the driver, not only the AF_XDP queue-pair path. Before this patch both directions waited roughly 100-200us (10 x usleep_range(10, 20)). Now disable waits up to 20ms and enable waits up to 1ms. Callers include i40e_vsi_enable_tx() via i40e_control_wait_tx_q(), i40e_vsi_wait_queues_disabled() from i40e_vsi_stop_rings(), i40e_pf_wait_queues_disabled(), the VF reset paths, and i40e_ctrl_vf_tx_rings() in i40e_virtchnl_pf.c. Could the commit message say that queue control timing changes across the whole driver? Could it also say where the new 1ms enable deadline (I40E_TXQ_ENABLE_TIMEOUT_US) comes from? [ ... ] > @@ -13408,46 +13412,38 @@ static int i40e_queue_pair_toggle_rings(struct i40e_vsi *vsi, int queue_pair, > bool enable) > { > struct i40e_pf *pf = vsi->back; > - int pf_q, ret = 0; > + int xdp_q, pf_q, ret; > + bool has_xdp; > > + has_xdp = i40e_enabled_xdp_vsi(vsi); > pf_q = vsi->base_queue + queue_pair; [ ... ] > + if (!enable) { > + /* Use the same firmware transition as i40e_vsi_stop_rings(). > + * Both TX queues must be announced before RX is stopped. > + */ > + i40e_pre_tx_queue_cfg(&pf->hw, pf_q, false); > + if (has_xdp) > + i40e_pre_tx_queue_cfg(&pf->hw, xdp_q, false); > + i40e_control_rx_q(pf, pf_q, false); > + msleep(I40E_DISABLE_TX_GAP_MSEC); > + wr32(&pf->hw, I40E_QTX_ENA(pf_q), 0); > + if (has_xdp) > + wr32(&pf->hw, I40E_QTX_ENA(xdp_q), 0); [Severity: High] This is a pre-existing issue and was not introduced by this patch. Since the patch rewrites this disable sequence, though: what stops ndo_start_xmit on this queue while the regular Tx ring is torn down? i40e_queue_pair_disable() only disables the IRQ and NAPI. None of i40e_queue_pair_disable(), i40e_queue_pair_toggle_rings(), i40e_xsk_pool_enable() or i40e_xsk_pool_disable() calls netif_tx_stop_queue() or synchronize_net(). In this driver, netif_tx_disable() is only called from i40e_down(). For the regular ring, the cleanup then runs with no synchronization against xmit: drivers/net/ethernet/intel/i40e/i40e_main.c:i40e_queue_pair_clean_rings() { i40e_clean_tx_ring(vsi->tx_rings[queue_pair]); if (i40e_enabled_xdp_vsi(vsi)) { ... synchronize_rcu(); i40e_clean_tx_ring(vsi->xdp_rings[queue_pair]); } ... } i40e_clean_tx_ring() frees every tx_bi skb, clears tx_bi and the descriptor ring with memset(), and resets next_to_use. Meanwhile, i40e_lan_xmit_frame()->i40e_xmit_frame_ring() checks no driver state before doing this: first = &tx_ring->tx_bi[tx_ring->next_to_use]; first->skb = skb; If the cleaner frees that slot, can i40e_tso() or i40e_tx_map() go on to use a freed skb, or can the skb be freed twice? The XDP ring is covered by the __I40E_CONFIG_BUSY check in i40e_xdp_xmit() plus the synchronize_rcu() above. The window is not new either: the old code already had mdelay(50) before cleanup. > [ ... ] > + return i40e_queue_pair_wait_queues_disabled(vsi, pf_q); [Severity: High] What happens when this still returns -ETIMEDOUT? The Tx and XDP Tx deadline is a fixed 20ms (I40E_TXQ_DISABLE_TIMEOUT_US), and i40e_pf_rxq_wait() still polls 10 x usleep_range(10, 20). If the regular Tx queue times out, i40e_queue_pair_wait_queues_disabled() also returns before it polls the XDP Tx and Rx queues. The caller does not make cleanup depend on the result: drivers/net/ethernet/intel/i40e/i40e_main.c:i40e_queue_pair_disable() { err = i40e_enter_busy_conf(vsi); ... err = i40e_queue_pair_toggle_rings(vsi, queue_pair, false /* off */); i40e_clean_rx_ring(vsi->rx_rings[queue_pair]); i40e_queue_pair_clean_rings(vsi, queue_pair); i40e_queue_pair_reset_stats(vsi, queue_pair); return err; } So the ring and XSK buffers are released while QENA_STAT may still be set. __I40E_CONFIG_BUSY is not cleared, and NAPI and the IRQ for the pair stay disabled. i40e_xsk_pool_disable() then returns early: drivers/net/ethernet/intel/i40e/i40e_xsk.c:i40e_xsk_pool_disable() { if (if_running) { err = i40e_queue_pair_disable(vsi, qid); if (err) return err; } clear_bit(qid, vsi->af_xdp_zc_qps); xsk_pool_dma_unmap(pool, I40E_RX_DMA_ATTR); ... } This skips clear_bit(), xsk_pool_dma_unmap() and i40e_queue_pair_enable(). i40e_queue_pair_enable() is the only queue-pair path that clears __I40E_CONFIG_BUSY. i40e_xsk_pool_enable() has the same early return, and it leaves the earlier xsk_pool_dma_map() and set_bit(af_xdp_zc_qps) in place. xp_disable_drv_zc() only WARNs on this error. xp_release_deferred() then frees the UMEM, which the device may still reference. With __I40E_CONFIG_BUSY left set, i40e_watchdog_subtask() and i40e_reset_subtask() bail out. A later MTU change goes through i40e_change_mtu()->i40e_vsi_reinit_locked(), which spins forever while holding rtnl: while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) usleep_range(1000, 2000); The commit message says the status is polled "before cleaning the rings and releasing the AF_XDP pool". Nothing makes the cleanup or the pool release depend on the poll succeeding, though. Could a link partner sending PAUSE or PFC XOFF frames stall the Tx pipe for more than 20ms and reach this path? That would give the same "networking stopped responding" result the commit is trying to fix. > } > > - return ret; > + /* The whole-VSI enable path brings RX up before TX. */ > + i40e_control_rx_q(pf, pf_q, true); > + ret = i40e_pf_rxq_wait(pf, pf_q, true); > + if (ret) > + return ret; [Severity: Low] Is it intended that an Rx enable timeout is now silent here? i40e_pf_rxq_wait() does not log anything. The old code printed "VSI seid %d Rx ring %d %sable timeout" in this case. The whole-VSI path in i40e_vsi_enable_rx() also logs it: dev_info(&pf->pdev->dev, "VSI seid %d Rx ring %d enable timeout\n", vsi->seid, pf_q); Tx enable failures and all disable failures still log. That makes an XSK setsockopt failing here with -ETIMEDOUT the only case that leaves nothing in the kernel log. > + ret = i40e_control_wait_tx_q(vsi->seid, pf, pf_q, false, true); > + if (ret || !has_xdp) > + return ret; > + return i40e_control_wait_tx_q(vsi->seid, pf, xdp_q, true, true); > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-b4-i40e-xsk-queue-order-v2-1-e14b712d5fc2%40boondocker.io