Lines Matching +full:next +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0
7 static struct callback_head work_exited; /* all we need is ->next == NULL */
19 * task_work_add - ask the @task to execute @work->func()
36 * user mode, or before entering guest mode.
41 * Otherwise @work->func() will be called when the @task goes through one of
52 * 0 if succeeds or -ESRCH.
61 return -EINVAL; in task_work_add()
63 return -EINVAL; in task_work_add()
68 head = READ_ONCE(task->task_works); in task_work_add()
71 return -ESRCH; in task_work_add()
72 work->next = head; in task_work_add()
73 } while (!try_cmpxchg(&task->task_works, &head, work)); in task_work_add()
101 * task_work_cancel_match - cancel a pending work added by task_work_add()
114 struct callback_head **pprev = &task->task_works; in task_work_cancel_match()
126 raw_spin_lock_irqsave(&task->pi_lock, flags); in task_work_cancel_match()
130 pprev = &work->next; in task_work_cancel_match()
132 } else if (try_cmpxchg(pprev, &work, work->next)) in task_work_cancel_match()
135 raw_spin_unlock_irqrestore(&task->pi_lock, flags); in task_work_cancel_match()
142 return cb->func == data; in task_work_func_match()
146 * task_work_cancel_func - cancel a pending work matching a function added by task_work_add()
150 * Find the last queued pending work with ->func == @func and remove
168 * task_work_cancel - cancel a pending work added by task_work_add()
187 * task_work_run - execute the works added by task_work_add()
190 * Called before the task returns to the user-mode or stops, or when
197 struct callback_head *work, *head, *next; in task_work_run() local
201 * work->func() can do task_work_add(), do not set in task_work_run()
204 work = READ_ONCE(task->task_works); in task_work_run()
208 if (task->flags & PF_EXITING) in task_work_run()
213 } while (!try_cmpxchg(&task->task_works, &work, head)); in task_work_run()
220 * But it can remove another entry from the ->next list. in task_work_run()
222 raw_spin_lock_irq(&task->pi_lock); in task_work_run()
223 raw_spin_unlock_irq(&task->pi_lock); in task_work_run()
226 next = work->next; in task_work_run()
227 work->func(work); in task_work_run()
228 work = next; in task_work_run()