Re: [PATCH] task_work: cleanup notification modes

From: Thomas Gleixner
Date: Sat Oct 17 2020 - 16:24:13 EST


On Sat, Oct 17 2020 at 09:36, Jens Axboe wrote:
> diff --git a/kernel/task_work.c b/kernel/task_work.c
> index 613b2d634af8..d82c224ab5d5 100644
> --- a/kernel/task_work.c
> +++ b/kernel/task_work.c
> @@ -9,23 +9,28 @@ static struct callback_head work_exited; /* all we need is ->next == NULL */
> * 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.
> + * Queue @work for task_work_run() below and notify the @task if @notify
> + * is @TWA_RESUME or @TWA_SIGNAL. @TWA_SIGNAL work like signals, in that the

s/work/works/

> + * 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.

It's also run before entering a guest. At least on x86, but all other
architectures should do the same.

> * 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.
> *
> - * 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 tht case.

s/tht/that/

Looks good otherwise.

Thanks,

tglx