* [PATCH net] gve: Move XPS configurations to preserve user settings
@ 2026-12-03 18:23 Joshua Washington
2026-12-04 19:04 ` netdev-bot+sashiko
0 siblings, 1 reply; 2+ messages in thread
From: Joshua Washington @ 2026-12-03 18:23 UTC (permalink / raw)
To: netdev
Cc: Joshua Washington, Harshitha Ramamurthy, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Jordan Rhee, Willem de Bruijn, Przemek Kitszel, Matt Olson,
Ankit Garg, Amaan Cheval, David Awogbemila, Catherine Sullivan,
Eugene Lee, stable
From: Eugene Lee <eugenehlee@google.com>
User XPS settings are lost when the GVE driver performs a soft reset
because the driver overrides the user XPS settings with the default
mappings.
Remove default XPS configuration when the driver performs a soft reset
and configure default XPS mappings only during driver initialization and
when the TX queue count is adjusted.
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.
This issue was hit on GCE VMs when modifying queue counts or ring
parameters with custom XPS mappings, and the fix was tested on GCE gVNIC
VMs using both GQI and DQO queue formats.
Fixes: 4edf8249bcd1 ("gve: Add netif_set_xps_queue call")
Cc: stable@vger.kernel.org
Reviewed-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Eugene Lee <eugenehlee@google.com>
Signed-off-by: Joshua Washington <joshwash@google.com>
---
drivers/net/ethernet/google/gve/gve.h | 1 +
drivers/net/ethernet/google/gve/gve_main.c | 42 +++++++++++++++++++--
drivers/net/ethernet/google/gve/gve_utils.c | 4 --
3 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
index 143d8cd595aa..6180434d5776 100644
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -673,6 +673,7 @@ struct gve_notify_block {
struct gve_priv *priv;
struct gve_tx_ring *tx; /* tx rings on this block */
struct gve_rx_ring *rx; /* rx rings on this block */
+ const struct cpumask *affinity_mask;
u32 irq;
bool irq_requested;
};
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 35cf0f06a0f2..074ccbbf449c 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);
cur_cpu = cpumask_next(cur_cpu, node_mask);
/* Wrap once CPUs in the node have been exhausted, or when
@@ -1935,6 +1935,27 @@ int gve_adjust_config(struct gve_priv *priv,
return 0;
}
+static void gve_set_xps_mapping(struct gve_priv *priv, int old_num_tx,
+ int new_num_tx)
+{
+ struct gve_notify_block *block;
+ int ntfy_idx;
+ int i;
+
+ /* Clear XPS mappings for removed queues in case the queue count was
+ * reduced while the interface is down.
+ */
+ for (i = new_num_tx; i < old_num_tx; i++)
+ netif_set_xps_queue(priv->dev, cpu_none_mask, i);
+
+ for (i = old_num_tx; i < new_num_tx; i++) {
+ ntfy_idx = gve_tx_idx_to_ntfy(priv, i);
+ block = &priv->ntfy_blocks[ntfy_idx];
+
+ netif_set_xps_queue(priv->dev, block->affinity_mask, i);
+ }
+}
+
int gve_adjust_queues(struct gve_priv *priv,
struct gve_rx_queue_config new_rx_config,
struct gve_tx_queue_config new_tx_config,
@@ -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;
+
+ goto config_xps;
}
/* Set the config for the next up. */
if (reset_rss) {
@@ -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;
}
@@ -3085,9 +3115,10 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!gve_is_gqi(priv) && !gve_is_qpl(priv))
dev->netmem_tx = NETMEM_TX_DMA;
+ gve_set_xps_mapping(priv, 0, priv->tx_cfg.num_queues);
err = register_netdev(dev);
if (err)
- goto abort_teardown_device;
+ goto abort_clear_xps;
dev_info(&pdev->dev, "GVE version %s\n", gve_version_str);
dev_info(&pdev->dev, "GVE queue format %d\n", (int)priv->queue_format);
@@ -3095,6 +3126,9 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
queue_work(priv->gve_wq, &priv->service_task);
return 0;
+abort_clear_xps:
+ gve_set_xps_mapping(priv, priv->tx_cfg.num_queues, 0);
+
abort_teardown_device:
disable_work_sync(&priv->service_task);
gve_teardown_device(priv);
diff --git a/drivers/net/ethernet/google/gve/gve_utils.c b/drivers/net/ethernet/google/gve/gve_utils.c
index 930555ac8fe9..2750c8c18fbe 100644
--- a/drivers/net/ethernet/google/gve/gve_utils.c
+++ b/drivers/net/ethernet/google/gve/gve_utils.c
@@ -26,16 +26,12 @@ void gve_tx_remove_from_block(struct gve_priv *priv, int queue_idx)
void gve_tx_add_to_block(struct gve_priv *priv, int queue_idx)
{
- unsigned int active_cpus = min_t(int, priv->num_ntfy_blks / 2,
- num_online_cpus());
int ntfy_idx = gve_tx_idx_to_ntfy(priv, queue_idx);
struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
struct gve_tx_ring *tx = &priv->tx[queue_idx];
block->tx = tx;
tx->ntfy_id = ntfy_idx;
- netif_set_xps_queue(priv->dev, get_cpu_mask(ntfy_idx % active_cpus),
- queue_idx);
}
bool gve_rx_was_added_to_block(struct gve_priv *priv, int queue_idx)
base-commit: c1c39137dcc3134010566ff29a81c93124efa539
--
2.56.1.915.g69d5ec7298-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] gve: Move XPS configurations to preserve user settings
2026-12-03 18:23 [PATCH net] gve: Move XPS configurations to preserve user settings Joshua Washington
@ 2026-12-04 19:04 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 19:04 UTC (permalink / raw)
To: joshwash
Cc: netdev, hramamurthy, andrew+netdev, davem, edumazet, kuba, pabeni,
jordanrhee, willemb, przemyslaw.kitszel, maolson, nktgrg,
amaan.cheval, awogbemila, csully, eugenehlee, stable
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 19:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 18:23 [PATCH net] gve: Move XPS configurations to preserve user settings Joshua Washington
2026-12-04 19:04 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox