diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2020-11-04 18:14:52 +0100 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2020-11-04 18:14:52 +0100 |
| commit | 01be83eea08d6d9f9209843e2e084505fba4053f (patch) | |
| tree | 95b456e1ac40399fd5f55b57ae0936643bea1836 /kernel/task_work.c | |
| parent | 45ff510517f3b1354a3d9c273ad5e5e8d08312cb (diff) | |
| parent | 9d820f68b2bdba5b2e7bf135123c3f57c5051d05 (diff) | |
| download | cachepc-linux-01be83eea08d6d9f9209843e2e084505fba4053f.tar.gz cachepc-linux-01be83eea08d6d9f9209843e2e084505fba4053f.zip | |
Merge branch 'core/urgent' into core/entry
Pick up the entry fix before further modifications.
Diffstat (limited to 'kernel/task_work.c')
| -rw-r--r-- | kernel/task_work.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/kernel/task_work.c b/kernel/task_work.c index ae058893913c..15b087286bea 100644 --- a/kernel/task_work.c +++ b/kernel/task_work.c @@ -37,23 +37,28 @@ static void task_work_notify_signal(struct task_struct *task) * task_work_add - ask the @task to execute @work->func() * @task: the task which should run the callback * @work: the callback to run - * @notify: send the notification if true + * @notify: how to notify the targeted task * - * Queue @work for task_work_run() below and notify the @task if @notify. - * Fails if the @task is exiting/exited and thus it can't process this @work. - * Otherwise @work->func() will be called when the @task returns from kernel - * mode or exits. + * Queue @work for task_work_run() below and notify the @task if @notify + * is @TWA_RESUME or @TWA_SIGNAL. @TWA_SIGNAL works like signals, in that the + * it will interrupt the targeted task and run the task_work. @TWA_RESUME + * work is run only when the task exits the kernel and returns to user mode, + * or before entering guest mode. Fails if the @task is exiting/exited and thus + * it can't process this @work. Otherwise @work->func() will be called when the + * @task goes through one of the aforementioned transitions, or exits. * - * This is like the signal handler which runs in kernel mode, but it doesn't - * try to wake up the @task. + * If the targeted task is exiting, then an error is returned and the work item + * is not queued. It's up to the caller to arrange for an alternative mechanism + * in that case. * - * Note: there is no ordering guarantee on works queued here. + * Note: there is no ordering guarantee on works queued here. The task_work + * list is LIFO. * * RETURNS: * 0 if succeeds or -ESRCH. */ -int -task_work_add(struct task_struct *task, struct callback_head *work, int notify) +int task_work_add(struct task_struct *task, struct callback_head *work, + enum task_work_notify_mode notify) { struct callback_head *head; @@ -65,12 +70,17 @@ task_work_add(struct task_struct *task, struct callback_head *work, int notify) } while (cmpxchg(&task->task_works, head, work) != head); switch (notify) { + case TWA_NONE: + break; case TWA_RESUME: set_notify_resume(task); break; case TWA_SIGNAL: task_work_notify_signal(task); break; + default: + WARN_ON_ONCE(1); + break; } return 0; |
