[patch] [sched] exit-penalty fix, 2.5.3-pre5

Ingo Molnar (mingo@elte.hu)
Mon, 28 Jan 2002 17:43:46 +0100 (CET)


the attached patch fixes the EXIT_WEIGHT code to only 'punish' tasks,
never reward them. (it would be a way too easy method to boost CPU hogs
unfairly via starting up bogus threads that exit() after a few seconds.)

Ingo

diff -rNu linux/kernel/exit.c linux/kernel/exit.c
--- linux/kernel/exit.c Mon Jan 28 15:23:50 2002
+++ linux/kernel/exit.c Mon Jan 28 15:24:43 2002
@@ -59,8 +59,9 @@
current->time_slice += p->time_slice;
if (current->time_slice > MAX_TIMESLICE)
current->time_slice = MAX_TIMESLICE;
- current->sleep_avg = (current->sleep_avg*EXIT_WEIGHT + p->sleep_avg) /
- (EXIT_WEIGHT + 1);
+ if (p->sleep_avg < current->sleep_avg)
+ current->sleep_avg = (current->sleep_avg * EXIT_WEIGHT +
+ p->sleep_avg) / (EXIT_WEIGHT + 1);
__restore_flags(flags);

p->pid = 0;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/