aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kthread.c')
-rw-r--r--kernel/kthread.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 12695e68ed00..f874300dfce5 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -823,3 +823,26 @@ void kthread_flush_worker(struct kthread_worker *worker)
823 wait_for_completion(&fwork.done); 823 wait_for_completion(&fwork.done);
824} 824}
825EXPORT_SYMBOL_GPL(kthread_flush_worker); 825EXPORT_SYMBOL_GPL(kthread_flush_worker);
826
827/**
828 * kthread_destroy_worker - destroy a kthread worker
829 * @worker: worker to be destroyed
830 *
831 * Flush and destroy @worker. The simple flush is enough because the kthread
832 * worker API is used only in trivial scenarios. There are no multi-step state
833 * machines needed.
834 */
835void kthread_destroy_worker(struct kthread_worker *worker)
836{
837 struct task_struct *task;
838
839 task = worker->task;
840 if (WARN_ON(!task))
841 return;
842
843 kthread_flush_worker(worker);
844 kthread_stop(task);
845 WARN_ON(!list_empty(&worker->work_list));
846 kfree(worker);
847}
848EXPORT_SYMBOL(kthread_destroy_worker);