From: netdev-bot+sashiko@kernel.org
To: eaujames@ddn.com
Cc: tariqt@nvidia.com, saeedm@nvidia.com, leon@kernel.org,
dtatulea@nvidia.com, mbloch@nvidia.com, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, feliu@nvidia.com,
davem@davemloft.net, guillaume.courrier@cea.fr,
jean-francois.lassignardie@bull.com, kuba@kernel.org
Subject: Re: [PATCH] net/mlx5e: preallocate child PKEY channel_stats at init
Date: Fri, 04 Dec 2026 09:15:18 +0000 [thread overview]
Message-ID: <179637571890.3146.9204848053420820294@kernel.org> (raw)
In-Reply-To: <axEqaGn--mwLclsc@eaujamesFR0130>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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).
- [High] net/mlx5e: mlx5i_pkey_dev_init() breaks default RTNL IPoIB child
creation
- [Low] The commit message describes the bug only as a startup race: the
child QPN is attached by mlx5_fs_add_rx_underlay_qpn() in…
--
net/mlx5e: preallocate child PKEY channel_stats at init
This commit preallocates the child PKEY interface's channel_stats[]
entries in mlx5i_pkey_dev_init(), sized to the parent's channel count,
before the child's QPN is added to the hash table. It also replaces the
num_rx_queues check with a check that the child's max_nch is not lower
than the parent's params.num_channels.
> mlx5i_complete_rx_cqe() uses the parent's rq->ix to index the child PKEY
> priv's channel_stats[]. The child's entries are allocated lazily in
> mlx5e_open_channels(), called from mlx5i_pkey_open(). Once the QPN is
> attached by mlx5_fs_add_rx_underlay_qpn(), the parent's NAPI can receive
> packets for the child before its channel_stats entries exist, and
> dereferences a NULL pointer.
[Severity: Low]
This isn't a bug, but does the commit message describe only part of what
the patch fixes? It explains a startup race. There also seems to be a
second case that is deterministic.
In drivers/net/ethernet/mellanox/mlx5/core/en_main.c,
mlx5e_build_nic_params() sets the child's channel count once:
params->num_channels = min_t(unsigned int, MLX5E_MAX_NUM_CHANNELS / 2,
priv->max_nch);
mlx5i_pkey_ethtool_ops has no .set_channels, so the child never goes
above 128 channels.
The parent can still be raised above 128 with ethtool -L, through
mlx5i_set_channels()->mlx5e_ethtool_set_channels(). This is allowed
while it has no sub-interfaces, on hosts with more than 128 completion
vectors.
A child created after that only allocates channel_stats[0..127], through
mlx5e_open_channel()->mlx5e_channel_stats_alloc(). The child QPN is
steered through the parent's RSS, so mlx5i_complete_rx_cqe() in en_rx.c
would run:
stats = &priv->channel_stats[rq->ix]->rq;
For any parent rq->ix >= 128 that entry is NULL. The dereference happens
on every such packet, not only during startup.
The old check, dev->num_rx_queues < parent_dev->real_num_rx_queues, did
not catch this. The child's num_rx_queues is the device maximum from
mlx5e_get_max_num_channels(), not its real channel count.
The new mlx5e_channel_stats_prealloc(priv, nch) call in
mlx5i_pkey_dev_init() uses the parent's params.num_channels, so it fixes
this case too.
Could the commit message also describe this case, so that it can be
matched against crash reports and assessed for stable backports?
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
> --- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c
> @@ -172,15 +174,22 @@ static int mlx5i_pkey_dev_init(struct net_device *dev)
> return -EINVAL;
> }
>
> - if (dev->num_rx_queues < parent_dev->real_num_rx_queues) {
> + parent_priv = mlx5i_epriv(parent_dev);
> + nch = parent_priv->channels.params.num_channels;
> + if (priv->max_nch < nch) {
> mlx5_core_warn(priv->mdev,
> - "failed to create child device with rx queues [%d] less than parent's [%d]\n",
> - dev->num_rx_queues,
> - parent_dev->real_num_rx_queues);
> + "failed to create child device with max channel count [%d] less than parent's [%d]\n",
> + priv->max_nch, nch);
> mlx5i_parent_put(dev);
> return -EINVAL;
> }
>
> + err = mlx5e_channel_stats_prealloc(priv, nch);
> + if (err) {
> + mlx5i_parent_put(dev);
> + return err;
> + }
> +
> /* Get QPN to netdevice hash table from parent */
> parent_ipriv = netdev_priv(parent_dev);
> ipriv->qpn_htbl = parent_ipriv->qpn_htbl;
[Severity: High]
Does this new check reject child creation through the default netlink
path on common ConnectX parts?
For ip link add ... type ipoib pkey ..., rtnl_create_link() sizes the
child through ipoib_link_ops. ipoib_get_max_num_queues() returns
min(num_possible_cpus(), 128) for both num_tx_queues and
num_rx_queues, so the child gets no extra tx queue headroom.
The parent is allocated through mlx5_rdma_rn_get_params() with
txqs = nch * MLX5_MAX_NUM_TC, so its tx queue count does not trim its
max_nch. mlx5e_build_nic_params() then gives it
num_channels = min(128, max_nch). When the host has at least as many
completion vectors as CPUs, that equals the child's queue count.
For the child, mlx5e_calc_max_nch() starts from netdev->num_tx_queues.
It subtracts mlx5e_qos_max_leaf_nodes() when mlx5_qos_is_supported()
is true, and profile->max_tc when ts_cqe_to_dest_cqn is set.
Unlike mlx5e_get_max_num_txqs(), it does not check
mlx5e_profile_feature_cap(profile, QOS_HTB) or PTP_TX.
mlx5i_pkey_nic_profile sets no features at all. On an HCA that
advertises ts_cqe_to_dest_cqn, the child's priv->max_nch therefore
ends up at least one below the parent's params.num_channels.
The old num_rx_queues < real_num_rx_queues comparison passed in that
configuration. With the new priv->max_nch < nch test,
mlx5i_pkey_dev_init() returns -EINVAL and the child cannot be created.
channel_stats[] really is sized by max_nch, so the check itself looks
right. The miscount seems to be in mlx5e_calc_max_nch(). Should that
function gate the QoS and PTP subtractions on the profile features, as
mlx5e_get_max_num_txqs() does, as part of this fix? It may also want a
guard against the unsigned tmp underflowing when the leaf node count
exceeds num_tx_queues.
Was this tested with ip link add, using default queue counts, on a
ConnectX-5 or later?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/axEqaGn--mwLclsc%40eaujamesFR0130
prev parent reply other threads:[~2026-12-04 9:15 UTC|newest]
Thread overview: 12+ 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
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
2026-12-04 9:15 ` 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=179637571890.3146.9204848053420820294@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=eaujames@ddn.com \
--cc=feliu@nvidia.com \
--cc=guillaume.courrier@cea.fr \
--cc=jean-francois.lassignardie@bull.com \
--cc=kuba@kernel.org \
--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