diff options
author | Peter Zijlstra <peterz@infradead.org> | 2015-02-17 07:07:38 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-02-18 08:27:28 -0500 |
commit | 74b8a4cb6ce3685049ee124243a52238c5cabe55 (patch) | |
tree | 72ea9b09e55fbe3a59e365e8e51a712057309347 /kernel/sched/core.c | |
parent | e07e0d4cb0c4bfe822ec8491cc06269096a38bea (diff) |
sched: Clarify ordering between task_rq_lock() and move_queued_task()
There was a wee bit of confusion around the exact ordering here;
clarify things.
Reported-by: Kirill Tkhai <ktkhai@parallels.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20150217121258.GM5029@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r-- | kernel/sched/core.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 1f37fe7f77a4..fd0a6ed21849 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -341,6 +341,22 @@ static struct rq *task_rq_lock(struct task_struct *p, unsigned long *flags) | |||
341 | raw_spin_lock_irqsave(&p->pi_lock, *flags); | 341 | raw_spin_lock_irqsave(&p->pi_lock, *flags); |
342 | rq = task_rq(p); | 342 | rq = task_rq(p); |
343 | raw_spin_lock(&rq->lock); | 343 | raw_spin_lock(&rq->lock); |
344 | /* | ||
345 | * move_queued_task() task_rq_lock() | ||
346 | * | ||
347 | * ACQUIRE (rq->lock) | ||
348 | * [S] ->on_rq = MIGRATING [L] rq = task_rq() | ||
349 | * WMB (__set_task_cpu()) ACQUIRE (rq->lock); | ||
350 | * [S] ->cpu = new_cpu [L] task_rq() | ||
351 | * [L] ->on_rq | ||
352 | * RELEASE (rq->lock) | ||
353 | * | ||
354 | * If we observe the old cpu in task_rq_lock, the acquire of | ||
355 | * the old rq->lock will fully serialize against the stores. | ||
356 | * | ||
357 | * If we observe the new cpu in task_rq_lock, the acquire will | ||
358 | * pair with the WMB to ensure we must then also see migrating. | ||
359 | */ | ||
344 | if (likely(rq == task_rq(p) && !task_on_rq_migrating(p))) | 360 | if (likely(rq == task_rq(p) && !task_on_rq_migrating(p))) |
345 | return rq; | 361 | return rq; |
346 | raw_spin_unlock(&rq->lock); | 362 | raw_spin_unlock(&rq->lock); |