• Home
  • Raw
  • Download

Lines Matching full:work

710  * when they finish. There is defined a safe point for freezing when one work
719 struct kthread_work *work; in kthread_worker_fn() local
742 work = NULL; in kthread_worker_fn()
745 work = list_first_entry(&worker->work_list, in kthread_worker_fn()
747 list_del_init(&work->node); in kthread_worker_fn()
749 worker->current_work = work; in kthread_worker_fn()
752 if (work) { in kthread_worker_fn()
754 work->func(work); in kthread_worker_fn()
855 * Returns true when the work could not be queued at the moment.
860 struct kthread_work *work) in queuing_blocked() argument
864 return !list_empty(&work->node) || work->canceling; in queuing_blocked()
868 struct kthread_work *work) in kthread_insert_work_sanity_check() argument
871 WARN_ON_ONCE(!list_empty(&work->node)); in kthread_insert_work_sanity_check()
872 /* Do not use a work with >1 worker, see kthread_queue_work() */ in kthread_insert_work_sanity_check()
873 WARN_ON_ONCE(work->worker && work->worker != worker); in kthread_insert_work_sanity_check()
876 /* insert @work before @pos in @worker */
878 struct kthread_work *work, in kthread_insert_work() argument
881 kthread_insert_work_sanity_check(worker, work); in kthread_insert_work()
883 list_add_tail(&work->node, pos); in kthread_insert_work()
884 work->worker = worker; in kthread_insert_work()
892 * @work: kthread_work to queue
894 * Queue @work to work processor @task for async execution. @task
896 * if @work was successfully queued, %false if it was already pending.
898 * Reinitialize the work if it needs to be used by another worker.
902 struct kthread_work *work) in kthread_queue_work() argument
908 if (!queuing_blocked(worker, work)) { in kthread_queue_work()
909 kthread_insert_work(worker, work, &worker->work_list); in kthread_queue_work()
919 * delayed work when the timer expires.
928 struct kthread_work *work = &dwork->work; in kthread_delayed_work_timer_fn() local
929 struct kthread_worker *worker = work->worker; in kthread_delayed_work_timer_fn()
933 * This might happen when a pending work is reinitialized. in kthread_delayed_work_timer_fn()
940 /* Work must not be used with >1 worker, see kthread_queue_work(). */ in kthread_delayed_work_timer_fn()
941 WARN_ON_ONCE(work->worker != worker); in kthread_delayed_work_timer_fn()
943 /* Move the work from worker->delayed_work_list. */ in kthread_delayed_work_timer_fn()
944 WARN_ON_ONCE(list_empty(&work->node)); in kthread_delayed_work_timer_fn()
945 list_del_init(&work->node); in kthread_delayed_work_timer_fn()
946 if (!work->canceling) in kthread_delayed_work_timer_fn()
947 kthread_insert_work(worker, work, &worker->work_list); in kthread_delayed_work_timer_fn()
958 struct kthread_work *work = &dwork->work; in __kthread_queue_delayed_work() local
964 * If @delay is 0, queue @dwork->work immediately. This is for in __kthread_queue_delayed_work()
970 kthread_insert_work(worker, work, &worker->work_list); in __kthread_queue_delayed_work()
975 kthread_insert_work_sanity_check(worker, work); in __kthread_queue_delayed_work()
977 list_add(&work->node, &worker->delayed_work_list); in __kthread_queue_delayed_work()
978 work->worker = worker; in __kthread_queue_delayed_work()
984 * kthread_queue_delayed_work - queue the associated kthread work
990 * If the work has not been pending it starts a timer that will queue
991 * the work after the given @delay. If @delay is zero, it queues the
992 * work immediately.
994 * Return: %false if the @work has already been pending. It means that
995 * either the timer was running or the work was queued. It returns %true
1002 struct kthread_work *work = &dwork->work; in kthread_queue_delayed_work() local
1008 if (!queuing_blocked(worker, work)) { in kthread_queue_delayed_work()
1019 struct kthread_work work; member
1023 static void kthread_flush_work_fn(struct kthread_work *work) in kthread_flush_work_fn() argument
1026 container_of(work, struct kthread_flush_work, work); in kthread_flush_work_fn()
1032 * @work: work to flush
1034 * If @work is queued or executing, wait for it to finish execution.
1036 void kthread_flush_work(struct kthread_work *work) in kthread_flush_work() argument
1039 KTHREAD_WORK_INIT(fwork.work, kthread_flush_work_fn), in kthread_flush_work()
1045 worker = work->worker; in kthread_flush_work()
1050 /* Work must not be used with >1 worker, see kthread_queue_work(). */ in kthread_flush_work()
1051 WARN_ON_ONCE(work->worker != worker); in kthread_flush_work()
1053 if (!list_empty(&work->node)) in kthread_flush_work()
1054 kthread_insert_work(worker, &fwork.work, work->node.next); in kthread_flush_work()
1055 else if (worker->current_work == work) in kthread_flush_work()
1056 kthread_insert_work(worker, &fwork.work, in kthread_flush_work()
1070 * not manipulate the work list_head any longer.
1075 static void kthread_cancel_delayed_work_timer(struct kthread_work *work, in kthread_cancel_delayed_work_timer() argument
1079 container_of(work, struct kthread_delayed_work, work); in kthread_cancel_delayed_work_timer()
1080 struct kthread_worker *worker = work->worker; in kthread_cancel_delayed_work_timer()
1088 work->canceling++; in kthread_cancel_delayed_work_timer()
1092 work->canceling--; in kthread_cancel_delayed_work_timer()
1096 * This function removes the work from the worker queue.
1099 * the timer used by delayed work is not running, e.g. by calling
1102 * The work might still be in use when this function finishes. See the
1105 * Return: %true if @work was pending and successfully canceled,
1106 * %false if @work was not pending
1108 static bool __kthread_cancel_work(struct kthread_work *work) in __kthread_cancel_work() argument
1111 * Try to remove the work from a worker list. It might either in __kthread_cancel_work()
1114 if (!list_empty(&work->node)) { in __kthread_cancel_work()
1115 list_del_init(&work->node); in __kthread_cancel_work()
1123 * kthread_mod_delayed_work - modify delay of or queue a kthread delayed work
1125 * @dwork: kthread delayed work to queue
1130 * @work is guaranteed to be queued immediately.
1134 * A special case is when the work is being canceled in parallel.
1149 struct kthread_work *work = &dwork->work; in kthread_mod_delayed_work() local
1156 if (!work->worker) { in kthread_mod_delayed_work()
1161 /* Work must not be used with >1 worker, see kthread_queue_work() */ in kthread_mod_delayed_work()
1162 WARN_ON_ONCE(work->worker != worker); in kthread_mod_delayed_work()
1165 * Temporary cancel the work but do not fight with another command in kthread_mod_delayed_work()
1166 * that is canceling the work as well. in kthread_mod_delayed_work()
1172 * when doing so. But the work can be removed from the queue (list) in kthread_mod_delayed_work()
1176 kthread_cancel_delayed_work_timer(work, &flags); in kthread_mod_delayed_work()
1177 if (work->canceling) { in kthread_mod_delayed_work()
1182 ret = __kthread_cancel_work(work); in kthread_mod_delayed_work()
1192 static bool __kthread_cancel_work_sync(struct kthread_work *work, bool is_dwork) in __kthread_cancel_work_sync() argument
1194 struct kthread_worker *worker = work->worker; in __kthread_cancel_work_sync()
1202 /* Work must not be used with >1 worker, see kthread_queue_work(). */ in __kthread_cancel_work_sync()
1203 WARN_ON_ONCE(work->worker != worker); in __kthread_cancel_work_sync()
1206 kthread_cancel_delayed_work_timer(work, &flags); in __kthread_cancel_work_sync()
1208 ret = __kthread_cancel_work(work); in __kthread_cancel_work_sync()
1210 if (worker->current_work != work) in __kthread_cancel_work_sync()
1214 * The work is in progress and we need to wait with the lock released. in __kthread_cancel_work_sync()
1217 work->canceling++; in __kthread_cancel_work_sync()
1219 kthread_flush_work(work); in __kthread_cancel_work_sync()
1221 work->canceling--; in __kthread_cancel_work_sync()
1230 * kthread_cancel_work_sync - cancel a kthread work and wait for it to finish
1231 * @work: the kthread work to cancel
1233 * Cancel @work and wait for its execution to finish. This function
1234 * can be used even if the work re-queues itself. On return from this
1235 * function, @work is guaranteed to be not pending or executing on any CPU.
1237 * kthread_cancel_work_sync(&delayed_work->work) must not be used for
1240 * The caller must ensure that the worker on which @work was last
1243 * Return: %true if @work was pending, %false otherwise.
1245 bool kthread_cancel_work_sync(struct kthread_work *work) in kthread_cancel_work_sync() argument
1247 return __kthread_cancel_work_sync(work, false); in kthread_cancel_work_sync()
1252 * kthread_cancel_delayed_work_sync - cancel a kthread delayed work and
1254 * @dwork: the kthread delayed work to cancel
1262 return __kthread_cancel_work_sync(&dwork->work, true); in kthread_cancel_delayed_work_sync()
1276 KTHREAD_WORK_INIT(fwork.work, kthread_flush_work_fn), in kthread_flush_worker()
1280 kthread_queue_work(worker, &fwork.work); in kthread_flush_worker()