aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-03-12 14:30:04 -0400
committerTejun Heo <tj@kernel.org>2013-03-12 14:30:04 -0400
commit9e8cd2f5898ab6710ad81f4583fada08bf8049a4 (patch)
treebb3950d07a5e23be7817eaaa0517066b7d5f82fb /include/linux
parentc9178087acd71b4ea010ea48e147cf66952d2da9 (diff)
workqueue: implement apply_workqueue_attrs()
Implement apply_workqueue_attrs() which applies workqueue_attrs to the specified unbound workqueue by creating a new pwq (pool_workqueue) linked to worker_pool with the specified attributes. A new pwq is linked at the head of wq->pwqs instead of tail and __queue_work() verifies that the first unbound pwq has positive refcnt before choosing it for the actual queueing. This is to cover the case where creation of a new pwq races with queueing. As base ref on a pwq won't be dropped without making another pwq the first one, __queue_work() is guaranteed to make progress and not add work item to a dead pwq. init_and_link_pwq() is updated to return the last first pwq the new pwq replaced, which is put by apply_workqueue_attrs(). Note that apply_workqueue_attrs() is almost identical to unbound pwq part of alloc_and_link_pwqs(). The only difference is that there is no previous first pwq. apply_workqueue_attrs() is implemented to handle such cases and replaces unbound pwq handling in alloc_and_link_pwqs(). Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/workqueue.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index c270b4eedf16..e152394fa7eb 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -410,6 +410,8 @@ extern void destroy_workqueue(struct workqueue_struct *wq);
410 410
411struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask); 411struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask);
412void free_workqueue_attrs(struct workqueue_attrs *attrs); 412void free_workqueue_attrs(struct workqueue_attrs *attrs);
413int apply_workqueue_attrs(struct workqueue_struct *wq,
414 const struct workqueue_attrs *attrs);
413 415
414extern bool queue_work_on(int cpu, struct workqueue_struct *wq, 416extern bool queue_work_on(int cpu, struct workqueue_struct *wq,
415 struct work_struct *work); 417 struct work_struct *work);