mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: <linux-kernel@vger.kernel.org>
Cc: Tejun Heo <tj@kernel.org>, Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: [PATCH 1/3] workqueue: remove the first check and the return value of maybe_create_worker()
Date: Fri, 11 Jul 2014 00:01:03 +0800	[thread overview]
Message-ID: <1405008074-11031-2-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1405008074-11031-1-git-send-email-laijs@cn.fujitsu.com>

The pool->lock is kept locked during the time the worker_thread() checks the
condition and maybe_create_worker() is called, therefore, the condition
is unchanged and the first condition check is unneeded.

After this unneeded check is removed, maybe_create_worker() only returns
true, so we remove the return value of it and adjust the call-site.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 kernel/workqueue.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index f344334..92f7ea0c 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1887,17 +1887,11 @@ static void pool_mayday_timeout(unsigned long __pool)
  * spin_lock_irq(pool->lock) which may be released and regrabbed
  * multiple times.  Does GFP_KERNEL allocations.  Called only from
  * manager.
- *
- * Return:
- * %false if no action was taken and pool->lock stayed locked, %true
- * otherwise.
  */
-static bool maybe_create_worker(struct worker_pool *pool)
+static void maybe_create_worker(struct worker_pool *pool)
 __releases(&pool->lock)
 __acquires(&pool->lock)
 {
-	if (!need_to_create_worker(pool))
-		return false;
 restart:
 	spin_unlock_irq(&pool->lock);
 
@@ -1914,7 +1908,7 @@ restart:
 			start_worker(worker);
 			if (WARN_ON_ONCE(need_to_create_worker(pool)))
 				goto restart;
-			return true;
+			return;
 		}
 
 		if (!need_to_create_worker(pool))
@@ -1930,7 +1924,6 @@ restart:
 	spin_lock_irq(&pool->lock);
 	if (need_to_create_worker(pool))
 		goto restart;
-	return true;
 }
 
 /**
@@ -1959,7 +1952,6 @@ restart:
 static bool manage_workers(struct worker *worker)
 {
 	struct worker_pool *pool = worker->pool;
-	bool ret = false;
 
 	/*
 	 * Anyone who successfully grabs manager_arb wins the arbitration
@@ -1972,12 +1964,12 @@ static bool manage_workers(struct worker *worker)
 	 * actual management, the pool may stall indefinitely.
 	 */
 	if (!mutex_trylock(&pool->manager_arb))
-		return ret;
+		return false;
 
-	ret |= maybe_create_worker(pool);
+	maybe_create_worker(pool);
 
 	mutex_unlock(&pool->manager_arb);
-	return ret;
+	return true;
 }
 
 /**
-- 
1.7.4.4


  reply	other threads:[~2014-07-10 16:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-10 16:01 [PATCH 0/3] workqueue: manager cleanup Lai Jiangshan
2014-07-10 16:01 ` Lai Jiangshan [this message]
2014-07-11 15:03   ` [PATCH 1/3] workqueue: remove the first check and the return value of maybe_create_worker() Tejun Heo
2014-07-14  2:30     ` Lai Jiangshan
2014-07-14 14:40       ` Tejun Heo
2014-07-10 16:01 ` [PATCH 2/3] workqueue: remove the guarantee and the retrying " Lai Jiangshan
2014-07-11 15:02   ` Tejun Heo
2014-07-10 16:01 ` [PATCH 3/3] workqueue: unfold start_worker() into create_worker() Lai Jiangshan
2014-07-14  4:05 ` [PATCH 0/1 V2] workqueue: manager cleanup Lai Jiangshan
2014-07-14  4:05   ` [PATCH 1/1 V2] workqueue: unfold start_worker() into create_worker() Lai Jiangshan
2014-07-16  1:28     ` Lai Jiangshan
2014-07-18 22:57       ` Tejun Heo
2014-07-22  5:03         ` [PATCH V3] " Lai Jiangshan
2014-07-22 15:05           ` Tejun Heo

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=1405008074-11031-2-git-send-email-laijs@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.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®