From: netdev-bot+sashiko@kernel.org
To: jmaxwell37@gmail.com
Cc: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
dipayanroy@linux.microsoft.com, ernis@linux.microsoft.com,
longli@microsoft.com, gargaditya@linux.microsoft.com,
hamzamahfooz@linux.microsoft.com, linux-hyperv@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: mana: Clamp the recorded RX queue in mana_select_queue()
Date: Fri, 04 Dec 2026 04:45:51 +0000 [thread overview]
Message-ID: <179635955108.3146.8320191705505135864@kernel.org> (raw)
In-Reply-To: <20261201044330.3046262-1-jmaxwell37@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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 says mana_get_tx_queue() is already bounded
because it "returns an indirection table entry, which is always below…
- [Low] The commit message's explanation of the trigger does not match
the current tree.
--
net: mana: Clamp the recorded RX queue in mana_select_queue()
This commit wraps the recorded RX queue returned by mana_select_queue()
into the range of real_num_tx_queues with a modulo. Forwarded skbs that
carry a queue index from a device with more queues then no longer trigger
the netdev_cap_txqueue() warning. It also reads real_num_tx_queues once
with READ_ONCE().
> This is easy to hit on Azure when container traffic is forwarded out of
> a MANA VF: veth sizes its queues with num_possible_cpus(), while mana
> sizes them with num_online_cpus(). On a guest with more possible than
> online CPUs the veth devices end up with more queues than the VF, and
> the index chosen on the veth survives into the VF transmit path.
[Severity: Low]
Does this description of the trigger match the current tree?
In veth_init_queues(), the real TX queue count defaults to 1 unless
IFLA_NUM_TX_QUEUES is given:
drivers/net/veth.c:veth_init_queues() {
...
if (!tb[IFLA_NUM_TX_QUEUES] && dev->num_tx_queues > 1) {
err = netif_set_real_num_tx_queues(dev, 1);
...
}
num_possible_cpus() only sets num_tx_queues, which is the maximum. With
one real TX queue, queue_mapping stays at 0. veth never calls
skb_record_rx_queue(), so skb_rx_queue_recorded() is false and
mana_select_queue() takes the mana_get_tx_queue() path. A default container
veth would not seem to hit this.
On the mana side, mana_probe_port() sets:
apc->num_queues = min(gc->max_num_queues_vport, MANA_DEF_NUM_QUEUES);
MANA_DEF_NUM_QUEUES is 16, and num_online_cpus() only caps the maximum.
A port with default settings would not show the quoted "real number of TX
queues is 32" either.
The real trigger looks wider than described. Any forwarded skb whose
queue_mapping - 1 is at or above the MANA port's real_num_tx_queues hits
it, whatever the possible and online CPU counts are. Examples are traffic
from a multi-queue ingress NIC, or from a veth created with numtxqueues or
resized with ethtool -L. The code change covers all of these cases.
Could the commit message be updated to describe the actual trigger
conditions?
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 95bf153c3e1a8..eafba38488e8c 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -684,18 +684,26 @@ static int mana_get_tx_queue(struct net_device *ndev, struct sk_buff *skb,
> static u16 mana_select_queue(struct net_device *ndev, struct sk_buff *skb,
> struct net_device *sb_dev)
> {
> + int num_txq = READ_ONCE(ndev->real_num_tx_queues);
> int txq;
[ ... ]
> - if (txq < 0 || skb->ooo_okay || txq >= ndev->real_num_tx_queues) {
> - if (skb_rx_queue_recorded(skb))
> + if (txq < 0 || skb->ooo_okay || txq >= num_txq) {
> + if (skb_rx_queue_recorded(skb)) {
> + /* The queue was recorded by another device, which may
> + * have many more queues than this port, so wrap it
> + * into range like skb_tx_hash() does.
> + */
> txq = skb_get_rx_queue(skb);
> - else
> + if (unlikely(txq >= num_txq))
> + txq %= num_txq;
> + } else {
> txq = mana_get_tx_queue(ndev, skb, txq);
> + }
> }
>
> return txq;
[Severity: Medium]
Can mana_get_tx_queue() return an index at or above num_txq here?
The commit message says:
mana_get_tx_queue() returns an indirection table entry, which is
always below apc->num_queues.
That does not seem to hold while the channel count is shrinking. Take an
ethtool -L that reduces the queues from 32 to 16:
mana_set_channels()
apc->num_queues = new_count;
mana_attach()
mana_alloc_queues()
netif_set_real_num_tx_queues(ndev, apc->num_queues); /* now 16 */
...
mana_add_rx_queues() / netif_set_real_num_rx_queues()
...
mana_rss_table_init(apc); /* indir_table rewritten for 16 */
mana_detach() only calls netif_tx_disable() and netif_device_detach(). So
__dev_queue_xmit()->netdev_core_pick_tx()->mana_select_queue() can still
run on other CPUs inside this window. Take a skb with no recorded RX queue
and no usable socket mapping. mana_get_tx_queue() would read the old
table:
txq = apc->indir_table[hash & (apc->indir_table_sz - 1)];
This can return 16..31, and mana_select_queue() returns it without a check.
netdev_cap_txqueue() would then print the same "selects TX queue N, but
real number of TX queues is M" warning and move the packet to queue 0. The
value is also cached with sk_tx_queue_set(). That cache does recover,
because the txq >= num_txq check recomputes it later.
mana_alloc_queues() can also fail between netif_set_real_num_tx_queues()
and mana_rss_table_init(). In that case real_num_tx_queues is not rolled
back, but mana_set_channels() restores apc->num_queues:
apc->num_queues = new_count;
err = mana_attach(ndev);
if (err) {
apc->num_queues = old_count;
indir_table can then keep entries above real_num_tx_queues until the next
successful attach.
The patch reads real_num_tx_queues once to cope with concurrent queue
count changes. Would it make sense to bound the final txq against num_txq
on every path? Another option is to rewrite indir_table before
real_num_tx_queues is lowered.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201044330.3046262-1-jmaxwell37%40gmail.com
prev parent reply other threads:[~2026-12-04 4:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 4:43 [PATCH net-next] net: mana: Clamp the recorded RX queue in mana_select_queue() Jon Maxwell
2026-12-04 4:45 ` 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=179635955108.3146.8320191705505135864@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=dipayanroy@linux.microsoft.com \
--cc=edumazet@kernel.org \
--cc=ernis@linux.microsoft.com \
--cc=gargaditya@linux.microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hamzamahfooz@linux.microsoft.com \
--cc=horms@kernel.org \
--cc=jmaxwell37@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wei.liu@kernel.org \
/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