@@ -1976,6 +1976,23 @@ static struct worker *create_worker(struct worker_pool *pool)
1976
1976
return NULL ;
1977
1977
}
1978
1978
1979
+ static void unbind_worker (struct worker * worker )
1980
+ {
1981
+ lockdep_assert_held (& wq_pool_attach_mutex );
1982
+
1983
+ kthread_set_per_cpu (worker -> task , -1 );
1984
+ if (cpumask_intersects (wq_unbound_cpumask , cpu_active_mask ))
1985
+ WARN_ON_ONCE (set_cpus_allowed_ptr (worker -> task , wq_unbound_cpumask ) < 0 );
1986
+ else
1987
+ WARN_ON_ONCE (set_cpus_allowed_ptr (worker -> task , cpu_possible_mask ) < 0 );
1988
+ }
1989
+
1990
+ static void rebind_worker (struct worker * worker , struct worker_pool * pool )
1991
+ {
1992
+ kthread_set_per_cpu (worker -> task , pool -> cpu );
1993
+ WARN_ON_ONCE (set_cpus_allowed_ptr (worker -> task , pool -> attrs -> cpumask ) < 0 );
1994
+ }
1995
+
1979
1996
/**
1980
1997
* destroy_worker - destroy a workqueue worker
1981
1998
* @worker: worker to be destroyed
@@ -5051,13 +5068,8 @@ static void unbind_workers(int cpu)
5051
5068
5052
5069
raw_spin_unlock_irq (& pool -> lock );
5053
5070
5054
- for_each_pool_worker (worker , pool ) {
5055
- kthread_set_per_cpu (worker -> task , -1 );
5056
- if (cpumask_intersects (wq_unbound_cpumask , cpu_active_mask ))
5057
- WARN_ON_ONCE (set_cpus_allowed_ptr (worker -> task , wq_unbound_cpumask ) < 0 );
5058
- else
5059
- WARN_ON_ONCE (set_cpus_allowed_ptr (worker -> task , cpu_possible_mask ) < 0 );
5060
- }
5071
+ for_each_pool_worker (worker , pool )
5072
+ unbind_worker (worker );
5061
5073
5062
5074
mutex_unlock (& wq_pool_attach_mutex );
5063
5075
}
@@ -5082,11 +5094,8 @@ static void rebind_workers(struct worker_pool *pool)
5082
5094
* of all workers first and then clear UNBOUND. As we're called
5083
5095
* from CPU_ONLINE, the following shouldn't fail.
5084
5096
*/
5085
- for_each_pool_worker (worker , pool ) {
5086
- kthread_set_per_cpu (worker -> task , pool -> cpu );
5087
- WARN_ON_ONCE (set_cpus_allowed_ptr (worker -> task ,
5088
- pool -> attrs -> cpumask ) < 0 );
5089
- }
5097
+ for_each_pool_worker (worker , pool )
5098
+ rebind_worker (worker , pool );
5090
5099
5091
5100
raw_spin_lock_irq (& pool -> lock );
5092
5101
0 commit comments