Skip to content

Commit f45b1c3

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: Don't bind the rescuer in the last working cpu
So that when the rescuer is woken up next time, it will not interrupt the last working cpu which might be busy on other crucial works but have nothing to do with the rescuer's incoming works. Cc: Valentin Schneider <[email protected]> Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 68f8305 commit f45b1c3

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

kernel/workqueue.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,6 +2684,17 @@ static void worker_attach_to_pool(struct worker *worker,
26842684
mutex_unlock(&wq_pool_attach_mutex);
26852685
}
26862686

2687+
static void unbind_worker(struct worker *worker)
2688+
{
2689+
lockdep_assert_held(&wq_pool_attach_mutex);
2690+
2691+
kthread_set_per_cpu(worker->task, -1);
2692+
if (cpumask_intersects(wq_unbound_cpumask, cpu_active_mask))
2693+
WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, wq_unbound_cpumask) < 0);
2694+
else
2695+
WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_possible_mask) < 0);
2696+
}
2697+
26872698
/**
26882699
* worker_detach_from_pool() - detach a worker from its pool
26892700
* @worker: worker which is attached to its pool
@@ -2701,7 +2712,7 @@ static void worker_detach_from_pool(struct worker *worker)
27012712

27022713
mutex_lock(&wq_pool_attach_mutex);
27032714

2704-
kthread_set_per_cpu(worker->task, -1);
2715+
unbind_worker(worker);
27052716
list_del(&worker->node);
27062717
worker->pool = NULL;
27072718

@@ -2796,17 +2807,6 @@ static struct worker *create_worker(struct worker_pool *pool)
27962807
return NULL;
27972808
}
27982809

2799-
static void unbind_worker(struct worker *worker)
2800-
{
2801-
lockdep_assert_held(&wq_pool_attach_mutex);
2802-
2803-
kthread_set_per_cpu(worker->task, -1);
2804-
if (cpumask_intersects(wq_unbound_cpumask, cpu_active_mask))
2805-
WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, wq_unbound_cpumask) < 0);
2806-
else
2807-
WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, cpu_possible_mask) < 0);
2808-
}
2809-
28102810
static void wake_dying_workers(struct list_head *cull_list)
28112811
{
28122812
struct worker *worker;

0 commit comments

Comments
 (0)