From: Yury Norov <yury.norov@gmail.com>
To: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
Yury Norov <yury.norov@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 7/7] RDMI: hfi1: drop cpumask_empty() call in hfi1/affinity.c
Date: Wed, 4 Jun 2025 15:39:43 -0400 [thread overview]
Message-ID: <20250604193947.11834-8-yury.norov@gmail.com> (raw)
In-Reply-To: <20250604193947.11834-1-yury.norov@gmail.com>
From: "Yury Norov [NVIDIA]" <yury.norov@gmail.com>
In few places, the driver tests a cpumask for emptiness immediately
before calling functions that report emptiness themself.
Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
---
drivers/infiniband/hw/hfi1/affinity.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c
index 8974aa1e63d1..ee7fedc67b86 100644
--- a/drivers/infiniband/hw/hfi1/affinity.c
+++ b/drivers/infiniband/hw/hfi1/affinity.c
@@ -337,9 +337,10 @@ static int _dev_comp_vect_cpu_get(struct hfi1_devdata *dd,
&entry->def_intr.used);
/* If there are non-interrupt CPUs available, use them first */
- if (!cpumask_empty(non_intr_cpus))
- cpu = cpumask_first(non_intr_cpus);
- else /* Otherwise, use interrupt CPUs */
+ cpu = cpumask_first(non_intr_cpus);
+
+ /* Otherwise, use interrupt CPUs */
+ if (cpu >= nr_cpu_ids)
cpu = cpumask_first(available_cpus);
if (cpu >= nr_cpu_ids) { /* empty */
@@ -1080,8 +1081,7 @@ int hfi1_get_proc_affinity(int node)
* loop as the used mask gets reset when
* (set->mask == set->used) before this loop.
*/
- cpumask_andnot(diff, hw_thread_mask, &set->used);
- if (!cpumask_empty(diff))
+ if (cpumask_andnot(diff, hw_thread_mask, &set->used))
break;
}
hfi1_cdbg(PROC, "Same available HW thread on all physical CPUs: %*pbl",
@@ -1113,8 +1113,7 @@ int hfi1_get_proc_affinity(int node)
* used for process assignments using the same method as
* the preferred NUMA node.
*/
- cpumask_andnot(diff, available_mask, intrs_mask);
- if (!cpumask_empty(diff))
+ if (cpumask_andnot(diff, available_mask, intrs_mask))
cpumask_copy(available_mask, diff);
/* If we don't have CPUs on the preferred node, use other NUMA nodes */
@@ -1130,8 +1129,7 @@ int hfi1_get_proc_affinity(int node)
* At first, we don't want to place processes on the same
* CPUs as interrupt handlers.
*/
- cpumask_andnot(diff, available_mask, intrs_mask);
- if (!cpumask_empty(diff))
+ if (cpumask_andnot(diff, available_mask, intrs_mask))
cpumask_copy(available_mask, diff);
}
hfi1_cdbg(PROC, "Possible CPUs for process: %*pbl",
--
2.43.0
next prev parent reply other threads:[~2025-06-04 19:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-04 19:39 [PATCH 0/7] RDMA: hfi1: cpumasks usage fixes Yury Norov
2025-06-04 19:39 ` [PATCH 1/7] cpumask: add cpumask_clear_cpus() Yury Norov
2025-06-04 19:39 ` [PATCH 2/7] RDMA: hfi1: fix possible divide-by-zero in find_hw_thread_mask() Yury Norov
2025-06-04 19:39 ` [PATCH 3/7] RDMA: hfi1: simplify find_hw_thread_mask() Yury Norov
2025-06-04 19:39 ` [PATCH 4/7] RDMA: hfi1: simplify init_real_cpu_mask() Yury Norov
2025-06-04 19:39 ` [PATCH 5/7] RDMA: hfi1: use rounddown in find_hw_thread_mask() Yury Norov
2025-06-04 19:39 ` [PATCH 6/7] RDMA: hfi1: simplify hfi1_get_proc_affinity() Yury Norov
2025-06-04 19:39 ` Yury Norov [this message]
2025-06-12 8:12 ` [PATCH 0/7] RDMA: hfi1: cpumasks usage fixes Leon Romanovsky
2025-06-21 15:03 ` Yury Norov
2025-06-23 16:23 ` Dennis Dalessandro
2025-06-25 10:41 ` Leon Romanovsky
2025-06-25 10:41 ` Leon Romanovsky
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=20250604193947.11834-8-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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