Skip to contentSkip to conversation

workque: fix opencoded cpumask_next_and_wrap() in wq_select_unbound_cpu()

PATCH Applied Yury Norov 2 participants 2 messages Jun 5, 2025 – Jun 9, 2025 Workqueue

lore
Share & tools
lore

Yury Norov

author
#0 lore raw

PATCH 1/1 workque: fix opencoded cpumask_next_and_wrap() in wq_select_unbound_cpu()

From: Yury Norov [NVIDIA] <[email protected]>

The dedicated helper is more verbose and effective comparing to cpumask_first() followed by cpumask_next().

---
 kernel/workqueue.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
kernel/workqueue.c +3 -6
index 3bef0754cf73..3518ea5ec55f 100644
@@ -2221,12 +2221,9 @@ static int wq_select_unbound_cpu(int cpu)
 	}
 
 	new_cpu = __this_cpu_read(wq_rr_cpu_last);
-	new_cpu = cpumask_next_and(new_cpu, wq_unbound_cpumask, cpu_online_mask);
-	if (unlikely(new_cpu >= nr_cpu_ids)) {
-		new_cpu = cpumask_first_and(wq_unbound_cpumask, cpu_online_mask);
-		if (unlikely(new_cpu >= nr_cpu_ids))
-			return cpu;
-	}
+	new_cpu = cpumask_next_and_wrap(new_cpu, wq_unbound_cpumask, cpu_online_mask);
+	if (unlikely(new_cpu >= nr_cpu_ids))
+		return cpu;
 	__this_cpu_write(wq_rr_cpu_last, new_cpu);
 
 	return new_cpu;
Signature · 1 line
2.43.0