public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] sched-2.5.64-bk10-C4
@ 2003-03-16 11:24 Ingo Molnar
  2003-03-16 16:00 ` [patch] sched-2.5.64-bk10-D0 Ingo Molnar
  2003-03-21  0:44 ` [patch] sched-2.5.64-bk10-C4 Eric Wong
  0 siblings, 2 replies; 5+ messages in thread
From: Ingo Molnar @ 2003-03-16 11:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds, Mike Galbraith, Andrew Morton


the attached patch fixes a fundamental (and long-standing) bug in the
sleep-average estimator which is the root cause of the "contest
process_load" problems reported by Mike Galbraith and Andrew Morton, and
which problem is addressed by Mike's patch.

the bug is the following: the sleep_time code in activate_task()  
over-estimates the true sleep time by 0.5 jiffies on average (0.5 msecs on
recent 2.5 kernels). Furthermore, for highly context-switch intensive and
CPU-intensive workloads it means a constant 1 jiffy over-estimation. This
turns the balance of giving and removing ticks and nils the effect of the
CPU busy-tick, catapulting the task(s) to highly interactive status -
while in reality they are constantly burning CPU time.

the fix is to round down sleep_time, not to round it up. This slightly
under-estimates the sleep time, but this is not a real problem, any task
with a sleep time in the 1 jiffy range will see timekeeping granularity
artifacts from various parts of the kernel anyway. We could use rdtsc to
estimate the sleep time, but i think that's unnecessary overhead.

the fixups in Mike's scheduler patch (which is in -mm8) basically work
around this bug. The patch below definitely fixes the contest-load
starvation bug, but it remains to be seen what other effects it has on
interactivity. In any case, this bug in the estimator is real and if
there's any other interactivity problem around then we need to deal with
it ontop of this patch.

this bug has been in the O(1) scheduler from day 1 on basically, so i'm
quite hopeful that a number of interactivity complaints are fixed by this
patch.

	Ingo

--- linux/kernel/sched.c.orig	
+++ linux/kernel/sched.c	
@@ -342,10 +342,10 @@ static inline void __activate_task(task_
  */
 static inline int activate_task(task_t *p, runqueue_t *rq)
 {
-	unsigned long sleep_time = jiffies - p->last_run;
+	long sleep_time = jiffies - p->last_run - 1;
 	int requeue_waker = 0;
 
-	if (sleep_time) {
+	if (sleep_time > 0) {
 		int sleep_avg;
 
 		/*


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-03-21  5:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-16 11:24 [patch] sched-2.5.64-bk10-C4 Ingo Molnar
2003-03-16 16:00 ` [patch] sched-2.5.64-bk10-D0 Ingo Molnar
2003-03-21  0:44 ` [patch] sched-2.5.64-bk10-C4 Eric Wong
2003-03-21  1:57   ` Con Kolivas
2003-03-21  5:30   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox