diff options
-rw-r--r-- | Documentation/DocBook/kernel-api.tmpl | 3 | ||||
-rw-r--r-- | kernel/workqueue.c | 58 |
2 files changed, 57 insertions, 4 deletions
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl index 356e34e6ce33..f8fe882e33dc 100644 --- a/Documentation/DocBook/kernel-api.tmpl +++ b/Documentation/DocBook/kernel-api.tmpl | |||
@@ -59,6 +59,9 @@ | |||
59 | !Iinclude/linux/hrtimer.h | 59 | !Iinclude/linux/hrtimer.h |
60 | !Ekernel/hrtimer.c | 60 | !Ekernel/hrtimer.c |
61 | </sect1> | 61 | </sect1> |
62 | <sect1><title>Workqueues and Kevents</title> | ||
63 | !Ekernel/workqueue.c | ||
64 | </sect1> | ||
62 | <sect1><title>Internal Functions</title> | 65 | <sect1><title>Internal Functions</title> |
63 | !Ikernel/exit.c | 66 | !Ikernel/exit.c |
64 | !Ikernel/signal.c | 67 | !Ikernel/signal.c |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index eebb1d839235..448e8f7b342d 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -93,9 +93,12 @@ static void __queue_work(struct cpu_workqueue_struct *cwq, | |||
93 | spin_unlock_irqrestore(&cwq->lock, flags); | 93 | spin_unlock_irqrestore(&cwq->lock, flags); |
94 | } | 94 | } |
95 | 95 | ||
96 | /* | 96 | /** |
97 | * Queue work on a workqueue. Return non-zero if it was successfully | 97 | * queue_work - queue work on a workqueue |
98 | * added. | 98 | * @wq: workqueue to use |
99 | * @work: work to queue | ||
100 | * | ||
101 | * Returns non-zero if it was successfully added. | ||
99 | * | 102 | * |
100 | * We queue the work to the CPU it was submitted, but there is no | 103 | * We queue the work to the CPU it was submitted, but there is no |
101 | * guarantee that it will be processed by that CPU. | 104 | * guarantee that it will be processed by that CPU. |
@@ -128,6 +131,14 @@ static void delayed_work_timer_fn(unsigned long __data) | |||
128 | __queue_work(per_cpu_ptr(wq->cpu_wq, cpu), work); | 131 | __queue_work(per_cpu_ptr(wq->cpu_wq, cpu), work); |
129 | } | 132 | } |
130 | 133 | ||
134 | /** | ||
135 | * queue_delayed_work - queue work on a workqueue after delay | ||
136 | * @wq: workqueue to use | ||
137 | * @work: work to queue | ||
138 | * @delay: number of jiffies to wait before queueing | ||
139 | * | ||
140 | * Returns non-zero if it was successfully added. | ||
141 | */ | ||
131 | int fastcall queue_delayed_work(struct workqueue_struct *wq, | 142 | int fastcall queue_delayed_work(struct workqueue_struct *wq, |
132 | struct work_struct *work, unsigned long delay) | 143 | struct work_struct *work, unsigned long delay) |
133 | { | 144 | { |
@@ -150,6 +161,15 @@ int fastcall queue_delayed_work(struct workqueue_struct *wq, | |||
150 | } | 161 | } |
151 | EXPORT_SYMBOL_GPL(queue_delayed_work); | 162 | EXPORT_SYMBOL_GPL(queue_delayed_work); |
152 | 163 | ||
164 | /** | ||
165 | * queue_delayed_work_on - queue work on specific CPU after delay | ||
166 | * @cpu: CPU number to execute work on | ||
167 | * @wq: workqueue to use | ||
168 | * @work: work to queue | ||
169 | * @delay: number of jiffies to wait before queueing | ||
170 | * | ||
171 | * Returns non-zero if it was successfully added. | ||
172 | */ | ||
153 | int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, | 173 | int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, |
154 | struct work_struct *work, unsigned long delay) | 174 | struct work_struct *work, unsigned long delay) |
155 | { | 175 | { |
@@ -275,8 +295,9 @@ static void flush_cpu_workqueue(struct cpu_workqueue_struct *cwq) | |||
275 | } | 295 | } |
276 | } | 296 | } |
277 | 297 | ||
278 | /* | 298 | /** |
279 | * flush_workqueue - ensure that any scheduled work has run to completion. | 299 | * flush_workqueue - ensure that any scheduled work has run to completion. |
300 | * @wq: workqueue to flush | ||
280 | * | 301 | * |
281 | * Forces execution of the workqueue and blocks until its completion. | 302 | * Forces execution of the workqueue and blocks until its completion. |
282 | * This is typically used in driver shutdown handlers. | 303 | * This is typically used in driver shutdown handlers. |
@@ -400,6 +421,12 @@ static void cleanup_workqueue_thread(struct workqueue_struct *wq, int cpu) | |||
400 | kthread_stop(p); | 421 | kthread_stop(p); |
401 | } | 422 | } |
402 | 423 | ||
424 | /** | ||
425 | * destroy_workqueue - safely terminate a workqueue | ||
426 | * @wq: target workqueue | ||
427 | * | ||
428 | * Safely destroy a workqueue. All work currently pending will be done first. | ||
429 | */ | ||
403 | void destroy_workqueue(struct workqueue_struct *wq) | 430 | void destroy_workqueue(struct workqueue_struct *wq) |
404 | { | 431 | { |
405 | int cpu; | 432 | int cpu; |
@@ -425,18 +452,41 @@ EXPORT_SYMBOL_GPL(destroy_workqueue); | |||
425 | 452 | ||
426 | static struct workqueue_struct *keventd_wq; | 453 | static struct workqueue_struct *keventd_wq; |
427 | 454 | ||
455 | /** | ||
456 | * schedule_work - put work task in global workqueue | ||
457 | * @work: job to be done | ||
458 | * | ||
459 | * This puts a job in the kernel-global workqueue. | ||
460 | */ | ||
428 | int fastcall schedule_work(struct work_struct *work) | 461 | int fastcall schedule_work(struct work_struct *work) |
429 | { | 462 | { |
430 | return queue_work(keventd_wq, work); | 463 | return queue_work(keventd_wq, work); |
431 | } | 464 | } |
432 | EXPORT_SYMBOL(schedule_work); | 465 | EXPORT_SYMBOL(schedule_work); |
433 | 466 | ||
467 | /** | ||
468 | * schedule_delayed_work - put work task in global workqueue after delay | ||
469 | * @work: job to be done | ||
470 | * @delay: number of jiffies to wait | ||
471 | * | ||
472 | * After waiting for a given time this puts a job in the kernel-global | ||
473 | * workqueue. | ||
474 | */ | ||
434 | int fastcall schedule_delayed_work(struct work_struct *work, unsigned long delay) | 475 | int fastcall schedule_delayed_work(struct work_struct *work, unsigned long delay) |
435 | { | 476 | { |
436 | return queue_delayed_work(keventd_wq, work, delay); | 477 | return queue_delayed_work(keventd_wq, work, delay); |
437 | } | 478 | } |
438 | EXPORT_SYMBOL(schedule_delayed_work); | 479 | EXPORT_SYMBOL(schedule_delayed_work); |
439 | 480 | ||
481 | /** | ||
482 | * schedule_delayed_work_on - queue work in global workqueue on CPU after delay | ||
483 | * @cpu: cpu to use | ||
484 | * @work: job to be done | ||
485 | * @delay: number of jiffies to wait | ||
486 | * | ||
487 | * After waiting for a given time this puts a job in the kernel-global | ||
488 | * workqueue on the specified CPU. | ||
489 | */ | ||
440 | int schedule_delayed_work_on(int cpu, | 490 | int schedule_delayed_work_on(int cpu, |
441 | struct work_struct *work, unsigned long delay) | 491 | struct work_struct *work, unsigned long delay) |
442 | { | 492 | { |