Lines Matching full:work
664 * when they finish. There is defined a safe point for freezing when one work
673 struct kthread_work *work; in kthread_worker_fn() local
696 work = NULL; in kthread_worker_fn()
699 work = list_first_entry(&worker->work_list, in kthread_worker_fn()
701 list_del_init(&work->node); in kthread_worker_fn()
703 worker->current_work = work; in kthread_worker_fn()
706 if (work) { in kthread_worker_fn()
708 work->func(work); in kthread_worker_fn()
809 * Returns true when the work could not be queued at the moment.
814 struct kthread_work *work) in queuing_blocked() argument
818 return !list_empty(&work->node) || work->canceling; in queuing_blocked()
822 struct kthread_work *work) in kthread_insert_work_sanity_check() argument
825 WARN_ON_ONCE(!list_empty(&work->node)); in kthread_insert_work_sanity_check()
826 /* Do not use a work with >1 worker, see kthread_queue_work() */ in kthread_insert_work_sanity_check()
827 WARN_ON_ONCE(work->worker && work->worker != worker); in kthread_insert_work_sanity_check()
830 /* insert @work before @pos in @worker */
832 struct kthread_work *work, in kthread_insert_work() argument
835 kthread_insert_work_sanity_check(worker, work); in kthread_insert_work()
837 list_add_tail(&work->node, pos); in kthread_insert_work()
838 work->worker = worker; in kthread_insert_work()
846 * @work: kthread_work to queue
848 * Queue @work to work processor @task for async execution. @task
850 * if @work was successfully queued, %false if it was already pending.
852 * Reinitialize the work if it needs to be used by another worker.
856 struct kthread_work *work) in kthread_queue_work() argument
862 if (!queuing_blocked(worker, work)) { in kthread_queue_work()
863 kthread_insert_work(worker, work, &worker->work_list); in kthread_queue_work()
873 * delayed work when the timer expires.
882 struct kthread_work *work = &dwork->work; in kthread_delayed_work_timer_fn() local
883 struct kthread_worker *worker = work->worker; in kthread_delayed_work_timer_fn()
887 * This might happen when a pending work is reinitialized. in kthread_delayed_work_timer_fn()
894 /* Work must not be used with >1 worker, see kthread_queue_work(). */ in kthread_delayed_work_timer_fn()
895 WARN_ON_ONCE(work->worker != worker); in kthread_delayed_work_timer_fn()
897 /* Move the work from worker->delayed_work_list. */ in kthread_delayed_work_timer_fn()
898 WARN_ON_ONCE(list_empty(&work->node)); in kthread_delayed_work_timer_fn()
899 list_del_init(&work->node); in kthread_delayed_work_timer_fn()
900 if (!work->canceling) in kthread_delayed_work_timer_fn()
901 kthread_insert_work(worker, work, &worker->work_list); in kthread_delayed_work_timer_fn()
912 struct kthread_work *work = &dwork->work; in __kthread_queue_delayed_work() local
917 * If @delay is 0, queue @dwork->work immediately. This is for in __kthread_queue_delayed_work()
923 kthread_insert_work(worker, work, &worker->work_list); in __kthread_queue_delayed_work()
928 kthread_insert_work_sanity_check(worker, work); in __kthread_queue_delayed_work()
930 list_add(&work->node, &worker->delayed_work_list); in __kthread_queue_delayed_work()
931 work->worker = worker; in __kthread_queue_delayed_work()
937 * kthread_queue_delayed_work - queue the associated kthread work
943 * If the work has not been pending it starts a timer that will queue
944 * the work after the given @delay. If @delay is zero, it queues the
945 * work immediately.
947 * Return: %false if the @work has already been pending. It means that
948 * either the timer was running or the work was queued. It returns %true
955 struct kthread_work *work = &dwork->work; in kthread_queue_delayed_work() local
961 if (!queuing_blocked(worker, work)) { in kthread_queue_delayed_work()
972 struct kthread_work work; member
976 static void kthread_flush_work_fn(struct kthread_work *work) in kthread_flush_work_fn() argument
979 container_of(work, struct kthread_flush_work, work); in kthread_flush_work_fn()
985 * @work: work to flush
987 * If @work is queued or executing, wait for it to finish execution.
989 void kthread_flush_work(struct kthread_work *work) in kthread_flush_work() argument
992 KTHREAD_WORK_INIT(fwork.work, kthread_flush_work_fn), in kthread_flush_work()
998 worker = work->worker; in kthread_flush_work()
1003 /* Work must not be used with >1 worker, see kthread_queue_work(). */ in kthread_flush_work()
1004 WARN_ON_ONCE(work->worker != worker); in kthread_flush_work()
1006 if (!list_empty(&work->node)) in kthread_flush_work()
1007 kthread_insert_work(worker, &fwork.work, work->node.next); in kthread_flush_work()
1008 else if (worker->current_work == work) in kthread_flush_work()
1009 kthread_insert_work(worker, &fwork.work, in kthread_flush_work()
1022 * This function removes the work from the worker queue. Also it makes sure
1023 * that it won't get queued later via the delayed work's timer.
1025 * The work might still be in use when this function finishes. See the
1028 * Return: %true if @work was pending and successfully canceled,
1029 * %false if @work was not pending
1031 static bool __kthread_cancel_work(struct kthread_work *work, bool is_dwork, in __kthread_cancel_work() argument
1037 container_of(work, struct kthread_delayed_work, work); in __kthread_cancel_work()
1038 struct kthread_worker *worker = work->worker; in __kthread_cancel_work()
1046 work->canceling++; in __kthread_cancel_work()
1050 work->canceling--; in __kthread_cancel_work()
1054 * Try to remove the work from a worker list. It might either in __kthread_cancel_work()
1057 if (!list_empty(&work->node)) { in __kthread_cancel_work()
1058 list_del_init(&work->node); in __kthread_cancel_work()
1066 * kthread_mod_delayed_work - modify delay of or queue a kthread delayed work
1068 * @dwork: kthread delayed work to queue
1073 * @work is guaranteed to be queued immediately.
1078 * A special case is when the work is being canceled in parallel.
1092 struct kthread_work *work = &dwork->work; in kthread_mod_delayed_work() local
1099 if (!work->worker) in kthread_mod_delayed_work()
1102 /* Work must not be used with >1 worker, see kthread_queue_work() */ in kthread_mod_delayed_work()
1103 WARN_ON_ONCE(work->worker != worker); in kthread_mod_delayed_work()
1105 /* Do not fight with another command that is canceling this work. */ in kthread_mod_delayed_work()
1106 if (work->canceling) in kthread_mod_delayed_work()
1109 ret = __kthread_cancel_work(work, true, &flags); in kthread_mod_delayed_work()
1118 static bool __kthread_cancel_work_sync(struct kthread_work *work, bool is_dwork) in __kthread_cancel_work_sync() argument
1120 struct kthread_worker *worker = work->worker; in __kthread_cancel_work_sync()
1128 /* Work must not be used with >1 worker, see kthread_queue_work(). */ in __kthread_cancel_work_sync()
1129 WARN_ON_ONCE(work->worker != worker); in __kthread_cancel_work_sync()
1131 ret = __kthread_cancel_work(work, is_dwork, &flags); in __kthread_cancel_work_sync()
1133 if (worker->current_work != work) in __kthread_cancel_work_sync()
1137 * The work is in progress and we need to wait with the lock released. in __kthread_cancel_work_sync()
1140 work->canceling++; in __kthread_cancel_work_sync()
1142 kthread_flush_work(work); in __kthread_cancel_work_sync()
1144 work->canceling--; in __kthread_cancel_work_sync()
1153 * kthread_cancel_work_sync - cancel a kthread work and wait for it to finish
1154 * @work: the kthread work to cancel
1156 * Cancel @work and wait for its execution to finish. This function
1157 * can be used even if the work re-queues itself. On return from this
1158 * function, @work is guaranteed to be not pending or executing on any CPU.
1160 * kthread_cancel_work_sync(&delayed_work->work) must not be used for
1163 * The caller must ensure that the worker on which @work was last
1166 * Return: %true if @work was pending, %false otherwise.
1168 bool kthread_cancel_work_sync(struct kthread_work *work) in kthread_cancel_work_sync() argument
1170 return __kthread_cancel_work_sync(work, false); in kthread_cancel_work_sync()
1175 * kthread_cancel_delayed_work_sync - cancel a kthread delayed work and
1177 * @dwork: the kthread delayed work to cancel
1185 return __kthread_cancel_work_sync(&dwork->work, true); in kthread_cancel_delayed_work_sync()
1199 KTHREAD_WORK_INIT(fwork.work, kthread_flush_work_fn), in kthread_flush_worker()
1203 kthread_queue_work(worker, &fwork.work); in kthread_flush_worker()