summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAlan Stern2010-02-12 09:39:21 +0100
committerTejun Heo2010-04-30 08:57:25 +0200
commiteef6a7d5c2f38adadab8240fabf43730fe796482 (patch)
tree4ee96327e3f7880bea51bd4e05b37193915c00ae /kernel
parentworkqueue: flush_delayed_work: keep the original workqueue for re-queueing (diff)
downloadkernel-qcow2-linux-eef6a7d5c2f38adadab8240fabf43730fe796482.tar.gz
kernel-qcow2-linux-eef6a7d5c2f38adadab8240fabf43730fe796482.tar.xz
kernel-qcow2-linux-eef6a7d5c2f38adadab8240fabf43730fe796482.zip
workqueue: warn about flush_scheduled_work()
This patch (as1319) adds kerneldoc and a pointed warning to flush_scheduled_work(). Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/workqueue.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 5bfb213984b2..0225fea89340 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -845,6 +845,30 @@ int schedule_on_each_cpu(work_func_t func)
return 0;
}
+/**
+ * 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(keventd_wq);