last_ran isn't being set reliably and on tasks that run for under one timer tick, they may be seen as using up their timeslice the next time they're scheduled. The lower the Hz, the more relevant this change will be. Bug reported by Serge Belyshev. timeslice() can be an int. Patch by _sid_ try_preempt need not check for rq_prio == highest_prio as it will always be by that point in the code. Patch by _sid_. -ck --- include/linux/sched.h | 2 +- kernel/sched_bfs.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) Index: linux-2.6.38.3-ck1/kernel/sched_bfs.c =================================================================== --- linux-2.6.38.3-ck1.orig/kernel/sched_bfs.c 2011-04-21 17:29:50.440288664 +1000 +++ linux-2.6.38.3-ck1/kernel/sched_bfs.c 2011-04-21 17:30:11.876955334 +1000 @@ -149,7 +149,7 @@ * The quota handed out to tasks of all priority levels when refilling their * time_slice. */ -static inline unsigned long timeslice(void) +static inline int timeslice(void) { return MS_TO_US(rr_interval); } @@ -1413,8 +1413,8 @@ if (rq_prio < highest_prio) continue; - if (rq_prio > highest_prio || (rq_prio == highest_prio && - deadline_after(rq->rq_deadline, latest_deadline))) { + if (rq_prio > highest_prio || + deadline_after(rq->rq_deadline, latest_deadline)) { latest_deadline = rq->rq_deadline; highest_prio = rq_prio; highest_prio_rq = rq; @@ -2928,7 +2928,7 @@ { rq->rq_time_slice = p->time_slice; rq->rq_deadline = p->deadline; - rq->rq_last_ran = p->last_ran; + rq->rq_last_ran = p->last_ran = rq->clock; rq->rq_policy = p->policy; rq->rq_prio = p->prio; if (p != rq->idle) Index: linux-2.6.38.3-ck1/include/linux/sched.h =================================================================== --- linux-2.6.38.3-ck1.orig/include/linux/sched.h 2011-04-21 21:01:51.290288668 +1000 +++ linux-2.6.38.3-ck1/include/linux/sched.h 2011-04-21 21:02:04.280288667 +1000 @@ -1570,7 +1570,7 @@ static inline void print_scheduler_version(void) { - printk(KERN_INFO"BFS CPU scheduler v0.400 by Con Kolivas.\n"); + printk(KERN_INFO"BFS CPU scheduler v0.401 by Con Kolivas.\n"); } static inline int iso_task(struct task_struct *p)