From: Shay Drori <shayd@nvidia.com>
To: Fushuai Wang <fushuai.wang@linux.dev>, <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>,
<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: Re: [PATCH 2/2] net/mlx5: Only consider online CPUs in affinity subset check
Date: Thu, 4 Jun 2026 08:53:22 +0300 [thread overview]
Message-ID: <7018a27a-29fb-4c8e-84cf-dc90d1b3bd9c@nvidia.com> (raw)
In-Reply-To: <20260603072657.10868-3-fushuai.wang@linux.dev>
On 03/06/2026 10:26, Fushuai Wang wrote:
> External email: Use caution opening links or attachments
>
>
> From: Fushuai Wang <wangfushuai@baidu.com>
>
> 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.
Thank for the patch!
can you please provide a full example? for simplicity, lets say the SF
pool is of size of 2 IRQs.
>
> Filter the affinity mask to only include online CPUs before checking if it's
> a subset of the requested mask,
won't this cause the affinity mask to be empty, which is kind of missing
the point of this API... :(
can you check if irq_get_effective_affinity_mask() will solve the issue?
Thanks
> ensuring SF creation succeeds in this scenario.
>
> Fixes: 061f5b23588a ("net/mlx5: SF, Use all available cpu for setting cpu affinity")
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> ---
> .../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/drivers/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 = 0;
> unsigned long index;
> + cpumask_var_t tmp;
>
> 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 = mlx5_irq_get_affinity_mask(iter);
> int iter_refcount = mlx5_irq_read_locked(iter);
>
> - 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 = iter;
> }
> }
> +
> + free_cpumask_var(tmp);
> return irq;
> }
>
> --
> 2.36.1
>
next prev parent reply other threads:[~2026-06-04 5:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 7:26 [PATCH 0/2] " Fushuai Wang
2026-06-03 7:26 ` [PATCH 1/2] net/mlx5: Simplify cpumask operations in comp_irq_request_sf() Fushuai Wang
2026-06-04 5:57 ` Shay Drori
2026-06-03 7:26 ` [PATCH 2/2] net/mlx5: Only consider online CPUs in affinity subset check Fushuai Wang
2026-06-04 5:53 ` Shay Drori [this message]
2026-06-04 12:54 ` Fushuai Wang
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=7018a27a-29fb-4c8e-84cf-dc90d1b3bd9c@nvidia.com \
--to=shayd@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fushuai.wang@linux.dev \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=wangfushuai@baidu.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
all inboxes | Powered by JetHome®