Skip to content

Commit bcc6244

Browse files
thejhPeter Zijlstra
authored andcommitted
sched: Clarify wake_up_q()'s write to task->wake_q.next
Clarify that wake_up_q() does an atomic write to task->wake_q.next, after which a concurrent __wake_q_add() can immediately overwrite task->wake_q.next again. Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 9065ce6 commit bcc6244

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/sched/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,9 +1055,10 @@ void wake_up_q(struct wake_q_head *head)
10551055
struct task_struct *task;
10561056

10571057
task = container_of(node, struct task_struct, wake_q);
1058-
/* Task can safely be re-inserted now: */
10591058
node = node->next;
1060-
task->wake_q.next = NULL;
1059+
/* pairs with cmpxchg_relaxed() in __wake_q_add() */
1060+
WRITE_ONCE(task->wake_q.next, NULL);
1061+
/* Task can safely be re-inserted now. */
10611062

10621063
/*
10631064
* wake_up_process() executes a full barrier, which pairs with

0 commit comments

Comments
 (0)