Skip to content

Commit 0998f0a

Browse files
YuryNorovhtejun
authored andcommitted
workqueue: fix opencoded cpumask_next_and_wrap() in wq_select_unbound_cpu()
The dedicated helper is more verbose and effective comparing to cpumask_first() followed by cpumask_next(). Signed-off-by: Yury Norov [NVIDIA] <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 19272b3 commit 0998f0a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

kernel/workqueue.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,12 +2221,9 @@ static int wq_select_unbound_cpu(int cpu)
22212221
}
22222222

22232223
new_cpu = __this_cpu_read(wq_rr_cpu_last);
2224-
new_cpu = cpumask_next_and(new_cpu, wq_unbound_cpumask, cpu_online_mask);
2225-
if (unlikely(new_cpu >= nr_cpu_ids)) {
2226-
new_cpu = cpumask_first_and(wq_unbound_cpumask, cpu_online_mask);
2227-
if (unlikely(new_cpu >= nr_cpu_ids))
2228-
return cpu;
2229-
}
2224+
new_cpu = cpumask_next_and_wrap(new_cpu, wq_unbound_cpumask, cpu_online_mask);
2225+
if (unlikely(new_cpu >= nr_cpu_ids))
2226+
return cpu;
22302227
__this_cpu_write(wq_rr_cpu_last, new_cpu);
22312228

22322229
return new_cpu;

0 commit comments

Comments
 (0)