summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury Norov [NVIDIA] <yury.norov@gmail.com>2025-06-04 15:39:39 -0400
committerLeon Romanovsky <leon@kernel.org>2025-06-26 05:19:35 -0400
commit15b0536313045c3fdd374b99f747b15278ac8895 (patch)
tree4ebc88bccebfc136b2e4d2d3ab64186bcc58f443
parent59f7d2138591ef8f0e4e4ab5f1ab674e8181ad3a (diff)
RDMA: hfi1: simplify find_hw_thread_mask()
The function opencodes cpumask_nth() and cpumask_clear_cpus(). The dedicated helpers are easier to use and usually much faster than opencoded for-loops. Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com> Link: https://patch.msgid.link/20250604193947.11834-4-yury.norov@gmail.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
-rw-r--r--drivers/infiniband/hw/hfi1/affinity.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c
index f2c530ab85a5..9ea80b777061 100644
--- a/drivers/infiniband/hw/hfi1/affinity.c
+++ b/drivers/infiniband/hw/hfi1/affinity.c
@@ -963,7 +963,7 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd,
static void find_hw_thread_mask(uint hw_thread_no, cpumask_var_t hw_thread_mask,
struct hfi1_affinity_node_list *affinity)
{
- int possible, curr_cpu, i;
+ int curr_cpu;
uint num_cores_per_socket;
cpumask_copy(hw_thread_mask, &affinity->proc.mask);
@@ -976,17 +976,9 @@ static void find_hw_thread_mask(uint hw_thread_no, cpumask_var_t hw_thread_mask,
node_affinity.num_online_nodes;
/* Removing other siblings not needed for now */
- possible = cpumask_weight(hw_thread_mask);
- curr_cpu = cpumask_first(hw_thread_mask);
- for (i = 0;
- i < num_cores_per_socket * node_affinity.num_online_nodes;
- i++)
- curr_cpu = cpumask_next(curr_cpu, hw_thread_mask);
-
- for (; i < possible; i++) {
- cpumask_clear_cpu(curr_cpu, hw_thread_mask);
- curr_cpu = cpumask_next(curr_cpu, hw_thread_mask);
- }
+ curr_cpu = cpumask_cpumask_nth(num_cores_per_socket *
+ node_affinity.num_online_nodes, hw_thread_mask) + 1;
+ cpumask_clear_cpus(hw_thread_mask, curr_cpu, nr_cpu_ids - curr_cpu);
/* Identifying correct HW threads within physical cores */
cpumask_shift_left(hw_thread_mask, hw_thread_mask,