aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/task_work.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 21:08:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 21:08:07 -0400
commitd52bd54db8be8999df6df5a776f38c4f8b5e9cea (patch)
tree0d8f436e959bb975c002ddf12ea1bdc9adadd04f /kernel/task_work.c
parent8cbdd85bda499d028b8f128191f392d701e8e41d (diff)
parent3bd080e4d8f2351ee3e143f0ec9307cc95ae6639 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge yet more updates from Andrew Morton: - the rest of ocfs2 - various hotfixes, mainly MM - quite a bit of misc stuff - drivers, fork, exec, signals, etc. - printk updates - firmware - checkpatch - nilfs2 - more kexec stuff than usual - rapidio updates - w1 things * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (111 commits) ipc: delete "nr_ipc_ns" kcov: allow more fine-grained coverage instrumentation init/Kconfig: add clarification for out-of-tree modules config: add android config fragments init/Kconfig: ban CONFIG_LOCALVERSION_AUTO with allmodconfig relay: add global mode support for buffer-only channels init: allow blacklisting of module_init functions w1:omap_hdq: fix regression w1: add helper macro module_w1_family w1: remove need for ida and use PLATFORM_DEVID_AUTO rapidio/switches: add driver for IDT gen3 switches powerpc/fsl_rio: apply changes for RIO spec rev 3 rapidio: modify for rev.3 specification changes rapidio: change inbound window size type to u64 rapidio/idt_gen2: fix locking warning rapidio: fix error handling in mbox request/release functions rapidio/tsi721_dma: advance queue processing from transfer submit call rapidio/tsi721: add messaging mbox selector parameter rapidio/tsi721: add PCIe MRRS override parameter rapidio/tsi721_dma: add channel mask and queue size parameters ...
Diffstat (limited to 'kernel/task_work.c')
-rw-r--r--kernel/task_work.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/task_work.c b/kernel/task_work.c
index 6ab4842b00e8..d513051fcca2 100644
--- a/kernel/task_work.c
+++ b/kernel/task_work.c
@@ -29,7 +29,7 @@ task_work_add(struct task_struct *task, struct callback_head *work, bool notify)
29 struct callback_head *head; 29 struct callback_head *head;
30 30
31 do { 31 do {
32 head = ACCESS_ONCE(task->task_works); 32 head = READ_ONCE(task->task_works);
33 if (unlikely(head == &work_exited)) 33 if (unlikely(head == &work_exited))
34 return -ESRCH; 34 return -ESRCH;
35 work->next = head; 35 work->next = head;
@@ -57,6 +57,9 @@ task_work_cancel(struct task_struct *task, task_work_func_t func)
57 struct callback_head **pprev = &task->task_works; 57 struct callback_head **pprev = &task->task_works;
58 struct callback_head *work; 58 struct callback_head *work;
59 unsigned long flags; 59 unsigned long flags;
60
61 if (likely(!task->task_works))
62 return NULL;
60 /* 63 /*
61 * If cmpxchg() fails we continue without updating pprev. 64 * If cmpxchg() fails we continue without updating pprev.
62 * Either we raced with task_work_add() which added the 65 * Either we raced with task_work_add() which added the
@@ -64,8 +67,7 @@ task_work_cancel(struct task_struct *task, task_work_func_t func)
64 * we raced with task_work_run(), *pprev == NULL/exited. 67 * we raced with task_work_run(), *pprev == NULL/exited.
65 */ 68 */
66 raw_spin_lock_irqsave(&task->pi_lock, flags); 69 raw_spin_lock_irqsave(&task->pi_lock, flags);
67 while ((work = ACCESS_ONCE(*pprev))) { 70 while ((work = lockless_dereference(*pprev))) {
68 smp_read_barrier_depends();
69 if (work->func != func) 71 if (work->func != func)
70 pprev = &work->next; 72 pprev = &work->next;
71 else if (cmpxchg(pprev, work, work->next) == work) 73 else if (cmpxchg(pprev, work, work->next) == work)
@@ -95,7 +97,7 @@ void task_work_run(void)
95 * work_exited unless the list is empty. 97 * work_exited unless the list is empty.
96 */ 98 */
97 do { 99 do {
98 work = ACCESS_ONCE(task->task_works); 100 work = READ_ONCE(task->task_works);
99 head = !work && (task->flags & PF_EXITING) ? 101 head = !work && (task->flags & PF_EXITING) ?
100 &work_exited : NULL; 102 &work_exited : NULL;
101 } while (cmpxchg(&task->task_works, work, head) != work); 103 } while (cmpxchg(&task->task_works, work, head) != work);