aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kthread.c')
-rw-r--r--kernel/kthread.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 3d3de633702e..4bfbff36d447 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -378,6 +378,19 @@ repeat:
378} 378}
379EXPORT_SYMBOL_GPL(kthread_worker_fn); 379EXPORT_SYMBOL_GPL(kthread_worker_fn);
380 380
381/* insert @work before @pos in @worker */
382static void insert_kthread_work(struct kthread_worker *worker,
383 struct kthread_work *work,
384 struct list_head *pos)
385{
386 lockdep_assert_held(&worker->lock);
387
388 list_add_tail(&work->node, pos);
389 work->queue_seq++;
390 if (likely(worker->task))
391 wake_up_process(worker->task);
392}
393
381/** 394/**
382 * queue_kthread_work - queue a kthread_work 395 * queue_kthread_work - queue a kthread_work
383 * @worker: target kthread_worker 396 * @worker: target kthread_worker
@@ -395,10 +408,7 @@ bool queue_kthread_work(struct kthread_worker *worker,
395 408
396 spin_lock_irqsave(&worker->lock, flags); 409 spin_lock_irqsave(&worker->lock, flags);
397 if (list_empty(&work->node)) { 410 if (list_empty(&work->node)) {
398 list_add_tail(&work->node, &worker->work_list); 411 insert_kthread_work(worker, work, &worker->work_list);
399 work->queue_seq++;
400 if (likely(worker->task))
401 wake_up_process(worker->task);
402 ret = true; 412 ret = true;
403 } 413 }
404 spin_unlock_irqrestore(&worker->lock, flags); 414 spin_unlock_irqrestore(&worker->lock, flags);
@@ -406,6 +416,18 @@ bool queue_kthread_work(struct kthread_worker *worker,
406} 416}
407EXPORT_SYMBOL_GPL(queue_kthread_work); 417EXPORT_SYMBOL_GPL(queue_kthread_work);
408 418
419struct kthread_flush_work {
420 struct kthread_work work;
421 struct completion done;
422};
423
424static void kthread_flush_work_fn(struct kthread_work *work)
425{
426 struct kthread_flush_work *fwork =
427 container_of(work, struct kthread_flush_work, work);
428 complete(&fwork->done);
429}
430
409/** 431/**
410 * flush_kthread_work - flush a kthread_work 432 * flush_kthread_work - flush a kthread_work
411 * @work: work to flush 433 * @work: work to flush
@@ -436,18 +458,6 @@ void flush_kthread_work(struct kthread_work *work)
436} 458}
437EXPORT_SYMBOL_GPL(flush_kthread_work); 459EXPORT_SYMBOL_GPL(flush_kthread_work);
438 460
439struct kthread_flush_work {
440 struct kthread_work work;
441 struct completion done;
442};
443
444static void kthread_flush_work_fn(struct kthread_work *work)
445{
446 struct kthread_flush_work *fwork =
447 container_of(work, struct kthread_flush_work, work);
448 complete(&fwork->done);
449}
450
451/** 461/**
452 * flush_kthread_worker - flush all current works on a kthread_worker 462 * flush_kthread_worker - flush all current works on a kthread_worker
453 * @worker: worker to flush 463 * @worker: worker to flush