From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Tejun Heo <tj@kernel.org>, linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: [PATCH 6/7] workqueue: node-awared allocation for unbound pool
Date: Thu, 4 Apr 2013 10:05:37 +0800 [thread overview]
Message-ID: <1365041143-3088-6-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1365041143-3088-1-git-send-email-laijs@cn.fujitsu.com>
calculate the node of the pool earlier, and allocate the pool
from the node.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
kernel/workqueue.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 737646d..3f33077 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -539,7 +539,7 @@ static int worker_pool_assign_id(struct worker_pool *pool)
* @wq: the target workqueue
* @node: the node ID
*
- * This must be called either with pwq_lock held or sched RCU read locked.
+ * This must be called either with wq->mutex held or sched RCU read locked.
* If the pwq needs to be used beyond the locking in effect, the caller is
* responsible for guaranteeing that the pwq stays online.
*/
@@ -3555,7 +3555,7 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
{
u32 hash = wqattrs_hash(attrs);
struct worker_pool *pool;
- int node;
+ int pool_node = NUMA_NO_NODE, node;
lockdep_assert_held(&wq_pool_mutex);
@@ -3563,29 +3563,30 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
hash_for_each_possible(unbound_pool_hash, pool, hash_node, hash) {
if (wqattrs_equal(pool->attrs, attrs)) {
pool->refcnt++;
- goto out_unlock;
+ goto out_pool;
}
}
- /* nope, create a new one */
- pool = kzalloc(sizeof(*pool), GFP_KERNEL);
- if (!pool || init_worker_pool(pool) < 0)
- goto fail;
-
- lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */
- copy_workqueue_attrs(pool->attrs, attrs);
-
/* if cpumask is contained inside a NUMA node, we belong to that node */
if (wq_numa_enabled) {
for_each_node(node) {
- if (cpumask_subset(pool->attrs->cpumask,
+ if (cpumask_subset(attrs->cpumask,
wq_numa_possible_cpumask[node])) {
- pool->node = node;
+ pool_node = node;
break;
}
}
}
+ /* create a new one */
+ pool = kzalloc_node(sizeof(*pool), GFP_KERNEL, pool_node);
+ if (!pool || init_worker_pool(pool) < 0)
+ goto fail;
+
+ lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */
+ copy_workqueue_attrs(pool->attrs, attrs);
+ pool->node = pool_node;
+
if (worker_pool_assign_id(pool) < 0)
goto fail;
@@ -3595,7 +3596,7 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
/* install */
hash_add(unbound_pool_hash, &pool->hash_node, hash);
-out_unlock:
+out_pool:
return pool;
fail:
if (pool)
--
1.7.7.6
next prev parent reply other threads:[~2013-04-04 2:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-04 2:05 [PATCH 1/7] workqueue: add __WQ_FREEZING and remove POOL_FREEZING Lai Jiangshan
2013-04-04 2:05 ` [PATCH 2/7] workqueue: set __WQ_FREEZING only when freezable Lai Jiangshan
2013-04-04 2:05 ` [PATCH 3/7] workqueue: rename rebind_workers() to associate_cpu_pool() Lai Jiangshan
2013-04-04 14:15 ` Tejun Heo
2013-04-04 2:05 ` [PATCH 4/7] workqueue: simplify workqueue_cpu_up_callback(CPU_ONLINE) Lai Jiangshan
2013-04-04 2:05 ` [PATCH 5/7] workqueue, use default pwq when fail to allocate node pwd Lai Jiangshan
2013-04-04 14:34 ` Tejun Heo
2013-04-04 2:05 ` Lai Jiangshan [this message]
2013-04-04 14:38 ` [PATCH 6/7] workqueue: node-awared allocation for unbound pool Tejun Heo
2013-04-04 2:05 ` [PATCH 7/7] workqueue: avoid false negative WARN_ON() Lai Jiangshan
2013-04-04 14:55 ` [PATCH] workqueue: avoid false negative WARN_ON() in destroy_workqueue() Tejun Heo
2013-04-05 7:39 ` Lai Jiangshan
2013-04-04 14:12 ` [PATCH 1/7] workqueue: add __WQ_FREEZING and remove POOL_FREEZING Tejun Heo
2013-04-20 16:12 ` Lai Jiangshan
2013-04-21 1:29 ` Tejun Heo
2014-03-25 9:56 ` [PATCH] " Lai Jiangshan
2014-03-27 12:08 ` Lai Jiangshan
2014-03-27 14:48 ` Tejun Heo
2014-04-16 19:51 ` Tejun Heo
2014-04-16 23:58 ` Lai Jiangshan
2014-04-17 15:29 ` Tejun Heo
2014-04-16 20:50 ` 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=1365041143-3088-6-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®