Subject: Re: Page replacement policy questions
To: None <tech-kern@netbsd.org>
From: David Laight <David.Laight@btinternet.com>
List: tech-kern
Date: 12/07/2001 14:40:13
My tuppence, based more on what solaris and svr4 do...

(I don't think my 1.5.2 i386 netbsd system is using the UBC - not enough
of its memory is ever used, and directory blocks are getting reused...)

The system won't (can't) differenciate between code and data, physical
memory is used to 'cache' disk blocks. All physical memory has a disc
block to which it can be written (unless readonly) and read back from.
If there isn't an obvious file (eg program data space) then the swap area
is used.

This means that you need enough swap space for the 'dirty' pages of your
system, and enough physical memory to stop it thrashing.  If most of your
memory is used for mmap() of data files (eg a database engine) then you
don't need much swap at all!

The 'usual' problem is that anything that trawls through a large part of
your filesystem - eg ftp a file larger than physical memory, or make an
iso9660 image - tends to leave its own pages present (which have been used
once recently) discarding those of your windowing system (which have been
used many times, but not recently).  This kills the 'active set'...
(This one is worth fixing, but I don't think it is trivial!)

If you are losing the active set on an idle system, something is definitely
wrong...  It may be correct to 'write out' some dirty pages, but their
contents should still be marked 'valid' so they can quickly be recovered.

    David

----- Original Message ----- 
From: Michael Graff <explorer@flame.org>
To: <tech-kern@netbsd.org>
Sent: Friday, December 07, 2001 7:12 AM
Subject: Page replacement policy questions


> I'm not a VM expert, but I do have a question.
> 
> Right now, we have a VM system that, from a user point of view, seems
> less than optimal.  The UBC is great, but here are the characteristics
> I'm finding annoying:
> 
>         (1) processes on a 2 GB machine start swapping at about 500
>             MB.
> 
>         (2) The system seems to treat cache pages as importantly as
>             process data pages.
> 
>         (3) After walking away for a few minutes, all my tcsh's swap
>             out, even on a fairly idle machine.
> 
> This is a simple policy, but I'm wondering why we can't do something
> like:
> 
>         Maintain a count of how many pages are used for cache and how
>         many pages are used for process data.
> 
>         Have a minimum reserved count for each, where the other type
>         of page cannot intrude into.  This is mostly to guarantee the
>         cache has some pages.
> 
>         Memory has three types:  cache, free, and in use by a process.
> 
>         When free memory is low, pages are reclaimed from the cache
>         and process spaces, depending on which is currently using
>         more, biased for reusing cache pages.
> 
>         The system tries to keep some bit of memory always free, say
>         4-16 MB (depending on system size) so processes can start
>         quickly.
> 
> --Michael