aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/workqueue.h3
-rw-r--r--kernel/workqueue.c9
2 files changed, 11 insertions, 1 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 1751ec4c47c9..5668ab249af5 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -295,6 +295,7 @@ enum {
295 WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */ 295 WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */
296 296
297 __WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */ 297 __WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */
298 __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
298 299
299 WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */ 300 WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */
300 WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */ 301 WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */
@@ -397,7 +398,7 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
397 * Pointer to the allocated workqueue on success, %NULL on failure. 398 * Pointer to the allocated workqueue on success, %NULL on failure.
398 */ 399 */
399#define alloc_ordered_workqueue(fmt, flags, args...) \ 400#define alloc_ordered_workqueue(fmt, flags, args...) \
400 alloc_workqueue(fmt, WQ_UNBOUND | (flags), 1, ##args) 401 alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
401 402
402#define create_workqueue(name) \ 403#define create_workqueue(name) \
403 alloc_workqueue((name), WQ_MEM_RECLAIM, 1) 404 alloc_workqueue((name), WQ_MEM_RECLAIM, 1)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 590f4d048ec7..cecd4ffe2c40 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3494,9 +3494,14 @@ int apply_workqueue_attrs(struct workqueue_struct *wq,
3494 struct pool_workqueue *pwq, *last_pwq; 3494 struct pool_workqueue *pwq, *last_pwq;
3495 struct worker_pool *pool; 3495 struct worker_pool *pool;
3496 3496
3497 /* only unbound workqueues can change attributes */
3497 if (WARN_ON(!(wq->flags & WQ_UNBOUND))) 3498 if (WARN_ON(!(wq->flags & WQ_UNBOUND)))
3498 return -EINVAL; 3499 return -EINVAL;
3499 3500
3501 /* creating multiple pwqs breaks ordering guarantee */
3502 if (WARN_ON((wq->flags & __WQ_ORDERED) && !list_empty(&wq->pwqs)))
3503 return -EINVAL;
3504
3500 pwq = kmem_cache_zalloc(pwq_cache, GFP_KERNEL); 3505 pwq = kmem_cache_zalloc(pwq_cache, GFP_KERNEL);
3501 if (!pwq) 3506 if (!pwq)
3502 return -ENOMEM; 3507 return -ENOMEM;
@@ -3752,6 +3757,10 @@ void workqueue_set_max_active(struct workqueue_struct *wq, int max_active)
3752{ 3757{
3753 struct pool_workqueue *pwq; 3758 struct pool_workqueue *pwq;
3754 3759
3760 /* disallow meddling with max_active for ordered workqueues */
3761 if (WARN_ON(wq->flags & __WQ_ORDERED))
3762 return;
3763
3755 max_active = wq_clamp_max_active(max_active, wq->flags, wq->name); 3764 max_active = wq_clamp_max_active(max_active, wq->flags, wq->name);
3756 3765
3757 spin_lock_irq(&workqueue_lock); 3766 spin_lock_irq(&workqueue_lock);