Skip to contentSkip to conversation

sched: add the other missing clock update to migrate_task()

PATCH In review Mike Galbraith 2 participants 4 messages Nov 22, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: add the other missing clock update to migrate_task()

sched: add the other missing clock update to migrate_task()

When calling set_task_cpu(), we must update both runqueue clocks in order to get an accurate clock offset. Add it.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

LKML-Reference: <new-submission>

---
 kernel/sched.c |    1 +
 1 file changed, 1 insertion(+)
kernel/sched.c +1 -0
Index: linux-2.6/kernel/sched.c
===================================================================
@@ -2126,6 +2126,7 @@ migrate_task(struct task_struct *p, int
 	 */
 	if (!p->se.on_rq && !task_running(rq, p)) {
 		update_rq_clock(rq);
+		update_rq_clock(cpu_rq(dest_cpu));
 		set_task_cpu(p, dest_cpu);
 		return 0;
 	}
#1 lore raw
Quoted 20 lines · Mike Galbraith

sched: add the other missing clock update to migrate_task()

When calling set_task_cpu(), we must update both runqueue clocks in order to get an accurate clock offset. Add it.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>

LKML-Reference: <new-submission>

---
 kernel/sched.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6/kernel/sched.c
===================================================================

kernel/sched.c migrate_task(struct task_struct *p, int · line 2132

Quoted 7 lines
kernel/sched.c +1 -0
@@ -2126,6 +2126,7 @@ migrate_task(struct task_struct *p, int
 	 */
 	if (!p->se.on_rq && !task_running(rq, p)) {
 		update_rq_clock(rq);
+		update_rq_clock(cpu_rq(dest_cpu));
 		set_task_cpu(p, dest_cpu);
 		return 0;
 	}

We should make double_rq_lock() and double_lock_balance() behave equivalent wrt update_rq_clock().

Current, depending on CONFIG_PREEMPT, double_lock_balance() already updates both rq clocks.

#2 lore raw
Quoted 5 lines · Peter Zijlstra

We should make double_rq_lock() and double_lock_balance() behave equivalent wrt update_rq_clock().

Current, depending on CONFIG_PREEMPT, double_lock_balance() already updates both rq clocks.

Hm, right. Better plan. We can save an update in the wakeup path for the tasks racing for the wakeup case too. If the call is really a lock/unlock go away, we don't need to bother. Shave a ns or so.

-Mike

#3 lore raw
Quoted 9 lines · Mike Galbraith
Quoted 5 lines · Peter Zijlstra

We should make double_rq_lock() and double_lock_balance() behave equivalent wrt update_rq_clock().

Current, depending on CONFIG_PREEMPT, double_lock_balance() already updates both rq clocks.

Hm, right. Better plan.

Oops, nope. Consistency is still a good plan, however, that update is still needed, because it's the case where we're _not_ going to use the migration thread.

-Mike