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
Subject: Re: [PATCH net] gve: Move XPS configurations to preserve user settings
Date: Fri, 04 Dec 2026 19:04:25 +0000 [thread overview]
Message-ID: <179641106575.3146.8858224123043442972@kernel.org> (raw)
In-Reply-To: <20261203182305.3688004-1-joshwash@google.com>
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
prev parent reply other threads:[~2026-12-04 19:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179641106575.3146.8858224123043442972@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=amaan.cheval@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=awogbemila@google.com \
--cc=csully@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eugenehlee@google.com \
--cc=hramamurthy@google.com \
--cc=jordanrhee@google.com \
--cc=joshwash@google.com \
--cc=kuba@kernel.org \
--cc=maolson@google.com \
--cc=netdev@vger.kernel.org \
--cc=nktgrg@google.com \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=stable@vger.kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox