mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lai Jiangshan <jiangshanlai@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <jiangshan.ljs@antgroup.com>,
	Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Subject: [RFC PATCH 7/8] workqueue: Remove the outer loop in maybe_create_worker()
Date: Thu,  4 Aug 2022 16:41:34 +0800	[thread overview]
Message-ID: <20220804084135.92425-8-jiangshanlai@gmail.com> (raw)
In-Reply-To: <20220804084135.92425-1-jiangshanlai@gmail.com>

From: Lai Jiangshan <jiangshan.ljs@antgroup.com>

worker_thread() always does the recheck after getting the manager role,
so the recheck in the maybe_create_worker() is unneeded and is removed.

A piece of comment for maybe_create_worker() is removed because it is
not true anymore after the recheck is removed.

A piece of comment for manage_workers() is removed because there is
already another piece of comment explaining the same thing which is
more accurate.

Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
---
 kernel/workqueue.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 64dc1833d11a..0d9844b81482 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2091,9 +2091,6 @@ static void pool_mayday_timeout(struct timer_list *t)
  * sent to all rescuers with works scheduled on @pool to resolve
  * possible allocation deadlock.
  *
- * On return, need_to_create_worker() is guaranteed to be %false and
- * may_start_working() %true.
- *
  * LOCKING:
  * raw_spin_lock_irq(pool->lock) which may be released and regrabbed
  * multiple times.  Does GFP_KERNEL allocations.  Called only from
@@ -2103,7 +2100,6 @@ static void maybe_create_worker(struct worker_pool *pool)
 __releases(&pool->lock)
 __acquires(&pool->lock)
 {
-restart:
 	raw_spin_unlock_irq(&pool->lock);
 
 	/* if we don't make progress in MAYDAY_INITIAL_TIMEOUT, call for help */
@@ -2121,13 +2117,6 @@ __acquires(&pool->lock)
 
 	del_timer_sync(&pool->mayday_timer);
 	raw_spin_lock_irq(&pool->lock);
-	/*
-	 * This is necessary even after a new worker was just successfully
-	 * created as @pool->lock was dropped and the new worker might have
-	 * already become busy.
-	 */
-	if (need_to_create_worker(pool))
-		goto restart;
 }
 
 /**
@@ -2138,10 +2127,6 @@ __acquires(&pool->lock)
  * to.  At any given time, there can be only zero or one manager per
  * pool.  The exclusion is handled automatically by this function.
  *
- * The caller can safely start processing works on false return.  On
- * true return, it's guaranteed that need_to_create_worker() is false
- * and may_start_working() is true.
- *
  * CONTEXT:
  * raw_spin_lock_irq(pool->lock) which may be released and regrabbed
  * multiple times.  Does GFP_KERNEL allocations.
-- 
2.19.1.6.gb485710b


  parent reply	other threads:[~2022-08-04  8:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04  8:41 [RFC PATCH 0/8] workqueue: Fix for prematurely wakeups and cleanups Lai Jiangshan
2022-08-04  8:41 ` [RFC PATCH 1/8] workqueue: Unconditionally set cpumask in worker_attach_to_pool() Lai Jiangshan
2022-08-16 21:18   ` Tejun Heo
2022-08-18 14:39     ` Lai Jiangshan
2022-09-12  7:54   ` Peter Zijlstra
2022-08-04  8:41 ` [RFC PATCH 2/8] workqueue: Make create_worker() safe against prematurely wakeups Lai Jiangshan
     [not found]   ` <20220804123520.1660-1-hdanton@sina.com>
2022-08-05  2:30     ` Lai Jiangshan
2022-08-16 21:46   ` Tejun Heo
2022-08-04  8:41 ` [RFC PATCH 3/8] workqueue: Set PF_NO_SETAFFINITY instead of kthread_bind_mask() Lai Jiangshan
2022-08-04  8:41 ` [RFC PATCH 4/8] workqueue: Set/Clear PF_WQ_WORKER while attaching/detaching Lai Jiangshan
2022-08-04  8:41 ` [RFC PATCH 5/8] workqueue: Use worker_set_flags() in worker_enter_idle() Lai Jiangshan
2022-08-04  8:41 ` [RFC PATCH 6/8] workqueue: Simplify the starting of the newly created worker Lai Jiangshan
2022-08-04  8:41 ` Lai Jiangshan [this message]
2022-08-16 22:08   ` [RFC PATCH 7/8] workqueue: Remove the outer loop in maybe_create_worker() Tejun Heo
2022-08-18 14:44     ` Lai Jiangshan
2022-08-19 17:29       ` Tejun Heo
2022-08-04  8:41 ` [RFC PATCH 8/8] workqueue: Move the locking out of maybe_create_worker() Lai Jiangshan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220804084135.92425-8-jiangshanlai@gmail.com \
    --to=jiangshanlai@gmail.com \
    --cc=jiangshan.ljs@antgroup.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®