--- linux-2.5.74-mm3/kernel/sched.c.old 2003-07-09 16:44:31.000000000 +0200 +++ linux-2.5.74-mm3/kernel/sched.c 2003-07-10 00:34:27.000000000 +0200 @@ -69,15 +69,13 @@ #define MIN_TIMESLICE ( 10 * HZ / 1000) #define MAX_TIMESLICE (200 * HZ / 1000) #define CHILD_PENALTY 80 -#define PARENT_PENALTY 100 +#define PARENT_PENALTY 90 #define EXIT_WEIGHT 3 -#define PRIO_BONUS_RATIO 25 -#define INTERACTIVE_DELTA 2 -#define MIN_SLEEP_AVG (HZ) +#define PRIO_BONUS_RATIO 45 +#define INTERACTIVE_DELTA 4 #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 @@ -90,13 +88,13 @@ * We scale it linearly, offset by the INTERACTIVE_DELTA delta. * Here are a few examples of different nice levels: * - * TASK_INTERACTIVE(-20): [1,1,1,1,1,1,1,1,1,0,0] - * TASK_INTERACTIVE(-10): [1,1,1,1,1,1,1,0,0,0,0] - * TASK_INTERACTIVE( 0): [1,1,1,1,0,0,0,0,0,0,0] - * TASK_INTERACTIVE( 10): [1,1,0,0,0,0,0,0,0,0,0] - * TASK_INTERACTIVE( 19): [0,0,0,0,0,0,0,0,0,0,0] + * TASK_INTERACTIVE(-20): [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0] + * TASK_INTERACTIVE(-10): [1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0] + * TASK_INTERACTIVE( 0): [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0] + * TASK_INTERACTIVE( 10): [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + * TASK_INTERACTIVE( 19): [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] * - * (the X axis represents the possible -5 ... 0 ... +5 dynamic + * (the X axis represents the possible -9 ... 0 ... +9 dynamic * priority range a task can explore, a value of '1' means the * task is rated interactive.) * @@ -299,35 +297,15 @@ array->nr_active++; p->array = array; } -/* - * normalise_sleep converts a task's sleep_avg to - * an appropriate proportion of MIN_SLEEP_AVG. - */ -static inline void normalise_sleep(task_t *p) -{ - unsigned long old_avg_time = jiffies - p->avg_start; - - if (unlikely(old_avg_time < MIN_SLEEP_AVG)) - return; - - if (p->sleep_avg > MAX_SLEEP_AVG) - p->sleep_avg = MAX_SLEEP_AVG; - - if (old_avg_time > MAX_SLEEP_AVG) - old_avg_time = MAX_SLEEP_AVG; - - p->sleep_avg = p->sleep_avg * MIN_SLEEP_AVG / old_avg_time; - p->avg_start = jiffies - MIN_SLEEP_AVG; -} /* * effective_prio - return the priority that is based on the static * priority but is modified by bonuses/penalties. * * We scale the actual sleep average [0 .... MAX_SLEEP_AVG] - * into the -5 ... 0 ... +5 bonus/penalty range. + * into the -9 ... 0 ... +9 bonus/penalty range. * - * We use 25% of the full 0...39 priority range so that: + * We use 50% of the full 0...39 priority range so that: * * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs. * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks. @@ -337,28 +315,11 @@ static int effective_prio(task_t *p) { int bonus, prio; - unsigned long sleep_period; if (rt_task(p)) return p->prio; - sleep_period = jiffies - p->avg_start; - - if (unlikely(!sleep_period)) - return p->static_prio; - - if (sleep_period > MAX_SLEEP_AVG) - sleep_period = MAX_SLEEP_AVG; - - if (p->sleep_avg > sleep_period) - sleep_period = p->sleep_avg; - - /* - * The bonus is determined according to the accumulated - * sleep avg over the duration the task has been running - * until it reaches MAX_SLEEP_AVG. -ck - */ - bonus = MAX_USER_PRIO*PRIO_BONUS_RATIO*p->sleep_avg/sleep_period/100 - + bonus = MAX_USER_PRIO*PRIO_BONUS_RATIO*p->sleep_avg/MAX_SLEEP_AVG/100 - MAX_USER_PRIO*PRIO_BONUS_RATIO/100/2; prio = p->static_prio - bonus; @@ -386,10 +347,10 @@ */ static inline void activate_task(task_t *p, runqueue_t *rq) { - long sleep_time = jiffies - p->last_run - 1; + long sleep_time = jiffies - p->last_run; - if (sleep_time > 0) { - unsigned long runtime = jiffies - p->avg_start; + if (sleep_time) { + int sleep_avg; /* * This code gives a bonus to interactive tasks. @@ -399,34 +360,15 @@ * spends sleeping, the higher the average gets - and the * higher the priority boost gets as well. */ - p->sleep_avg += sleep_time; - /* - * Give a bonus to tasks that wake early on to prevent - * the problem of the denominator in the bonus equation - * from continually getting larger. - */ - if (runtime < MAX_SLEEP_AVG) - p->sleep_avg += (runtime - p->sleep_avg) * (MAX_SLEEP_AVG - runtime) * - (MAX_BONUS - INTERACTIVE_DELTA) / MAX_BONUS / MAX_SLEEP_AVG; - - 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->avg_start = jiffies - MIN_SLEEP_AVG; - p->sleep_avg = MIN_SLEEP_AVG / 2; - } - - if (unlikely(p->avg_start > jiffies)){ - p->avg_start = jiffies; - p->sleep_avg = 0; + sleep_avg = p->sleep_avg + sleep_time; + if (sleep_avg > MAX_SLEEP_AVG) + sleep_avg = MAX_SLEEP_AVG; + + if (p->sleep_avg != sleep_avg) { + p->sleep_avg = sleep_avg; + p->prio = effective_prio(p); } } - p->prio = effective_prio(p); __activate_task(p, rq); } @@ -603,7 +545,6 @@ * from forking tasks that are max-interactive. */ current->sleep_avg = current->sleep_avg * PARENT_PENALTY / 100; - normalise_sleep(p); p->sleep_avg = p->sleep_avg * CHILD_PENALTY / 100; p->prio = effective_prio(p); set_task_cpu(p, smp_processor_id()); @@ -644,8 +585,6 @@ * If the child was a (relative-) CPU hog then decrease * the sleep_avg of the parent as well. */ - normalise_sleep(p); - normalise_sleep(p->parent); if (p->sleep_avg < p->parent->sleep_avg) p->parent->sleep_avg = (p->parent->sleep_avg * EXIT_WEIGHT + p->sleep_avg) / (EXIT_WEIGHT + 1);