workqueue: Create kworker only for boot CPU pool prior SMP initialization
PATCH 1/1 workqueue: Create kworker only for boot CPU pool prior SMP initialization
The workqueue_init() is called before SMP initialization, which means only the boot CPU is online, just create kworker for boot CPU pool.
Signed-off-by Zqiang <[email protected]>
--- kernel/workqueue.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/workqueue.c +3 -5
@@ -6120,11 +6120,9 @@ void __init workqueue_init(void)mutex_unlock (&wq_pool_mutex);/* create the initial workers */ -for_each_online_cpu (cpu) { -for_each_cpu_worker_pool (pool, cpu) { - pool->flags &= ~POOL_DISASSOCIATED ; -BUG_ON (!create_worker (pool)); - } +for_each_cpu_worker_pool (pool,smp_processor_id ()) { + pool->flags &= ~POOL_DISASSOCIATED ; +BUG_ON (!create_worker (pool)); }hash_for_each (unbound_pool_hash, bkt, pool, hash_node)
Signature · 1 line
2.25.1
Tejun Heo
maintainerQuoted 15 lines · Zqiang
The
workqueue_init()is called before SMP initialization, which means only the boot CPU is online, just create kworker for boot CPU pool.Signed-off-by Zqiang <[email protected]>--- kernel/workqueue.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)kernel/workqueue.c +0
-0@@ -6120,11 +6120,9 @@ void __init workqueue_init(void)mutex_unlock (&wq_pool_mutex);
kernel/workqueue.c void __init workqueue_init(void) · line 6125
Quoted 10 lines
kernel/workqueue.c +3
-5/* create the initial workers */ -for_each_online_cpu (cpu) { -for_each_cpu_worker_pool (pool, cpu) { - pool->flags &= ~POOL_DISASSOCIATED ; -BUG_ON (!create_worker (pool)); - } +for_each_cpu_worker_pool (pool,smp_processor_id ()) { + pool->flags &= ~POOL_DISASSOCIATED ; +BUG_ON (!create_worker (pool));
I mean, I guess this would work but what's the benefit? It doesn't make any practical difference and the code is now more fragile to external changes.
Thanks.
Signature · 1 line
tejun