From: Greg Kroah-Hartman Date: Thu, 10 Aug 2017 16:27:59 +0000 (-0700) Subject: 4.12-stable patches X-Git-Tag: v4.12.6~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35d43a3b1d579556c0550c188b41e85de3a27787;p=thirdparty%2Fkernel%2Fstable-queue.git 4.12-stable patches added patches: workqueue-implicit-ordered-attribute-should-be-overridable.patch --- diff --git a/queue-4.12/series b/queue-4.12/series index 6fd42fba131..e1e19c9af34 100644 --- a/queue-4.12/series +++ b/queue-4.12/series @@ -97,6 +97,7 @@ net-mlx5e-schedule-overflow-check-work-to-mlx5e-workqueue.patch net-mlx5-fix-mlx5_add_flow_rules-call-with-correct-num-of-dests.patch udp6-fix-socket-leak-on-early-demux.patch net-phy-correctly-process-phy_halted-in-phy_stop_machine.patch +workqueue-implicit-ordered-attribute-should-be-overridable.patch ipv4-fib-fix-null-pointer-deref-during-fib_sync_down_dev.patch virtio_net-fix-truesize-for-mergeable-buffers.patch sparc64-measure-receiver-forward-progress-to-avoid-send-mondo-timeout.patch diff --git a/queue-4.12/workqueue-implicit-ordered-attribute-should-be-overridable.patch b/queue-4.12/workqueue-implicit-ordered-attribute-should-be-overridable.patch new file mode 100644 index 00000000000..d5c5afa72c6 --- /dev/null +++ b/queue-4.12/workqueue-implicit-ordered-attribute-should-be-overridable.patch @@ -0,0 +1,91 @@ +From 0a94efb5acbb6980d7c9ab604372d93cd507e4d8 Mon Sep 17 00:00:00 2001 +From: Tejun Heo +Date: Sun, 23 Jul 2017 08:36:15 -0400 +Subject: workqueue: implicit ordered attribute should be overridable + +From: Tejun Heo + +commit 0a94efb5acbb6980d7c9ab604372d93cd507e4d8 upstream. + +5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be +ordered") automatically enabled ordered attribute for unbound +workqueues w/ max_active == 1. Because ordered workqueues reject +max_active and some attribute changes, this implicit ordered mode +broke cases where the user creates an unbound workqueue w/ max_active +== 1 and later explicitly changes the related attributes. + +This patch distinguishes explicit and implicit ordered setting and +overrides from attribute changes if implict. + +Signed-off-by: Tejun Heo +Fixes: 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") +Cc: Holger Hoffstätte +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/workqueue.h | 4 +++- + kernel/workqueue.c | 13 +++++++++---- + 2 files changed, 12 insertions(+), 5 deletions(-) + +--- a/include/linux/workqueue.h ++++ b/include/linux/workqueue.h +@@ -323,6 +323,7 @@ enum { + + __WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */ + __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */ ++ __WQ_ORDERED_EXPLICIT = 1 << 18, /* internal: alloc_ordered_workqueue() */ + __WQ_LEGACY = 1 << 18, /* internal: create*_workqueue() */ + + WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */ +@@ -422,7 +423,8 @@ __alloc_workqueue_key(const char *fmt, u + * Pointer to the allocated workqueue on success, %NULL on failure. + */ + #define alloc_ordered_workqueue(fmt, flags, args...) \ +- alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args) ++ alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | \ ++ __WQ_ORDERED_EXPLICIT | (flags), 1, ##args) + + #define create_workqueue(name) \ + alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name)) +--- a/kernel/workqueue.c ++++ b/kernel/workqueue.c +@@ -3744,8 +3744,12 @@ static int apply_workqueue_attrs_locked( + return -EINVAL; + + /* creating multiple pwqs breaks ordering guarantee */ +- if (WARN_ON((wq->flags & __WQ_ORDERED) && !list_empty(&wq->pwqs))) +- return -EINVAL; ++ if (!list_empty(&wq->pwqs)) { ++ if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) ++ return -EINVAL; ++ ++ wq->flags &= ~__WQ_ORDERED; ++ } + + ctx = apply_wqattrs_prepare(wq, attrs); + if (!ctx) +@@ -4129,13 +4133,14 @@ void workqueue_set_max_active(struct wor + struct pool_workqueue *pwq; + + /* disallow meddling with max_active for ordered workqueues */ +- if (WARN_ON(wq->flags & __WQ_ORDERED)) ++ if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) + return; + + max_active = wq_clamp_max_active(max_active, wq->flags, wq->name); + + mutex_lock(&wq->mutex); + ++ wq->flags &= ~__WQ_ORDERED; + wq->saved_max_active = max_active; + + for_each_pwq(pwq, wq) +@@ -5263,7 +5268,7 @@ int workqueue_sysfs_register(struct work + * attributes breaks ordering guarantee. Disallow exposing ordered + * workqueues. + */ +- if (WARN_ON(wq->flags & __WQ_ORDERED)) ++ if (WARN_ON(wq->flags & __WQ_ORDERED_EXPLICIT)) + return -EINVAL; + + wq->wq_dev = wq_dev = kzalloc(sizeof(*wq_dev), GFP_KERNEL);