* [PATCH wq/for-3.18] workqueue: apply __WQ_ORDERED to create_singlethread_workqueue()
@ 2014-09-12 19:53 Tejun Heo
2014-09-12 20:12 ` Tejun Heo
2014-09-12 20:24 ` [PATCH v2 wq/for-3.17-fixes] " Tejun Heo
0 siblings, 2 replies; 3+ messages in thread
From: Tejun Heo @ 2014-09-12 19:53 UTC (permalink / raw)
To: Lai Jiangshan, linux-kernel
Cc: Gustavo Luiz Duarte, Mike Anderson, Tomas Henzl
>From e141deffe6a30cfe7dd6ad97f21afa85b80ca3ac Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Sat, 13 Sep 2014 04:14:30 +0900
create_singlethread_workqueue() is a compat interface for singled
threaded workqueue which maps to ordered workqueue w/ rescuer in the
current implementation. create_singlethread_workqueue() currently
implemented by invoking alloc_workqueue() w/ appropriate parameters.
8719dceae2f9 ("workqueue: reject adjusting max_active or applying
attrs to ordered workqueues") introduced __WQ_ORDERED to protect
ordered workqueues against dynamic attribute changes which can break
ordering guarantees but forgot to apply it to
create_singlethread_workqueue(). While this can be potentially
dangerous, this isn't a problem in practice given the existing uses of
dynamic attribute changes.
Let's make create_singlethread_workqueue() wrap
alloc_ordered_workqueue() instead so that it inherits __WQ_ORDERED and
can implicitly track future ordered_workqueue changes.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Mike Anderson <mike.anderson@us.ibm.com>
Cc: Gustavo Luiz Duarte <gduarte@redhat.com>
Cc: Tomas Henzl <thenzl@redhat.com>
---
Applied to wq/for-3.18.
Thanks.
include/linux/workqueue.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index a0cc2e9..b996e6cd 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -419,7 +419,7 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, \
1, (name))
#define create_singlethread_workqueue(name) \
- alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name))
+ alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name)
extern void destroy_workqueue(struct workqueue_struct *wq);
--
1.9.3
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH wq/for-3.18] workqueue: apply __WQ_ORDERED to create_singlethread_workqueue()
2014-09-12 19:53 [PATCH wq/for-3.18] workqueue: apply __WQ_ORDERED to create_singlethread_workqueue() Tejun Heo
@ 2014-09-12 20:12 ` Tejun Heo
2014-09-12 20:24 ` [PATCH v2 wq/for-3.17-fixes] " Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2014-09-12 20:12 UTC (permalink / raw)
To: Lai Jiangshan, linux-kernel
Cc: Gustavo Luiz Duarte, Mike Anderson, Tomas Henzl
On Sat, Sep 13, 2014 at 04:53:28AM +0900, Tejun Heo wrote:
> From e141deffe6a30cfe7dd6ad97f21afa85b80ca3ac Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj@kernel.org>
> Date: Sat, 13 Sep 2014 04:14:30 +0900
>
> create_singlethread_workqueue() is a compat interface for singled
> threaded workqueue which maps to ordered workqueue w/ rescuer in the
> current implementation. create_singlethread_workqueue() currently
> implemented by invoking alloc_workqueue() w/ appropriate parameters.
>
> 8719dceae2f9 ("workqueue: reject adjusting max_active or applying
> attrs to ordered workqueues") introduced __WQ_ORDERED to protect
> ordered workqueues against dynamic attribute changes which can break
> ordering guarantees but forgot to apply it to
> create_singlethread_workqueue(). While this can be potentially
> dangerous, this isn't a problem in practice given the existing uses of
> dynamic attribute changes.
>
> Let's make create_singlethread_workqueue() wrap
> alloc_ordered_workqueue() instead so that it inherits __WQ_ORDERED and
> can implicitly track future ordered_workqueue changes.
Oops, this is the right change but w/ wrong description and branch.
W/o __WQ_ORDERED, create_singlethread_workqueue() is broken on NUMA
setups. Will respin the patch.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v2 wq/for-3.17-fixes] workqueue: apply __WQ_ORDERED to create_singlethread_workqueue()
2014-09-12 19:53 [PATCH wq/for-3.18] workqueue: apply __WQ_ORDERED to create_singlethread_workqueue() Tejun Heo
2014-09-12 20:12 ` Tejun Heo
@ 2014-09-12 20:24 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2014-09-12 20:24 UTC (permalink / raw)
To: Tejun Heo
Cc: Lai Jiangshan, linux-kernel, Gustavo Luiz Duarte, Mike Anderson,
Tomas Henzl,
"workqueue: implement NUMA affinity for unbound
workqueues"
>From e09c2c295468476a239d13324ce9042ec4de05eb Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Sat, 13 Sep 2014 04:14:30 +0900
create_singlethread_workqueue() is a compat interface for single
threaded workqueue which maps to ordered workqueue w/ rescuer in the
current implementation. create_singlethread_workqueue() currently
implemented by invoking alloc_workqueue() w/ appropriate parameters.
8719dceae2f9 ("workqueue: reject adjusting max_active or applying
attrs to ordered workqueues") introduced __WQ_ORDERED to protect
ordered workqueues against dynamic attribute changes which can break
ordering guarantees but forgot to apply it to
create_singlethread_workqueue(). This in itself is okay as nobody
currently uses dynamic attribute change on workqueues created with
create_singlethread_workqueue().
However, 4c16bd327c ("workqueue: implement NUMA affinity for unbound
workqueues") broke singlethreaded guarantee for ordered workqueues
through allocating a separate pool_workqueue on each NUMA node by
default. A later change 8a2b75384444 ("workqueue: fix ordered
workqueues in NUMA setups") fixed it by allocating only one global
pool_workqueue if __WQ_ORDERED is set.
Combined, the __WQ_ORDERED omission in create_singlethread_workqueue()
became critical breaking its single threadedness and ordering
guarantee.
Let's make create_singlethread_workqueue() wrap
alloc_ordered_workqueue() instead so that it inherits __WQ_ORDERED and
can implicitly track future ordered_workqueue changes.
v2: I missed that __WQ_ORDERED now protects against pwq splitting
across NUMA nodes and incorrectly described the patch as a
nice-to-have fix to protect against future dynamic attribute
usages. Oleg pointed out that this is actually a critical
breakage due to 8a2b75384444 ("workqueue: fix ordered workqueues
in NUMA setups").
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Mike Anderson <mike.anderson@us.ibm.com>
Cc: Oleg Nesterov <onestero@redhat.com>
Cc: Gustavo Luiz Duarte <gduarte@redhat.com>
Cc: Tomas Henzl <thenzl@redhat.com>
Cc: stable@vger.kernel.org
Fixes: 4c16bd327c ("workqueue: implement NUMA affinity for unbound workqueues")
---
Applied to wq/for-3.17-fixes.
Thanks.
include/linux/workqueue.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index a0cc2e9..b996e6cd 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -419,7 +419,7 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, \
1, (name))
#define create_singlethread_workqueue(name) \
- alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name))
+ alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name)
extern void destroy_workqueue(struct workqueue_struct *wq);
--
1.9.3
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-12 20:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-12 19:53 [PATCH wq/for-3.18] workqueue: apply __WQ_ORDERED to create_singlethread_workqueue() Tejun Heo
2014-09-12 20:12 ` Tejun Heo
2014-09-12 20:24 ` [PATCH v2 wq/for-3.17-fixes] " Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome