Sacrifice throughput to ensure low latency at all load levels. Probably not a good thing to do by default. -ck --- linux-2.6.35-ck1.orig/kernel/sched_bfs.c 2010-09-23 08:56:29.871350304 +1000 +++ linux-2.6.35-ck1/kernel/sched_bfs.c 2010-09-24 17:08:30.935726514 +1000 @@ -2069,6 +2041,7 @@ update_cpu_clock(struct rq *rq, struct t /* time_slice accounting is done in usecs to avoid overflow on 32bit */ if (rq->rq_policy != SCHED_FIFO && p != idle) { long time_diff = rq->clock - rq->rq_last_ran; + int qnr = queued_notrunning(); /* * There should be less than or equal to one jiffy worth, and not @@ -2076,11 +2049,23 @@ update_cpu_clock(struct rq *rq, struct t * time_slice accounting. */ if (unlikely(time_diff <= 0)) - time_diff = JIFFIES_TO_NS(1) / 2; + time_diff = HALF_JIFFY_NS; else if (unlikely(time_diff > JIFFIES_TO_NS(1))) time_diff = JIFFIES_TO_NS(1); - rq->rq_time_slice -= NS_TO_US(time_diff); + /* + * If we are overloaded, then shorten the effective timeslices + * to ensure latencies are kept as small as is possible by + * making them expire at a rate proportional to load/CPUs. + */ + if (qnr > 0) { + int nol = num_online_cpus(); + + time_diff /= nol; + time_diff *= qnr + nol; + } + time_diff = NS_TO_US(time_diff); + rq->rq_time_slice -= time_diff; } rq->rq_last_ran = rq->timekeep_clock = rq->clock; }