Re: [PATCH] Re: kswapd

From: Linus Torvalds (torvalds@transmeta.com)
Date: Mon Mar 27 2000 - 11:14:34 EST


On Mon, 27 Mar 2000, Kanoj Sarcar wrote:
>
> This is my reasoning: Rik's patch makes it so that before kswapd
> undertakes heavy weight work, it yields the cpu ... then it checks
> whether it has to do the work (via zone_wake_kswapd). This is the
> only difference over pre3.

No, there's another difference: pre3 will loop forever, even if there is
nothing to do - until something comes up that needs scheduling. Basically,
the pre3 loop boils down to

        do {
                /* not interesting */
        } while (!tsk->need_resched);

when there is enough memory.

Which obviously causes excessive CPU to be wasted.

NOTE! The "obviously" is a bit strong. What happens is that kswapd is only
woken up when needed, so most of the time it is sleeping. It's only when
it is woken up and when it has done its work when the loop turns into a
CPU-burner, but it can easily mean that kswapd will just spend CPU time
for no good reason until its time-slice is exhausted.

So think of the bug as "kswapd will waste the final part of its timeslice
doing nothing useful".

                Linus

-
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/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:20 EST