mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Libin <huawei.libin@huawei.com>
To: <tj@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <wangyijing@huawei.com>,
	<guohanjun@huawei.com>, <wujianguo@huawei.com>
Subject: [PATCH] workqueue: fix ordered workqueue in multi NUMA nodes platform
Date: Thu, 5 Sep 2013 13:10:44 +0800	[thread overview]
Message-ID: <1378357844-15632-1-git-send-email-huawei.libin@huawei.com> (raw)

In platform with multi NUMA nodes, there is no ordering guarantee
with the workqueue created by calling alloc_ordered_workqueue().

Add member ordered_pwq in structure workqueue_struct, used to hold
the first choice of pwq, in order to avoid breaking its ordering
guarantee under enqueueing work in different NUMA nodes.

Signed-off-by: Libin <huawei.libin@huawei.com>
---
 kernel/workqueue.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 29b7985..42c6c29 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -249,6 +249,7 @@ struct workqueue_struct {
 
 	struct workqueue_attrs	*unbound_attrs;	/* WQ: only for unbound wqs */
 	struct pool_workqueue	*dfl_pwq;	/* WQ: only for unbound wqs */
+	struct pool_workqueue   *ordered_pwq;   /* WQ: only for ordered wqs */
 
 #ifdef CONFIG_SYSFS
 	struct wq_device	*wq_dev;	/* I: for sysfs interface */
@@ -1326,10 +1327,19 @@ retry:
 
 	/* pwq which will be used unless @work is executing elsewhere */
 	if (!(wq->flags & WQ_UNBOUND))
-		pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);
-	else
-		pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu));
+	    pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);
+	else {
+	    pwq = unbound_pwq_by_node(wq, cpu_to_node(cpu));
+	    if (wq->flags & __WQ_ORDERED) {
+		mutex_lock(&wq->mutex);
+		if (wq->ordered_pwq == NULL)
+		    wq->ordered_pwq = pwq;
+		else
+		    pwq = wq->ordered_pwq;
+		mutex_unlock(&wq->mutex);
+	    }
 
+	}
 	/*
 	 * If @work was previously on a different pool, it might still be
 	 * running there, in which case the work needs to be queued on that
-- 
1.8.2.1



             reply	other threads:[~2013-09-05  5:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-05  5:10 Libin [this message]
2013-09-05 16:30 ` [PATCH] workqueue: fix ordered workqueue in NUMA setups 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=1378357844-15632-1-git-send-email-huawei.libin@huawei.com \
    --to=huawei.libin@huawei.com \
    --cc=guohanjun@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=wangyijing@huawei.com \
    --cc=wujianguo@huawei.com \
    /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®