Skip to content

Commit c9c19e8

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: Init rescuer's affinities as wq_unbound_cpumask
The affinity to set to the rescuers should be consistent in all paths when a rescuer is in detached state. The affinity could be either wq_unbound_cpumask or unbound_effective_cpumask(wq). Related paths: rescuer's worker_detach_from_pool() update wq_unbound_cpumask update wq's cpumask init_rescuer() Both affinities are Ok as long as they are consistent in all paths. In the commit 449b31a ("workqueue: Init rescuer's affinities as the wq's effective cpumask") makes init_rescuer use unbound_effective_cpumask(wq) which is consistent with then apply_wqattrs_commit(). But using unbound_effective_cpumask(wq) requres much more code to maintain the consistency, and it doesn't make much sense since the affinity is only effective when the rescuer is not processing works. wq_unbound_cpumask is more favorable. So apply_wqattrs_commit() and the path of "updating wq's cpumask" had been changed to not update the rescuer's affinity, and both the paths of "updating wq_unbound_cpumask" and "rescuer's worker_detach_from_pool()" had been changed to use wq_unbound_cpumask. Now, make init_rescuer() use wq_unbound_cpumask for rescuer's affinity and make all the paths consistent. Cc: Juri Lelli <[email protected]> Cc: Waiman Long <[email protected]> Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 8ac4dbe commit c9c19e8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kernel/workqueue.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5603,10 +5603,13 @@ static int init_rescuer(struct workqueue_struct *wq)
56035603
}
56045604

56055605
wq->rescuer = rescuer;
5606-
if (wq->flags & WQ_UNBOUND)
5607-
kthread_bind_mask(rescuer->task, unbound_effective_cpumask(wq));
5606+
5607+
/* initial cpumask is consistent with the detached rescuer and unbind_worker() */
5608+
if (cpumask_intersects(wq_unbound_cpumask, cpu_active_mask))
5609+
kthread_bind_mask(rescuer->task, wq_unbound_cpumask);
56085610
else
56095611
kthread_bind_mask(rescuer->task, cpu_possible_mask);
5612+
56105613
wake_up_process(rescuer->task);
56115614

56125615
return 0;

0 commit comments

Comments
 (0)