From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796373523; b=Ssl2yPi0sENWSdBfDFeEETwvLRvqF9CQsokaFHne0J7blrwvviOkgdEhOob0butV4Hhw PCRi1H0H+5Mnry1VRlryQdnMmxCfRqAp730xFhSvDjM4M6kLd6how1Ta2a3cKVcUnzQqQ s7bKsK+smF1o42C4O1d2uxNASphunmWRtnb24XTe5N1diBga6BLQZ1tAN50VsmIhm7ZtA XQS89S7AP7UjQbcUK/xKWnUVoLcx05h3cvL9kKl6y4gVlRZhkhRKLGRA+aSjhVJ85BRXf QBvaRnl11K21zECf32T73jcyD6tV6uuuS1Y/gaZzplNan0JpM/7lOwUXpQznnJqGMnw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796373523; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=s5lmCS9ztgidURBOklNAO3YH8KqmIYXhUMZ6hhu+Hlk=; b=MYSNT+XpsjI0gf1gIc9LeseRD2XDsOYOXCsUA0fWjhSJNECAlCoLjh5QEsfUM7Wb/dy1 uRm0GuqWlQp28RWrsrMU5FHq9vZTFS48qHwdxoLI311kK8XPi3+ec9QYPD0LWA/aI5QDw FIalxPq2lgxNA9lbrFoyCg9KQEP+dWJ41/V4UDr2DODneP8eQUwNe+4TtnXLRakl/B12A 1k8XtPQolm5mdstad19XCNmSFF7tpqrOQNdrQ18BLA9G4Ur5mU7Gwapa+9U3gPmAi/RET fOK3E5X0pv75gnw1GsQhjmRegUwoi/Q2gHP9qI29LXa3sORVAA/sX93I03oTtFtEZOw== 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=DKI7Ckp+; arc=none smtp.remote-ip=100.103.45.18 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 088BE606A330 for ; Fri, 4 Dec 2026 08:38:42 +0000 (UTC) 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=DKI7Ckp+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE37F1F000CE; Fri, 4 Dec 2026 08:38:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796373522; bh=s5lmCS9ztgidURBOklNAO3YH8KqmIYXhUMZ6hhu+Hlk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=DKI7Ckp+gGqt1AUNwOFkFP5l5vjpzOADIysvk6JwN+3/qfZg9DC09fqBg9B4AFkQq sHHrniESJyFj1+Y69Rj3yfpB5M0Eek+bDlj8aaeJqV2xTvZuEu63sjl+zDlvX3TAfZ DE02+R1aCTimEDAt8IfRIcRJZh7rp3UBeyO0lRLuXeVagrr1vc6UJh9b57YtZgFlso 9ZH/fz3VT41g+28d7ti4qk+fs4RjyHR9i4Dd8kQoXYo1HsaHgwUYoLP5N6VJ5Tc0yK ael6VI91l/9bIiJfacBNGL3FPjpXOb5fGciWcS+tHpNhvIKNb1fPDxZdZbJ4eNXNRY xufj++RfMnqeQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] net/mlx5e: preallocate child PKEY channel_stats at init Reply-To: sashiko-reviews@lists.linux.dev To: "Etienne AUJAMES" Cc: linux-rdma@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 08:38:42 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] net/mlx5e: mlx5i_pkey_dev_init() breaks default RTNL IPoIB child creation - [Medium] net/mlx5e: mlx5e_calc_max_nch() ignores profile features and underflows - [Low] net/mlx5e: data race reading parent num_channels in mlx5i_pkey_dev_init() -- commit 44014ff5da47d2578d00e45f3df8f44769c480ac Author: Etienne AUJAMES net/mlx5e: preallocate child PKEY channel_stats at init This commit preallocates child PKEY channel_stats entries in mlx5i_pkey_dev_init() for the parent's channel count so packets received on the parent NAPI before mlx5i_pkey_open() do not dereference a NULL pointer. It also replaces the child num_rx_queues check with a check that priv->max_nch is at least the parent's params.num_channels. > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c b= /drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c > index 5edc392475251..577981ae5ecfd 100644 > --- 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 *d= ev) > return -EINVAL; > } > =20 > - if (dev->num_rx_queues < parent_dev->real_num_rx_queues) { > + parent_priv =3D mlx5i_epriv(parent_dev); > + nch =3D parent_priv->channels.params.num_channels; [Severity: Low] Is this read of parent_priv->channels.params.num_channels subject to a data race with mlx5i_set_coalesce()? mlx5i_pkey_dev_init() runs under rtnl_lock() without holding netdev_lock(parent_dev) or parent_priv->state_lock. Because mlx5i_init() sets netdev->request_ops_lock =3D true and mlx5i_ethtool_ops.op_needs_rtnl omits ETHTOOL_OP_NEEDS_RTNL_SCOALESCE, ethtool -C on the parent runs without rtnl_lock(): CPU0 CPU1 mlx5i_pkey_dev_init() mlx5i_set_coalesce() /* rtnl_lock() held */ /* netdev_lock(parent_dev) held */ mutex_lock(&parent_priv->state_lock) mlx5e_switch_priv_params() nch =3D parent_priv->channels .params.num_channels; priv->channels.params =3D *new_para= ms; <-- data race Because struct mlx5e_params is larger than 8 bytes, the struct assignment compiles to a memcpy that KCSAN reports as a data race even though num_channels does not change. Holding parent_priv->state_lock around the read would serialize it with mlx5e_switch_priv_params(). > + if (priv->max_nch < nch) { > mlx5_core_warn(priv->mdev, > - "failed to create child device with rx queues [%d] less than p= arent's [%d]\n", > - dev->num_rx_queues, > - parent_dev->real_num_rx_queues); > + "failed to create child device with max channel count [%d] les= s than parent's [%d]\n", > + priv->max_nch, nch); > mlx5i_parent_put(dev); > return -EINVAL; > } [Severity: High] Does replacing the num_rx_queues check with priv->max_nch < nch break default netlink creation of IPoIB PKEY child interfaces? When a child is created with default queue counts (ip link add link name type ipoib pkey ), ipoib_get_max_num_queues() sets both num_tx_queues and num_rx_queues to min(num_possible_cpus(), 128), which matches the parent's default num_channels with no extra TX queue headroom. During mlx5e_priv_init(), mlx5e_calc_max_nch() unconditionally subtracts profile->max_tc when MLX5_CAP_GEN(mdev, ts_cqe_to_dest_cqn) is set (and mlx5e_qos_max_leaf_nodes(mdev) when QoS is supported), even though mlx5i_pkey_nic_profile supports neither PTP_TX nor QOS_HTB. Because the parent allocates 8 * nch TX queues in mlx5_rdma_rn_get_params(), the parent's max_nch is unaffected while the child's priv->max_nch drops to at most nch - 1. This regression causes default RTNL child creation to fail with -EINVAL on ConnectX HCAs advertising ts_cqe_to_dest_cqn. [Severity: Medium] Can mlx5e_calc_max_nch() also underflow tmp or reduce priv->max_nch to 0 for profiles that do not enable QOS_HTB or PTP_TX? drivers/net/ethernet/mellanox/mlx5/core/en_main.c:mlx5e_calc_max_nch() { ... tmp =3D netdev->num_tx_queues; if (mlx5_qos_is_supported(mdev)) tmp -=3D mlx5e_qos_max_leaf_nodes(mdev); if (MLX5_CAP_GEN(mdev, ts_cqe_to_dest_cqn)) tmp -=3D profile->max_tc; tmp =3D tmp / profile->max_tc; max_nch =3D min_t(unsigned int, max_nch, tmp); ... } Unlike mlx5e_get_max_num_txqs(), which gates both reservations on mlx5e_profile_feature_cap(profile, QOS_HTB) and PTP_TX, these unchecked unsigned subtractions wrap tmp near UINT_MAX when netdev->num_tx_queues is smaller than the subtracted reserve (for example, a default RTNL child with at most 128 queues when mlx5e_qos_max_leaf_nodes(mdev) is 256), bypassing the TX queue cap. When num_tx_queues equals the subtracted reserve, priv->max_nch becomes 0 and mlx5e_attach_netdev() fails in netif_set_real_num_rx_queues() with -EINVAL. Gating these subtractions on mlx5e_profile_feature_cap() to match mlx5e_get_max_num_txqs() and clamping against unsigned underflow would avoid both the spurious reduction and the wraparound. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/axEqaGn--mwLclsc@ea= ujamesFR0130?part=3D1