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=1796411067; b=ri5YLrYf69hWPlAHpnAfODHALd0hmstlSwdpWeyaH2tmzJC+OeoL+cZ7trHCjzwibOfy 4S21L7+5fBOc1+EJ0UYMi/efi5AYTa4TueYZZEBbK0KPE6M5k4NHc1eeowjTKlPIgF0wa TUuetUQpShfYlnANGxDPtk6uTGaDXrv8s9SIgAocC6G3PsuEOe5ICWFm72JM78gI4jf4H JPqq09yDqvcTPIhkbWhCnidTJp3XDKD8RE4DC+c0/2dho3Mwq1BLfDyVVXFBaDOWBKBhc 9dvXEYTEJHN1xWFKoxOYfyVeNRqYiDtSy6qshQs518LiqqUvdp15migxc9XBtS93QAg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796411067; 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=S1U3SLkL8varxw3Qyq4yQWqRwvsninRdPv3WZ+hEHkQ=; b=4yjHaOf+VhzMRfN/p3S7ZMuVnmhgOM4WOi3p+L1SIe2lnMP6uu5bcv2Q4TXVWD4etlZ4 KRY9VgXpvW6hamcbkXqFQCbYfrJ9LgxBvJL4cqQEHXSLQ/VA20DWtZ2licvDVbSEHN3cb F15AEn6mm7AsYui4S/JBlE+LkE7o892WwWw7r8ahpGEggLdGED82Nfk5V+RTTVDeHUTUr vOcP86+20K0sSYgsT/KTdsW9eZiqPxnHRPPzZnCzZgIG4wndd0cQIUoPgIbI5wWX6Zraj se6vahRb4a7YCv/97ur+oWYott5xUYm43Br430Xv6z4L6AE36tSmdZyd/voB3y0nzUA== 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=YDTMnzft; 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 900FF606A32C; Fri, 4 Dec 2026 19:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YDTMnzft Received: by smtp.kernel.org (Postfix) with ESMTPSA id 366C61F00936; Fri, 4 Dec 2026 19:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796411067; bh=S1U3SLkL8varxw3Qyq4yQWqRwvsninRdPv3WZ+hEHkQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=YDTMnzft6S0J6w0YCtsaLN3RaScRR1aAHXC/JBFpAI69kRw8VLZzR18dTauf6Lj8L O3uU9fl7Gg4jVerD3hOo6ngbTjfZxIfqAUZE3VTZwtqswxb9nS+dyqQcyV0+GQ4bb9 QjRweDio07G2QYltezbP6OXaAs3AqQMzeRNXJuY43pXnZ2UdMG0m9D7h1BFzUP1yJ2 QePGKfORvaDPqkYMZ7Jn1FjfJcU9100XJJZrNf79IoGeeo/nmpemAYiDHVOxHK08JU Yjk88VeKQ1HE3JCZ/hANsTc/Z0xut80ibgV9f5IqgSFD+14otLtSdq/6KJEg3CoaWr SqdkCxWJsLQlQ== Subject: Re: [PATCH net] gve: Move XPS configurations to preserve user settings From: netdev-bot+sashiko@kernel.org To: joshwash@google.com Cc: netdev@vger.kernel.org, hramamurthy@google.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, jordanrhee@google.com, willemb@google.com, przemyslaw.kitszel@intel.com, maolson@google.com, nktgrg@google.com, amaan.cheval@gmail.com, awogbemila@google.com, csully@google.com, eugenehlee@google.com, stable@vger.kernel.org Date: Fri, 04 Dec 2026 19:04:25 +0000 Message-ID: <179641106575.3146.8858224123043442972@kernel.org> In-Reply-To: <20261203182305.3688004-1-joshwash@google.com> References: <20261203182305.3688004-1-joshwash@google.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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 4 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 3 · Low: 1 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 commit message presents the XPS change as a refactor: it stores each notify block's IRQ affinity and reuses it for XPS "rather… - [Medium] In gve_adjust_queues() (gve_main.c:1959-1999), if gve_adjust_config() fails after gve_queues_start() has already written… - [Medium] gve_setup_notify_blocks() saves the requested CPU in block->affinity_mask = cpumask_of(cur_cpu) (gve_main.c:627). - [Low] gve: gve_alloc_notify_blocks() omits XPS cleanup when clamping TX queues -- gve: Move XPS configurations to preserve user settings This commit stops gve from re-applying default XPS mappings each time the queues are started, so a soft reset keeps user XPS settings. Default XPS is now set only at probe time and when the TX queue count changes. It also saves each notify block's IRQ affinity mask and reuses it as the default XPS mask. > Store the CPU affinity mask assigned to each notify block in > gve_setup_notify_blocks() and reuse it when configuring XPS rather than > duplicating the CPU affinity calculation logic. [Severity: Medium] Is this only a de-duplication? The formula removed from gve_tx_add_to_block() does not look at the NUMA node: unsigned int active_cpus = min_t(int, priv->num_ntfy_blks / 2, num_online_cpus()); ... netif_set_xps_queue(priv->dev, get_cpu_mask(ntfy_idx % active_cpus), queue_idx); The IRQ affinity in gve_setup_notify_blocks() works differently. It walks gve_get_node_mask(), which returns cpumask_of_node(priv->numa_node), or cpu_all_mask for NUMA_NO_NODE. It wraps at nr_cpu_ids or tx_cfg.max_queues. The two have differed since commit d991666b7b699a ("gve: make IRQ handlers and page allocation NUMA aware"). Take a multi-node guest where the gVNIC's node does not start at CPU 0, for example node 1 = CPUs 48-95. The default TX queues now map to CPUs on that node. CPUs on other nodes lose their default XPS entries and fall back to skb_tx_hash(). Could the commit message mention this change in default TX steering? This patch is also tagged Cc: stable. Trees older than d991666b7b699a do not have gve_get_node_mask() or cur_cpu here, so would a backport need a different approach? > diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c > index 35cf0f06a0f27..074ccbbf449c8 100644 > --- a/drivers/net/ethernet/google/gve/gve_main.c > +++ b/drivers/net/ethernet/google/gve/gve_main.c > @@ -624,8 +624,8 @@ static int gve_setup_notify_blocks(struct gve_priv *priv) > } > block->irq = priv->msix_vectors[msix_idx].vector; > block->irq_requested = true; > - irq_set_affinity_and_hint(block->irq, > - cpumask_of(cur_cpu)); > + block->affinity_mask = cpumask_of(cur_cpu); > + irq_set_affinity_and_hint(block->irq, block->affinity_mask); [Severity: Medium] Can block->affinity_mask name an offline CPU here? When priv->numa_node is NUMA_NO_NODE, gve_get_node_mask() returns cpu_all_mask. cur_cpu then wraps only on this condition: if (cur_cpu >= nr_cpu_ids || (i + 1) == priv->tx_cfg.max_queues) tx_cfg.max_queues comes from the MSI-X vector count, not the CPU count. Suppose nr_cpu_ids is larger than the online count (hot-pluggable vCPU slots) and there are more TX queues than online CPUs. Some blocks then get a CPU that is possible but offline. In that case irq_set_affinity_and_hint() fails with -EINVAL. The return value is ignored, but the mask is still saved. Later, gve_set_xps_mapping() passes this mask to netif_set_xps_queue(). __netif_set_xps_queue() only adds entries for CPUs in mask & cpu_online_mask, so those queues get no XPS entry at all. The removed formula, ntfy_idx % min(num_ntfy_blks / 2, num_online_cpus()), stayed within the online CPU count and was re-applied on every open. XPS is now set only at probe and on queue count changes. Does anything correct the mapping once that CPU comes online, or on the next open or reset? > > cur_cpu = cpumask_next(cur_cpu, node_mask); > /* Wrap once CPUs in the node have been exhausted, or when [ ... ] > @@ -1942,6 +1963,7 @@ int gve_adjust_queues(struct gve_priv *priv, > { > struct gve_tx_alloc_rings_cfg tx_alloc_cfg = {0}; > struct gve_rx_alloc_rings_cfg rx_alloc_cfg = {0}; > + u16 old_num_tx = priv->tx_cfg.num_queues; > int err; > > gve_get_curr_alloc_cfgs(priv, &tx_alloc_cfg, &rx_alloc_cfg); > @@ -1954,7 +1976,10 @@ int gve_adjust_queues(struct gve_priv *priv, > > if (netif_running(priv->dev)) { > err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg); > - return err; > + if (err) > + return err; [Severity: Medium] What happens to the XPS mappings for newly added TX queues if gve_adjust_config() fails after gve_queues_start() has already committed the new config? gve_queues_start() writes the new config first and only then runs steps that can fail: priv->tx_cfg = *tx_alloc_cfg->qcfg; ... err = netif_set_real_num_rx_queues(dev, priv->rx_cfg.num_queues); if (err) goto stop_rings; err = gve_reg_xdp_info(priv, dev); if (err) goto stop_rings; ... err = gve_register_qpls(priv); if (err) goto reset; On the reset path, gve_reset() can also return the error from gve_recover(). For example, grow from 4 to 8 TX queues while the interface is running: - priv->tx_cfg.num_queues becomes 8. - A later step fails. - This early return skips config_xps. Queues 4..7 then never get a default XPS mapping. Before this patch, the next gve_open() or reset rebuilt XPS through gve_tx_add_to_block(), but that call is now removed. A later gve_adjust_queues() reads old_num_tx from the already-updated priv->tx_cfg.num_queues (8). So this loop in gve_set_xps_mapping() does not cover queues 4..7 either: for (i = old_num_tx; i < new_num_tx; i++) { Would these queues stay unmapped until the queue count is shrunk and grown again? Shrinking looks fine, since netif_set_real_num_tx_queues() resets XPS for the removed queues itself. > + > + goto config_xps; > } [ ... ] > @@ -1965,6 +1990,11 @@ int gve_adjust_queues(struct gve_priv *priv, > priv->tx_cfg = new_tx_config; > priv->rx_cfg = new_rx_config; > > +config_xps: > + /* Update default XPS mappings for added or removed TX queues > + * while preserving custom XPS mappings of existing TX queues. > + */ > + gve_set_xps_mapping(priv, old_num_tx, priv->tx_cfg.num_queues); > return 0; > } > [Severity: Low] Does gve_alloc_notify_blocks() need to clear XPS for the queues it drops when it clamps the TX queue count? With this patch, gve_adjust_queues() installs default XPS entries for new TX queues even while the interface is down. At that point dev->real_num_tx_queues has not been raised yet. __netif_set_xps_queue() only checks the index against dev->num_tx_queues, so those entries go straight into dev->xps_maps[XPS_CPUS]. Consider this sequence with max_tx_queues of 8: - The interface is opened with 4 TX queues, so real_num_tx_queues is 4. It is then brought down. - ethtool -L raises TX to 8 while down. gve_set_xps_mapping(priv, 4, 8) maps queues 4..7. - Before the next open, a reset (gve_handle_reset()) or gve_resume() runs gve_setup_device() -> gve_alloc_notify_blocks(). If pci_enable_msix_range() returns fewer vectors, this clamps the count: if (priv->tx_cfg.num_queues > priv->tx_cfg.max_queues) priv->tx_cfg.num_queues = priv->tx_cfg.max_queues; Nothing clears the XPS entries for the queues dropped here. - On the next gve_open(), gve_queues_start() calls netif_set_real_num_tx_queues() with the clamped count. That only calls netif_reset_xps_queues_gt() when txq < dev->real_num_tx_queues, which is false because real_num_tx_queues is still 4. The stale queue indices then stay in the CPU maps. They cannot be seen or cleared through sysfs, because tx-N kobjects only exist below real_num_tx_queues. __get_xps_queue_idx() rejects these indices, so there is no out-of-bounds transmit. But on any CPU whose map also holds an active queue, some flows hash onto the stale index and fall back to skb_tx_hash(). That happens when cur_cpu wrapped in gve_setup_notify_blocks(), or when a user mask overlaps a dropped queue's CPU. The preconditions are unusual. Still, should gve_alloc_notify_blocks() call gve_set_xps_mapping() for the queues it drops? Or would it be simpler to defer the offline XPS setup until the queues are actually started? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203182305.3688004-1-joshwash%40google.com