Skip to content

Commit c88b086

Browse files
committed
sched: Clarify wake_up_q()'s write to task->wake_q.next
JIRA: https://issues.redhat.com/browse/RHEL-96250 commit bcc6244 Author: Jann Horn <jannh@google.com> Date: Wed Jan 29 20:53:03 2025 +0100 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 <jannh@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20250129-sched-wakeup-prettier-v1-1-2f51f5f663fa@google.com Signed-off-by: Phil Auld <pauld@redhat.com>
1 parent 8306224 commit c88b086

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
@@ -1021,9 +1021,10 @@ void wake_up_q(struct wake_q_head *head)
10211021
struct task_struct *task;
10221022

10231023
task = container_of(node, struct task_struct, wake_q);
1024-
/* Task can safely be re-inserted now: */
10251024
node = node->next;
1026-
task->wake_q.next = NULL;
1025+
/* pairs with cmpxchg_relaxed() in __wake_q_add() */
1026+
WRITE_ONCE(task->wake_q.next, NULL);
1027+
/* Task can safely be re-inserted now. */
10271028

10281029
/*
10291030
* wake_up_process() executes a full barrier, which pairs with

0 commit comments

Comments
 (0)