From: Con Kolivas Attached is an incremental patch against 2.5.74-mm2 with more interactivity work. Audio should be quite resistant to skips with this, and it should not induce further unfairness. Changes: The sleep_avg buffer was not needed with the improved semantics in O2int so it has been removed entirely as it created regressions in O2int. A small change to the idle detection code to only make tasks with enough accumulated sleep_avg become idle. Minor cleanups and clarified code. Other issues: Jerky mouse with heavy page rendering in web browsers remains. This is a different issue to the audio and will need some more thought. The patch is also available for download here: http://kernel.kolivas.org/2.5 Note for those who wish to get smooth X desktop feel now for their own use, the granularity patch on that website will do wonders on top of O3int, but a different approach will be needed for mainstream consumption. kernel/sched.c | 20 +++++++++----------- 1 files changed, 9 insertions(+), 11 deletions(-) diff -puN kernel/sched.c~o3int kernel/sched.c --- 25/kernel/sched.c~o3int 2003-07-06 20:50:19.000000000 -0700 +++ 25-akpm/kernel/sched.c 2003-07-06 20:50:19.000000000 -0700 @@ -77,6 +77,7 @@ #define MAX_SLEEP_AVG (10*HZ) #define STARVATION_LIMIT (10*HZ) #define NODE_THRESHOLD 125 +#define MAX_BONUS ((MAX_USER_PRIO - MAX_RT_PRIO) * PRIO_BONUS_RATIO / 100) /* * If a task is 'interactive' then we reinsert it in the active @@ -306,7 +307,7 @@ static inline void normalise_sleep(task_ { unsigned long old_avg_time = jiffies - p->avg_start; - if (old_avg_time < MIN_SLEEP_AVG) + if (unlikely(old_avg_time < MIN_SLEEP_AVG)) return; if (p->sleep_avg > MAX_SLEEP_AVG) @@ -406,22 +407,19 @@ static inline void activate_task(task_t */ if (runtime < MAX_SLEEP_AVG) p->sleep_avg += (runtime - p->sleep_avg) * (MAX_SLEEP_AVG - runtime) * - (10 - INTERACTIVE_DELTA) / 10 / MAX_SLEEP_AVG; + (MAX_BONUS - INTERACTIVE_DELTA) / MAX_BONUS / MAX_SLEEP_AVG; - /* - * Keep a buffer of 10% sleep_avg - * to prevent short bursts of cpu activity from making - * interactive tasks lose their bonus - */ - if (p->sleep_avg > MAX_SLEEP_AVG * 11/10) - p->sleep_avg = MAX_SLEEP_AVG * 11/10; + if (p->sleep_avg > MAX_SLEEP_AVG) + p->sleep_avg = MAX_SLEEP_AVG; /* * Tasks that sleep a long time are categorised as idle and * get their static priority only */ - if (sleep_time > MIN_SLEEP_AVG) - p->sleep_avg = runtime / 2; + if (sleep_time > MIN_SLEEP_AVG){ + p->avg_start = jiffies - MIN_SLEEP_AVG; + p->sleep_avg = MIN_SLEEP_AVG / 2; + } if (unlikely(p->avg_start > jiffies)){ p->avg_start = jiffies; _