From nobody Mon Jun 8 06:36:13 2026 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9818B403EBA for ; Wed, 3 Jun 2026 07:28:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780471726; cv=none; b=KTIkAbgV0P1DsoqOPWVXVGbEuxlcC75xRCqbP+QL9emTfQamW8Towk4Pt7PinPPVDsb3+r5nVoCpC23gpZ2bpUAO+wvty7PBx56YNZkGZIitL/qOCdHbkuBpxCDzGZ2fmGFEsk8PEeAgDDlqrE/E89clsnZlpYy1vGCZWP5MiPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780471726; c=relaxed/simple; bh=vZOfIEcxw+Fy1HBH6hwkpuijf88E6fq/alp03avT+5s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WQb7Ea2SOkJtepn3wJBuLnOvujxcWz47wJCmOs5NKbaqje3Eo030IqaqUMJi5K6wg2MhISh1VQTtUwRwMuDJTgc3+d3y1s41oIIspVEwzxAo6ezAOPS49HFUVExqQFpHoWMXJfaqbgmrb7zQNZL+aSlK83eR3b+qCbK/IlgsCXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=btgvpoP/; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="btgvpoP/" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780471722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cGWYtXhrZv46AL1Ad6j8BtWNTA7mBnidxEXk+Mph1lY=; b=btgvpoP/52SIHLi2S3tYnry3XCFl3lxirO/81WgmLgvurS2xp8AUyrwtJIBWMGLmHisNo2 HDns5Y8pmvKE5fthZXUkLfUhUZJAeE6zOSoWQRs06JJZWMVvOGfQC/92+yL2YLLfygQjcl 8SJmaQ4DeIE0+b55OmxkDtxR5XsqBgk= From: Fushuai Wang To: saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shayd@nvidia.com, parav@nvidia.com, moshe@nvidia.com Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, wangfushuai@baidu.com Subject: [PATCH 1/2] net/mlx5: Simplify cpumask operations in comp_irq_request_sf() Date: Wed, 3 Jun 2026 15:26:56 +0800 Message-Id: <20260603072657.10868-2-fushuai.wang@linux.dev> In-Reply-To: <20260603072657.10868-1-fushuai.wang@linux.dev> References: <20260603072657.10868-1-fushuai.wang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Fushuai Wang Combine cpumask_copy() and cpumask_andnot() into a single cpumask_andnot() since the function can take cpu_online_mask directly as the source. Signed-off-by: Fushuai Wang Reviewed-by: Shay Drory --- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/eth= ernet/mellanox/mlx5/core/eq.c index 22a637111aa2..d11ec263d53c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c @@ -886,8 +886,7 @@ static int comp_irq_request_sf(struct mlx5_core_dev *de= v, u16 vecidx) return -ENOMEM; =20 af_desc->is_managed =3D false; - cpumask_copy(&af_desc->mask, cpu_online_mask); - cpumask_andnot(&af_desc->mask, &af_desc->mask, &table->used_cpus); + cpumask_andnot(&af_desc->mask, cpu_online_mask, &table->used_cpus); irq =3D mlx5_irq_affinity_request(dev, pool, af_desc); if (IS_ERR(irq)) { kvfree(af_desc); --=20 2.36.1 From nobody Mon Jun 8 06:36:13 2026 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB38F407CEB for ; Wed, 3 Jun 2026 07:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780471733; cv=none; b=Z33NT0VbcatgOR20EVpg9igpaR6SPBzCCObXCfWkGTIfv75ljV9FIhnVMbXuQBoYH8xh9BR9aBiX1iTl1svqg+bm/37SqhbzW8BfzocpejSx7SoPtlIERQB6UfXbfpdX67ZakYxr6NQ5STMTBCZDcVk6mxhYFAK660tLRRggQ1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780471733; c=relaxed/simple; bh=u6F/2C+fvBzquIXPlmU/3j5rjS4sBgawX1rb11MeljM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hEW2PvoR5Dco50twN5k2UmqjDYdOjrnTLqNt36Zv0QiPZ5sa7he5kWtQHggxFFnvkz30O37NPE6m0pcuRhQrSJ8Ib37y/j189m3UNSSKiuvwxJOWy420x0LUeBUe9ud91dI15GyK9X1mXyS14GiDW4SvFRW5f6lYsk01zEIMiA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=OeNMOhBG; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="OeNMOhBG" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780471729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TbOdb5ayEdhtH6yD3DNTe0xKjBwdKK62mPaH1TFHgak=; b=OeNMOhBGJqIjbiZIKthmLgw+5Il6LKUo0dcmPR1dzBbD8H+Js2nFq3Ay1dDPfbpf9til3s tUnLRquTGzzLGphpHl8IzZlcuVPPCm6Gz9QJYauVovHPLRPdsbZ+neQD3wHgkzgroL5Cfe iK0+sPgC+3g24EjqfI/auwnChrp1bJg= From: Fushuai Wang To: saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shayd@nvidia.com, parav@nvidia.com, moshe@nvidia.com Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, wangfushuai@baidu.com Subject: [PATCH 2/2] net/mlx5: Only consider online CPUs in affinity subset check Date: Wed, 3 Jun 2026 15:26:57 +0800 Message-Id: <20260603072657.10868-3-fushuai.wang@linux.dev> In-Reply-To: <20260603072657.10868-1-fushuai.wang@linux.dev> References: <20260603072657.10868-1-fushuai.wang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Fushuai Wang When an SF is created after a CPU has been taken offline, the IRQ pool may contain IRQs with affinity masks that include the offline CPU. Since only online CPUs should be considered for IRQ placement, cpumask_subset() check would fail because the iter_mask contains offline CPUs that are not present in req_mask, causing SF creation to fail. Filter the affinity mask to only include online CPUs before checking if it's a subset of the requested mask, ensuring SF creation succeeds in this scena= rio. Fixes: 061f5b23588a ("net/mlx5: SF, Use all available cpu for setting cpu a= ffinity") Signed-off-by: Fushuai Wang --- .../net/ethernet/mellanox/mlx5/core/irq_affinity.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c b/drive= rs/net/ethernet/mellanox/mlx5/core/irq_affinity.c index 994fe83da4be..8c0df240b888 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c @@ -102,18 +102,26 @@ irq_pool_find_least_loaded(struct mlx5_irq_pool *pool= , const struct cpumask *req struct mlx5_irq *iter; int irq_refcount =3D 0; unsigned long index; + cpumask_var_t tmp; =20 lockdep_assert_held(&pool->lock); + + if (!alloc_cpumask_var(&tmp, GFP_ATOMIC)) + return NULL; + xa_for_each_range(&pool->irqs, index, iter, start, end) { struct cpumask *iter_mask =3D mlx5_irq_get_affinity_mask(iter); int iter_refcount =3D mlx5_irq_read_locked(iter); =20 - if (!cpumask_subset(iter_mask, req_mask)) + cpumask_and(tmp, iter_mask, cpu_online_mask); + if (!cpumask_subset(tmp, req_mask)) /* skip IRQs with a mask which is not subset of req_mask */ continue; - if (iter_refcount < pool->min_threshold) + if (iter_refcount < pool->min_threshold) { /* If we found an IRQ with less than min_thres, return it */ + free_cpumask_var(tmp); return iter; + } if (!irq || iter_refcount < irq_refcount) { /* In case we won't find an IRQ with less than min_thres, * keep a pointer to the least used IRQ @@ -122,6 +130,8 @@ irq_pool_find_least_loaded(struct mlx5_irq_pool *pool, = const struct cpumask *req irq =3D iter; } } + + free_cpumask_var(tmp); return irq; } =20 --=20 2.36.1