Re: [patch] idle_task was wasting a lot of CPU

Rik van Riel (H.H.vanRiel@phys.uu.nl)
Mon, 30 Nov 1998 13:03:01 +0100 (CET)


On Fri, 27 Nov 1998, Andrea Arcangeli wrote:

> --- linux/kernel/sched.c:1.1.1.2 Fri Nov 27 11:19:09 1998
> +++ linux/kernel/sched.c Fri Nov 27 11:41:41 1998
> @@ -130,8 +133,15 @@
> }
> #endif
> #endif
> - if (p->policy != SCHED_OTHER || p->counter > current->counter + 3)
> - current->need_resched = 1;
> + if (/* idle_task == current || */ p->counter >= current->counter ||
> + p->policy != SCHED_OTHER)
> + current->need_resched = 1;
> }

Andrea, this is absurd. I already told you that the number of
reschedules increased by 25% when we test for > current->counter,
but the equal sign added makes this even worse. It would be better
to test for the idle task in a special case, since that is less
expensive than a greatly increased amount of schedule()s.

if (current == idle_task || p->counter >= current->counter ||
p->policy != SCHED_OTHER)

This should catch most things, with the most commonly
occurring situations placed first. An alternative is
to have the idle task mark itself with SCHED_YIELD so
the != SCHED_OTHER test will pass. Since the idle task
is never subjected to goodness() the SCHED_YIELD will
never be cleared and we can keep on using the trick...

cheers,

Rik -- now completely used to dvorak kbd layout...
+-------------------------------------------------------------------+
| Linux memory management tour guide. H.H.vanRiel@phys.uu.nl |
| Scouting Vries cubscout leader. http://www.phys.uu.nl/~riel/ |
+-------------------------------------------------------------------+

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