mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 5/7] workqueue, use default pwq when fail to allocate node pwd
Date: Thu, 4 Apr 2013 10:05:36 +0800	[thread overview]
Message-ID: <1365041143-3088-5-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1365041143-3088-1-git-send-email-laijs@cn.fujitsu.com>

When we fail to allocate the node pwq, we can use the default pwq
for the node.

Thus we can avoid failure after allocated default pwq, and remove
some code for failure path.

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

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a383eaf..737646d 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3751,17 +3751,6 @@ static struct pool_workqueue *alloc_unbound_pwq(struct workqueue_struct *wq,
 	return pwq;
 }
 
-/* undo alloc_unbound_pwq(), used only in the error path */
-static void free_unbound_pwq(struct pool_workqueue *pwq)
-{
-	lockdep_assert_held(&wq_pool_mutex);
-
-	if (pwq) {
-		put_unbound_pool(pwq->pool);
-		kfree(pwq);
-	}
-}
-
 /**
  * wq_calc_node_mask - calculate a wq_attrs' cpumask for the specified node
  * @attrs: the wq_attrs of interest
@@ -3891,12 +3880,12 @@ int apply_workqueue_attrs(struct workqueue_struct *wq,
 	for_each_node(node) {
 		if (wq_calc_node_cpumask(attrs, node, -1, tmp_attrs->cpumask)) {
 			pwq_tbl[node] = alloc_unbound_pwq(wq, tmp_attrs);
-			if (!pwq_tbl[node])
-				goto enomem_pwq;
-		} else {
-			dfl_pwq->refcnt++;
-			pwq_tbl[node] = dfl_pwq;
+			if (pwq_tbl[node])
+				continue;
+			/* fallback to dfl_pwq if the allocation failed */
 		}
+		dfl_pwq->refcnt++;
+		pwq_tbl[node] = dfl_pwq;
 	}
 
 	mutex_unlock(&wq_pool_mutex);
@@ -3931,10 +3920,6 @@ out_free:
 	return ret;
 
 enomem_pwq:
-	free_unbound_pwq(dfl_pwq);
-	for_each_node(node)
-		if (pwq_tbl && pwq_tbl[node] != dfl_pwq)
-			free_unbound_pwq(pwq_tbl[node]);
 	mutex_unlock(&wq_pool_mutex);
 	put_online_cpus();
 enomem:
@@ -4017,7 +4002,8 @@ static void wq_update_unbound_numa(struct workqueue_struct *wq, int cpu,
 	if (!pwq) {
 		pr_warning("workqueue: allocation failed while updating NUMA affinity of \"%s\"\n",
 			   wq->name);
-		goto out_unlock;
+		mutex_lock(&wq->mutex);
+		goto use_dfl_pwq;
 	}
 
 	/*
-- 
1.7.7.6


  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 ` Lai Jiangshan [this message]
2013-04-04 14:34   ` [PATCH 5/7] workqueue, use default pwq when fail to allocate node pwd Tejun Heo
2013-04-04  2:05 ` [PATCH 6/7] workqueue: node-awared allocation for unbound pool Lai Jiangshan
2013-04-04 14:38   ` 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-5-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®