workqueue: misc cleanup
cover workqueue: misc cleanup
patch1&2 are simple cleaups and reflect to recently changes.
patch3 just moves code.
Lai Jiangshan (3):
workqueue: remove the declaration of copy_workqueue_attrs()
workqueue: remove the lock from wq_sysfs_prep_attrs()
workqueue: move flush_scheduled_work() to workqueue.h
include/linux/workqueue.h | 30 +++++++++++++++++++++++++++++- kernel/workqueue.c | 36 ++---------------------------------- 2 files changed, 31 insertions(+), 35 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/3 workqueue: remove the declaration of copy_workqueue_attrs()
This pre-declaration was unneeded since a previous refactor patch 6ba94429c8e7 ("workqueue: Reorder sysfs code").
--- kernel/workqueue.c | 2 -- 1 file changed, 2 deletions(-)
kernel/workqueue.c +0 -2
@@ -337,8 +337,6 @@ struct workqueue_struct *system_freezable_power_efficient_wq __read_mostly;EXPORT_SYMBOL_GPL (system_freezable_power_efficient_wq);static int worker_thread (void *__worker); -static void copy_workqueue_attrs (struct workqueue_attrs *to, -const struct workqueue_attrs *from);static void workqueue_sysfs_unregister (struct workqueue_struct *wq);#define CREATE_TRACE_POINTS
Signature · 1 line
2.1.0
PATCH 2/3 workqueue: remove the lock from wq_sysfs_prep_attrs()
In reply to Lai JiangshanReading to wq->unbound_attrs requires protection of either wq_pool_mutex or wq->mutex, and wq_sysfs_prep_attrs() is called with wq_pool_mutex held, so we don't need to grab wq->mutex here.
--- kernel/workqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/workqueue.c +2 -2
@@ -4941,13 +4941,13 @@ static struct workqueue_attrs *wq_sysfs_prep_attrs(struct workqueue_struct *wq) {struct workqueue_attrs *attrs; +lockdep_assert_held (&wq_pool_mutex); + attrs =alloc_workqueue_attrs (GFP_KERNEL );if (!attrs)return NULL ; -mutex_lock (&wq->mutex);copy_workqueue_attrs (attrs, wq->unbound_attrs); -mutex_unlock (&wq->mutex);return attrs; }
Signature · 1 line
2.1.0
PATCH 3/3 workqueue: move flush_scheduled_work() to workqueue.h
In reply to Lai Jiangshanflush_scheduled_work() is just a simple call to flush_work().
--- include/linux/workqueue.h | 30 +++++++++++++++++++++++++++++- kernel/workqueue.c | 30 ------------------------------ 2 files changed, 29 insertions(+), 31 deletions(-)
include/linux/workqueue.h +29 -1
@@ -435,7 +435,6 @@ extern bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq,extern void flush_workqueue (struct workqueue_struct *wq);extern void drain_workqueue (struct workqueue_struct *wq); -extern void flush_scheduled_work (void );extern int schedule_on_each_cpu (work_func_t func);
@@ -532,6 +531,35 @@ static inline bool schedule_work(struct work_struct *work) }/** +* flush_scheduled_work - ensure that any scheduled work has run to completion. +* +* Forces execution of the kernel-global workqueue and blocks until its +* completion. +* +* Think twice before calling this function! It's very easy to get into +* trouble if you don't take great care. Either of the following situations +* will lead to deadlock: +* +* One of the work items currently on the workqueue needs to acquire +* a lock held by your code or its caller. +* +* Your code is running in the context of a work routine. +* +* They will be detected by lockdep when they occur, but the first might not +* occur very often. It depends on what work items are on the workqueue and +* what locks they need, which you have no control over. +* +* In most situations flushing the entire workqueue is overkill; you merely +* need to know that a particular work item isn't queued and isn't running. +* In such cases you should use cancel_delayed_work_sync() or +* cancel_work_sync() instead. +*/ +static inline void flush_scheduled_work (void ) +{ +flush_workqueue (system_wq); +} + +/** * schedule_delayed_work_on - queue work in global workqueue on CPU after delay * @cpu: cpu to use * @dwork: job to be done
kernel/workqueue.c +0 -30
@@ -2959,36 +2959,6 @@ int schedule_on_each_cpu(work_func_t func) }/** -* flush_scheduled_work - ensure that any scheduled work has run to completion. -* -* Forces execution of the kernel-global workqueue and blocks until its -* completion. -* -* Think twice before calling this function! It's very easy to get into -* trouble if you don't take great care. Either of the following situations -* will lead to deadlock: -* -* One of the work items currently on the workqueue needs to acquire -* a lock held by your code or its caller. -* -* Your code is running in the context of a work routine. -* -* They will be detected by lockdep when they occur, but the first might not -* occur very often. It depends on what work items are on the workqueue and -* what locks they need, which you have no control over. -* -* In most situations flushing the entire workqueue is overkill; you merely -* need to know that a particular work item isn't queued and isn't running. -* In such cases you should use cancel_delayed_work_sync() or -* cancel_work_sync() instead. -*/ -void flush_scheduled_work (void ) -{ -flush_workqueue (system_wq); -} -EXPORT_SYMBOL (flush_scheduled_work); - -/** * execute_in_process_context - reliably execute the routine with user context * @fn: the function to execute * @ew: guaranteed storage for the execute work structure (must
Signature · 1 line
2.1.0
Tejun Heo
maintainerQuoted 3 lines · Lai Jiangshan
patch1&2 are simple cleaups and reflect to recently changes.
patch3 just moves code.
Applied 1-3 to wq/for-4.2.
Thanks.
Signature · 1 line
tejun