Article View: linux.kernel.netdev
Article #26841Re: [PATCH] net/mlx5e: preallocate child PKEY channel_stats at init
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 09:15
Date: Fri, 04 Dec 2026 09:15
148 lines
14128 bytes
14128 bytes
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
Technical Details
Message-ID:
<179637571890.3146.9204848053420820294@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377210-linux-kernel-netdev=dewy.ruReferences:
<axEqaGn--mwLclsc@eaujamesFR0130>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377210-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] net/mlx5e: preallocate child PKEY channel_stats at init Date: Fri, 04 Dec 2026 09:15:18 +0000 Organization: Usenet Network Message-ID: <179637571890.3146.9204848053420820294@kernel.org> References: <axEqaGn--mwLclsc@eaujamesFR0130> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2724760"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:rQW40gPfFGXFd9dxpK4PJP3gDvs= sha256:sMC9s9ah7oAoZ0ZDfGGSGUf/tawsbHGb4VZ7R3yFQ8Q= sha1:3jaHb9Kn/tXmyFd6KCfd8w44ryU= sha256:NM4P0ETrwKMiFj0SrlVtzB3aJMlOiyk6ipYGrqlhZm0= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 4E372117B76; Fri, 4 Dec 2026 12:15:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.639 X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IZax-sswAiOS; Fri, 4 Dec 2026 12:15:40 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377210-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 9F658117B56; Fri, 4 Dec 2026 12:15:30 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 3038828007; Fri, 4 Dec 2026 09:15:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796375726; b=JkUI/sBq4aJxi85cxqni8hwt06+ldK6z4KpJkc+w59uT+kqM8CWlLcXLYcmVfOrLFZBc adeCTT08GskJ7UyYelqU/JCASxrSrEUuaLeq37eUgIzu4P2E0gpONy7QbL5OyDAK1/0tP PyNmM4vSea6u5h10aBIBQAWZhjF2UqPqO1j7GhTOQify1vx67dwm6DPNgk9YLMYbGaA7g ck/EcLERiimRXyuedBjS2H4qAvZhUpiZKtSxKcYwytd/DxVXk9Qbn3vP0P8v4cSVpJdAs BVGZo1ZikEPs0dj89K0e6EL6eIFXkPiaD78JSgAUN8BSSAsnV6yiiNKx0O3Ti6l2aGA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796375726; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=8MQOLoH8csQtr83v5rlKG1EQmag5hQm6MAZQFk0npHg=; b=mexHa8Re7lJsTHcEnk8pkTxhDq+8PnqTIQJOCy3P4LGw4ja32H7myg1AFB8h4RgtLs5C 13kdCWftENohr7/Dcv/BSF1VTO1zDGBJWSeSTWLVXaRXtUI2VqN0OWHKNIz9ou6TNeMkF rQH9sqv7CavcqVCWsHHgfU/DdRsku822eP2BdFpjtQnB/eFSYwiHfnFJkTv2SUC471rsW uPNNquhXRgpifkW8YYJ7Q6me2G0LtrYaZN30JC2HoZmLWI+KPBO3K0kQ88uTXVEhpq7P/ NArXqI5Bh3vx+8TFBOCzbUJNLlCgaj5TKRXqxLHAwvVbH3MrcLiLNgE1+tHSXs8rWUA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="gZB/oprU"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07022606A333; Fri, 4 Dec 2026 09:15:26 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gZB/oprU X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796375720; b=MxysoJKxRqa4BDHk34KHedBWzQlPhnY1fNfsiCmdnSHlzmXoAI8NfiA78dyNgZLbP837 Zc8RZmlYbFBbPOVMTSenc0CX94b0PLXa2JWDnCYFvzL6OeoJuwP2mhQ7/OLCu++vWSmOM lvDaXb5VsOUVW94vUwhyD/G1RIRHPszMDMTm2pHZ0V6lVXW+CH32wrsVrd7KMipxexEGA 2/HZViBhFn/XpbsfXOrRucpvTRu2rmovC1zNcUBwPvHgmunBQJLnvjcbYgENbDOsnGKCW C9oucXxFRzeD7xu9pMqyoCmlEt8qJnyTxwIkq7W/eHko6Na5a3pGjaXBXIYSmc/Z6Kg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796375720; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=8MQOLoH8csQtr83v5rlKG1EQmag5hQm6MAZQFk0npHg=; b=hlrvVJvzNST7vhoqG+GCDk33OIcRqIaZ8mo6bagDCxBUsQySbJZcSrAwcQvNpt9yj0ve NGb5tuz5k+/s4Z72ZGE+/9nsvyrGJPRil0LXqSxowr0LZlMa9SW6dF6nn+AfZytmvZSy4 byoxHXL+UTSh+nlbD8wdJlajtVo2MgpwMiPw8NrnUxUmPUDW6FN6QjBeUYQO5lSE0Jw0j vSV5AwBoXv/R2fYURmMXhT73mrT/srYArCASGNYba6iSF4cO8jGXroeKchIzU4eBEKEbP CY6LoikbDM8jgKgjfz1vsG2UxrtE0yYRx5m0FCY+DEIUWfY0BtZ8Qk+9wfeDuR8rtfw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="gZB/oprU"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2308E606A322; Fri, 4 Dec 2026 09:15:20 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58AEA1F000C2; Fri, 4 Dec 2026 09:15:19 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796375720; bh=8MQOLoH8csQtr83v5rlKG1EQmag5hQm6MAZQFk0npHg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=gZB/oprUfKEm9Hh8bG9THetiVTiRiJDXC22LEZCRdyQ4l2dfrSKn/A6xlClO6UiMJ f6IBGbHERrb6zQdQteliVA6z2H+HnmYs7tBOKpmgf5u0Qaflt1DSVv/5OsuwjldqEx w5gc2BYP22q2639hLT1M7K5QzkJIAjzqglAKNltLkBGrf+lGAEaCE83M52IjbIUyU1 yF7oEK041NyvwvFXZRb1uExkIQ9IqM8K0cQXOc6px1ahtWhGWGDoCWpZob7nQAVjS9 LSAdVhyU/xNTPGrgWDZO5kJiVYhUDXP0A90BM8IxRqv/HvSEnFVlcP0bKUY2eKVXGB hjXHH6wZ6idiA== X-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 X-In-Reply-To: <axEqaGn--mwLclsc@eaujamesFR0130> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list