diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-09-11 17:23:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:58:27 -0400 |
commit | 892f6668f3a7088c7e30049c3d8e1844531602dc (patch) | |
tree | 68ad5c81f3bccaae821a891f1611135056829dc0 /kernel | |
parent | 205e550a0fb469ae73f91a903f27f4f63e774037 (diff) |
task_work: documentation
No functional changes, just comments.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/task_work.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/kernel/task_work.c b/kernel/task_work.c index 6ee09856f725..8727032e3a6f 100644 --- a/kernel/task_work.c +++ b/kernel/task_work.c | |||
@@ -4,6 +4,23 @@ | |||
4 | 4 | ||
5 | static struct callback_head work_exited; /* all we need is ->next == NULL */ | 5 | static struct callback_head work_exited; /* all we need is ->next == NULL */ |
6 | 6 | ||
7 | /** | ||
8 | * task_work_add - ask the @task to execute @work->func() | ||
9 | * @task: the task which should run the callback | ||
10 | * @work: the callback to run | ||
11 | * @notify: send the notification if true | ||
12 | * | ||
13 | * Queue @work for task_work_run() below and notify the @task if @notify. | ||
14 | * Fails if the @task is exiting/exited and thus it can't process this @work. | ||
15 | * Otherwise @work->func() will be called when the @task returns from kernel | ||
16 | * mode or exits. | ||
17 | * | ||
18 | * This is like the signal handler which runs in kernel mode, but it doesn't | ||
19 | * try to wake up the @task. | ||
20 | * | ||
21 | * RETURNS: | ||
22 | * 0 if succeeds or -ESRCH. | ||
23 | */ | ||
7 | int | 24 | int |
8 | task_work_add(struct task_struct *task, struct callback_head *work, bool notify) | 25 | task_work_add(struct task_struct *task, struct callback_head *work, bool notify) |
9 | { | 26 | { |
@@ -21,6 +38,17 @@ task_work_add(struct task_struct *task, struct callback_head *work, bool notify) | |||
21 | return 0; | 38 | return 0; |
22 | } | 39 | } |
23 | 40 | ||
41 | /** | ||
42 | * task_work_cancel - cancel a pending work added by task_work_add() | ||
43 | * @task: the task which should execute the work | ||
44 | * @func: identifies the work to remove | ||
45 | * | ||
46 | * Find the last queued pending work with ->func == @func and remove | ||
47 | * it from queue. | ||
48 | * | ||
49 | * RETURNS: | ||
50 | * The found work or NULL if not found. | ||
51 | */ | ||
24 | struct callback_head * | 52 | struct callback_head * |
25 | task_work_cancel(struct task_struct *task, task_work_func_t func) | 53 | task_work_cancel(struct task_struct *task, task_work_func_t func) |
26 | { | 54 | { |
@@ -46,6 +74,14 @@ task_work_cancel(struct task_struct *task, task_work_func_t func) | |||
46 | return work; | 74 | return work; |
47 | } | 75 | } |
48 | 76 | ||
77 | /** | ||
78 | * task_work_run - execute the works added by task_work_add() | ||
79 | * | ||
80 | * Flush the pending works. Should be used by the core kernel code. | ||
81 | * Called before the task returns to the user-mode or stops, or when | ||
82 | * it exits. In the latter case task_work_add() can no longer add the | ||
83 | * new work after task_work_run() returns. | ||
84 | */ | ||
49 | void task_work_run(void) | 85 | void task_work_run(void) |
50 | { | 86 | { |
51 | struct task_struct *task = current; | 87 | struct task_struct *task = current; |