>From c9b7e910de032ce0851ec297575d42bc8f07a4a3 Mon Sep 17 00:00:00 2001 From: Stephan Baerwolf Date: Wed, 20 Jul 2011 15:06:17 +0200 Subject: [PATCH 3/3] sched: fix incorrect use of "ideal_runtime"s timeunit In "check_preempt_tick()" (kernel/sched_fair.c:1093) a ulong called "ideal_runtime" stores a timeslice of the current task (scheduling entity). This time complies real cpu-time. At the end of the same function (nr_running > 1) this (real) time is compared with a virtual-runtime-delta. Obviously the timeunits (real vs. virtual) didn't fit. Using "wakeup_preempt_entity()" instead should fix this in a even more general way. Signed-off-by: Stephan Baerwolf --- kernel/sched_fair.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 66dc9f7..61d002d 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c @@ -1083,6 +1083,9 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) update_cfs_shares(cfs_rq); } +static int +wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se); + /* * Preempt the current task with a newly woken task if needed: */ @@ -1115,14 +1118,11 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) return; if (cfs_rq->nr_running > 1) { + // check, if maybe curr has finally overtaken the remaining leftmost struct sched_entity *se = __pick_first_entity(cfs_rq); - s64 delta = curr->vruntime - se->vruntime; - - if (delta < 0) - return; - - if (delta > ideal_runtime) - resched_task(rq_of(cfs_rq)->curr); + + if (wakeup_preempt_entity(curr, se) > 0) + resched_task(rq_of(cfs_rq)->curr); } } @@ -1156,8 +1156,6 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) se->prev_sum_exec_runtime = se->sum_exec_runtime; } -static int -wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se); /* * Pick the next process, keeping these things in mind, in this order: -- 1.7.3.4