Re: cp file /dev/zero <-> cache [was Re: increasing page size]

Stephen C. Tweedie (
Mon, 6 Jul 1998 15:36:18 +0100


On Mon, 6 Jul 1998 14:34:02 +0200 (CEST), Andrea Arcangeli
<> said:

> On Mon, 6 Jul 1998, Stephen C. Tweedie wrote:
>> or 16MB box doing compilations, then you desperately want unused process
>> data pages --- idle bits of inetd, lpd, sendmail, init, the shell, the

> Now also the process that needs memory got swapped out.

No --- that's the whole point. We have per-page process page aging
which lets us differentiate between processes which are active and those
which are idle, and between the used and unused pages within the active

If you are short on memory, then you don't want to keep around any
process pages which belong to idle tasks. The only way to do that is to
invoke the swapper. We need to make sure that we are just aggressive
enough to discard pages which are not in use, and not to discard pages
which have been touched recently.

If we simply prune the cache to zero before doing any swapping, then we
will be eliminating potentially useful data out of the cache instead of
throwing away pages to swap which may not have been used in the past
half an hour.

That's what the balancing issue is about: if there are swap pages which
are not being touched at all and files such as header files which are
being constantly accessed, then we need to do at least _some_ swapping
to eliminate the idle process pages.

> I _really_ don' t want cache and readahead when the system needs
> memory.

You also don't want lpd sitting around, either.

> The only important thing is to avoid the always swapin/out and provide
> free memory to the process.

It's just wishful thinking to assume you can do this simply by
destroying the cache. Oh, and you _do_ want readahead even with little
memory, otherwise you are doing 10 disk IOs to read a file instead of
one; and on a box which is starved of memory, that implies you'll
probably see a disk seek between each IO. That's just going to thrash
your disk even harder.

> You don' t run in a 32Mbyte box I see ;-).

I run in 64MB, 16MB and 6MB for testing purposes.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to