All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] sched: ensure than a child can't start left of it's parent's vruntime at fork() time
@ 2009-09-08 11:16 Mike Galbraith
  0 siblings, 0 replies; only message in thread
From: Mike Galbraith @ 2009-09-08 11:16 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra


sched: ensure than a child can't start left of it's parent's vruntime at fork() time.

With START_DEBIT we make room for the new task, but with child_runs_first,
the debit lands on the parent when we swap vruntimes.  There's nothing to
prevent the parent's vruntime having been right of min_vruntime at fork()
time, meaning that the child can gain vruntime, thus increasing scheduling
latency for waiters.

Signed-off-by: Mike Galbraith <efault@gmx.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>

diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index cc97ea4..eb1269c 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -728,11 +728,11 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
 
 			vruntime -= thresh;
 		}
-
-		/* ensure we never gain time by being placed backwards. */
-		vruntime = max_vruntime(se->vruntime, vruntime);
 	}
 
+	/* ensure we never gain time by being placed backwards. */
+	vruntime = max_vruntime(se->vruntime, vruntime);
+
 	se->vruntime = vruntime;
 }
 
@@ -1756,6 +1757,8 @@ static void task_new_fair(struct rq *rq, struct task_struct *p)
 	sched_info_queued(p);
 
 	update_curr(cfs_rq);
+	if (curr)
+		se->vruntime = curr->vruntime;	
 	place_entity(cfs_rq, se, 1);
 
 	/* 'curr' will be NULL if the child belongs to a different group */



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-08 11:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-08 11:16 [patch] sched: ensure than a child can't start left of it's parent's vruntime at fork() time Mike Galbraith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.