From nobody Mon Jun 8 06:36:26 2026 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 3EE8B3F8256; Fri, 5 Jun 2026 10:21:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780654903; cv=none; b=odXdOKBWXpn1ICI+9NO7SHTD05oVoEgu91Grj2y0zLFGWa+Q2azJMQFA0v787+AT3snrg89Hk/uV4V6Uowi3nbYUs1ejsti1IgK8AA3e157NM6jnKNWwEVP2oHoh1O7pOAyMuoAs2SeL1X0BryMK3p7uj8eGV/sJ5A/wy54Bgow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780654903; c=relaxed/simple; bh=n0k4JGs4kQG2g1krCb8kuEjcTHo5ckxZS8wF38x7sEE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=i/BjdY9pGk++9eg8JdjBh5u/Njk3eUbY8hqW4kCCC/2ANwgI0HMnMOdYL1nXxAn3xXKfz8DOEHIYrk6QOj69II8/Jd2KVGzryuYocFpOZXLxRkVq9bTd7kZMoAZSi1SoG5vuYbh/PlYo4bPseZREegXTLzn81RQrQ4hPlbOGA3E= 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=vnpoYyQQ; arc=none smtp.client-ip=91.218.175.172 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="vnpoYyQQ" 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=1780654900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qmshnswE8x0GBLubuyd5jODV23L4uppKMxxUHX+7goQ=; b=vnpoYyQQ+RziLKxNP15P1l/tm6hhar1Dc/VYl5ttTKi8fEQ1nVNJTUHs1IKgYDsz8w7H7e 9MhkWYvoOxZ4T6aEB0rsyFnFaUr/UJpisABG7WF6RYkyHLP80GpB7OpT/4yylKwgY1oKNn mlLFZSXWOFPvOnH+M8IqUJJOyA1YEZU= 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 net v3] net/mlx5: Use effective affinity mask for IRQ selection Date: Fri, 5 Jun 2026 18:21:12 +0800 Message-Id: <20260605102112.91772-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT From: Fushuai Wang When a 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. This is an example: 1. When mlx5 driver loads, it initializes the IRQ pools. For sf_ctrl_pool with =E2=89=A464 sf: - xa_num_irqs =3D {N, N} (There is only one slot) 2. When the first SF is created: - The ctrl IRQ is allocated with mask=3Dcpu_online_mask=3D{0-191} 2. We take CPU 20 offline 3. Existing ctl irq still have mask=3D{0-191} 4. Create a new SF: - req_mask=3D{0-19,21-191} - iter_mask=3D{0-191} - {0-191} is NOT a subset of {0-19,21-191} - least_loaded_irq=3DNULL 5. Try to allocate a new irq via irq_pool_request_irq() 6. xa_alloc() fails because the pool is full(There is only one slot) 7. sf creation fails with error Use irq_get_effective_affinity_mask() instead, which returns the IRQ's actual effective affinity that already excludes offline CPUs. Fixes: 061f5b23588a ("net/mlx5: SF, Use all available cpu for setting cpu a= ffinity") Suggested-by: Shay Drory Signed-off-by: Fushuai Wang Reviewed-by: Shay Drory Reviewed-by: Tariq Toukan --- v2->v3: Separate the patchset to two patches, reverse xmas tree coding styl= e fix. v1->v2: Use mlx5_irq_get_affinity_mask() api previous discussion: https://lore.kernel.org/all/20260603072657.10868-1-fushuai.wang@linux.dev/T= /#u https://lore.kernel.org/all/20260604125705.21241-1-fushuai.wang@linux.dev/T= /#u drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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..a0bb8ee44e35 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c @@ -105,9 +105,12 @@ irq_pool_find_least_loaded(struct mlx5_irq_pool *pool,= const struct cpumask *req =20 lockdep_assert_held(&pool->lock); 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); + const struct cpumask *iter_mask; =20 + iter_mask =3D irq_get_effective_affinity_mask(mlx5_irq_get_irq(iter)); + if (!iter_mask) + continue; if (!cpumask_subset(iter_mask, req_mask)) /* skip IRQs with a mask which is not subset of req_mask */ continue; --=20 2.36.1