linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] workqueue: Create kworker only for boot CPU pool prior SMP initialization
@ 2022-03-31 13:14 Zqiang
  2022-04-04 17:40 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Zqiang @ 2022-03-31 13:14 UTC (permalink / raw)
  To: tj, jiangshanlai; +Cc: linux-kernel

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 <qiang1.zhang@intel.com>
---
 kernel/workqueue.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index abcc9a2ac319..3948babe02d5 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] workqueue: Create kworker only for boot CPU pool prior SMP initialization
  2022-03-31 13:14 [PATCH] workqueue: Create kworker only for boot CPU pool prior SMP initialization Zqiang
@ 2022-04-04 17:40 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2022-04-04 17:40 UTC (permalink / raw)
  To: Zqiang; +Cc: jiangshanlai, linux-kernel

On Thu, Mar 31, 2022 at 09:14:35PM +0800, Zqiang wrote:
> 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 <qiang1.zhang@intel.com>
> ---
>  kernel/workqueue.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index abcc9a2ac319..3948babe02d5 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -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));

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.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-04 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 13:14 [PATCH] workqueue: Create kworker only for boot CPU pool prior SMP initialization Zqiang
2022-04-04 17:40 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).