From: Dragos Tatulea <dtatulea@nvidia.com>
To: Etienne AUJAMES <eaujames@ddn.com>
Cc: Tariq Toukan <tariqt@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>, Mark Bloch <mbloch@nvidia.com>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
Feng Liu <feliu@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
COURRIER Guillaume <guillaume.courrier@cea.fr>
Subject: Re: [PATCH net] net/mlx5e: guard child PKEY channel stats lookup in rx path
Date: Thu, 3 Dec 2026 12:00:12 +0100 [thread overview]
Message-ID: <21cbd341-c84b-450a-84f8-52d5e7052a7e@nvidia.com> (raw)
In-Reply-To: <awnovA2_GjB8ETZR@eaujamesFR0130>
Hi,
I only realize that I missed your reply when you sent the v2.
On 27.11.26 21:31, Etienne AUJAMES wrote:
> On 27/11/26, Dragos Tatulea wrote:
>> On 27.11.26 12:03, Etienne AUJAMES wrote:
>>> Can you confirm that the parent channel count cannot be resized while
>>> a sub-interface is present (whether UP or DOWN)?"
>>>
>> True. I had forgotten about this change. However, it is still possible to have
>> a parent created with > 128 channels and the pkeys created afterwards. And then
>> you can run into the issue again...
>
> I am not sure to understand.
> Are you referring to the following commit?
>
> commit dbc94a0fb81771a38733c0e8f2ea8c4fa6934dc1
> Author: Dragos Tatulea <dtatulea@nvidia.com>
> Date: Thu Dec 8 09:52:54 2022 +0200
>
> IB/IPoIB: Fix queue count inconsistency for PKEY child interfaces
>
> There are 2 ways to create IPoIB PKEY child interfaces:
> 1) Writing a PKEY to /sys/class/net/<ib parent interface>/create_child.
> 2) Using netlink with iproute.
> ...
> This change adds the get_num_tx/rx_queues() ops which allows for
> interfaces with multiple queues to be created over netlink. This
> constant only represents the max number of tx and rx queues on that
> net device.
>
> +static unsigned int ipoib_get_max_num_queues(void)
> +{
> + return min_t(unsigned int, num_possible_cpus(), 128);
> +}
> +
>
> A child interface created via netlink (ip link add link ... type ipoib)
> ends up with min(num_possible_cpus(), 128) RX/TX queues. The parent
> may therefore have more allocated channels than the child, which would
> trigger the same crash in the receive path.
>
> Is there another scenario you had in mind?
>
This is the scenario.
> The following guard should prevent most crash cases:
> 31c70bfe58 ("net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent")
>
> @@ -168,6 +168,15 @@ static int mlx5i_pkey_dev_init(struct net_device *dev)
> return -EINVAL;
> }
>
> + if (dev->num_rx_queues < parent_dev->real_num_rx_queues) {
> + mlx5_core_warn(priv->mdev,
> + "failed to create child device with rx queues [%d] less than parent's [%d]\n",
> +
>
Not completely: you can still create a child with num_rx_queues > 128
but the channel stats array will still be sized based on the 128 max.
> While digging I found a related problem in mlx5e_calc_max_nch(), which
> sizes priv->channel_stats[] (max_nch) for the child:
>
> /* netdev rx queues */
> max_nch = min_t(unsigned int, max_nch, netdev->num_rx_queues);
>
> /* netdev tx queues */
> tmp = netdev->num_tx_queues;
> if (mlx5_qos_is_supported(mdev))
> tmp -= mlx5e_qos_max_leaf_nodes(mdev);
> if (MLX5_CAP_GEN(mdev, ts_cqe_to_dest_cqn))
> tmp -= profile->max_tc;
> tmp = tmp / profile->max_tc;
> max_nch = min_t(unsigned int, max_nch, tmp);
>
> 1/ It subtracts the QoS and PTP TX queues based only on the HW
> capabilities, not on the profile. Commit 1958c2bddfa2 ("net/mlx5e: Add
> profile indications for PTP and QOS HTB features") made the txq
> allocation depend on profile->features, but did not update
> mlx5e_calc_max_nch(). The IPoIB profiles have no .features, so they
> never get these queues.
>
Interesting point for refactoring. But note that IPoIB + QoS / PTP TX is
not a valid combination of features.
> 2/ I am not entiery sure but I think 'tmp' (unsigned int) can underflow
> for the netlink allocation path (if the firmwares return true for
> mlx5_qos_is_supported() and for MLX5_CAP_GEN(mdev, ts_cqe_to_dest_cqn).
>
It could. But max_nch will be used instead. So it doesn't seem to be a
problem to me.
Thanks,
Dragos
next prev parent reply other threads:[~2026-12-03 11:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 18:24 [PATCH net] net/mlx5e: guard child PKEY channel stats lookup in rx path Etienne AUJAMES
2026-11-25 18:27 ` netdev-bot+sinfo
2026-11-25 19:17 ` Etienne AUJAMES
2026-11-26 14:41 ` Dragos Tatulea
2026-11-27 11:03 ` Etienne AUJAMES
2026-11-27 13:56 ` Dragos Tatulea
2026-11-27 20:31 ` Etienne AUJAMES
2026-12-03 11:00 ` Dragos Tatulea [this message]
2026-11-26 18:27 ` netdev-bot+sashiko
2026-12-03 8:38 ` [PATCH] net/mlx5e: preallocate child PKEY channel_stats at init Etienne AUJAMES
2026-12-03 11:10 ` Dragos Tatulea
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=21cbd341-c84b-450a-84f8-52d5e7052a7e@nvidia.com \
--to=dtatulea@nvidia.com \
--cc=davem@davemloft.net \
--cc=eaujames@ddn.com \
--cc=feliu@nvidia.com \
--cc=guillaume.courrier@cea.fr \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.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