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 3/3] workqueue: cleanup may_start_working()
Date: Sat, 26 Jul 2014 11:04:51 +0800 [thread overview]
Message-ID: <1406343900-32423-4-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1406343900-32423-1-git-send-email-laijs@cn.fujitsu.com>
The name of may_start_working() became misleading due to the semantics of
"!pool->nr_idle" is changed and any worker can start working in spite of
the value of pool->nr_idle.
So we remove the may_start_working() and use "!pool->nr_idle" directly,
need_to_create_worker() is also removed along with it.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
kernel/workqueue.c | 37 +++++++++++++------------------------
1 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ce8e3fc..e1ab4f9 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -735,12 +735,6 @@ static bool need_more_worker(struct worker_pool *pool)
return !list_empty(&pool->worklist) && __need_more_worker(pool);
}
-/* Can I start working? Called from busy but !running workers. */
-static bool may_start_working(struct worker_pool *pool)
-{
- return pool->nr_idle;
-}
-
/* Do I need to keep working? Called from currently running workers. */
static bool keep_working(struct worker_pool *pool)
{
@@ -748,12 +742,6 @@ static bool keep_working(struct worker_pool *pool)
atomic_read(&pool->nr_running) <= 1;
}
-/* Do we need a new worker? Called from manager. */
-static bool need_to_create_worker(struct worker_pool *pool)
-{
- return need_more_worker(pool) && !may_start_working(pool);
-}
-
/* Do we have too many workers and should some go away? */
static bool too_many_workers(struct worker_pool *pool)
{
@@ -1815,19 +1803,20 @@ static void pool_mayday_timeout(unsigned long __pool)
spin_lock_irq(&wq_mayday_lock); /* for wq->maydays */
spin_lock(&pool->lock);
- if (need_to_create_worker(pool)) {
- /*
- * We've been trying to create a new worker but
- * haven't been successful. We might be hitting an
- * allocation deadlock. Send distress signals to
- * rescuers.
- */
- list_for_each_entry(work, &pool->worklist, entry)
- send_mayday(work);
- }
+ if (!pool->nr_idle) {
+ if (need_more_worker(pool)) {
+ /*
+ * We've been trying to create a new worker but
+ * haven't been successful. We might be hitting an
+ * allocation deadlock. Send distress signals to
+ * rescuers.
+ */
+ list_for_each_entry(work, &pool->worklist, entry)
+ send_mayday(work);
+ }
- if (!pool->nr_idle)
mod_timer(&pool->mayday_timer, jiffies + MAYDAY_INTERVAL);
+ }
spin_unlock(&pool->lock);
spin_unlock_irq(&wq_mayday_lock);
@@ -2097,7 +2086,7 @@ woke_up:
goto sleep;
/* do we need to create worker? */
- if (unlikely(!may_start_working(pool)))
+ if (unlikely(!pool->nr_idle))
start_creater_work(pool);
/*
--
1.7.4.4
prev parent reply other threads:[~2014-07-26 3:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-26 3:04 [PATCH 0/3] workqueue: offload the worker-management out from kworker Lai Jiangshan
2014-07-26 3:04 ` [PATCH 1/3] workqueue: migrate the new worker before add it to idle_list Lai Jiangshan
2014-07-26 3:04 ` [PATCH 2/3] workqueue: use dedicated creater kthread for all pools Lai Jiangshan
2014-07-28 18:55 ` Tejun Heo
2014-07-29 1:26 ` Lai Jiangshan
2014-07-29 2:16 ` Tejun Heo
2014-07-29 9:16 ` [PATCH RFC 2/2 V2] " Lai Jiangshan
2014-07-29 15:04 ` Tejun Heo
2014-07-30 0:32 ` Lai Jiangshan
2014-07-30 3:23 ` Tejun Heo
2014-07-30 3:46 ` Lai Jiangshan
2014-07-30 3:46 ` Tejun Heo
2014-07-26 3:04 ` Lai Jiangshan [this message]
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=1406343900-32423-4-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®