Subject: Re: Bad response...
To: Johnny Billquist <bqt@Update.UU.SE>
From: SODA Noriyuki <soda@sra.co.jp>
List: current-users
Date: 09/01/2004 01:50:10
>>>>> On Tue, 31 Aug 2004 17:20:35 +0200 (CEST),
	Johnny Billquist <bqt@Update.UU.SE> said:

> Ok. Correct me if I'm wrong now then, and fill in the blanks.
> If the file cache is at VM_FILEMIN or less, other memory grabbers cannot
> "steal" the pages used by the file cache.

Yes.

> If the file cache is at less than VM_FILEMAX, it will "steal" pages from
> other memory classes, when needed.

This only happens if anon pages or exec pages are larger than vm.anonmax
or vm.execmax.

> But obviously, the file cache can also grab more memory than VM_FILEMAX.
> At what conditions does this happen?

This happens when file cache needs more memory, and if there is free memory.

The vm.{anon,exec,file}{min,max} parameters are only used when
free memory isn't enough, to determine how memory is reclaimed.

There are 3 classes of memory:
	anonymous pages: stack, heap, bss and data section of processes
	executable pages: text section of processes.
		i.e. file pages which are mapped into processes' memory 
		space with PROT_EXEC bit on.
		If the executable pages are unmapped from processes'
		memory space, the pages are turned into file pages.
	file pages: file cache, including file pages which are mapped
		into processes' memory space with MAP_SHARED, but
		without PROT_EXEC.
When memory shortage happens, and
- if a memory class ${A} (${A} is either anon, exec or file) is
  smaller than ${A}min, entire space of the class ${A} is considered
  active, so memory is reclaimed from classes other than ${A}.
- if class ${A} is smaller than ${A}max, and if there is at least
  one class ${B} where the size of ${B} is larger than ${B}max, then
  entire space of the class ${A} is considered active, so memory
  is reclaimed from classes other than ${A}.

If you can read C program, it may be easier to understand how it
works by reading src/sys/uvm/uvm_pdaemon.c:uvmpd_scan_inactive().

The file cache can grow more than than vm.filemax, because those
parameters aren't used to limit memory to be allocated, but only
used to reclaim memory.

The names vm.{anon,exec,file}max may be confusing, these are not
really maximum but something like "soft minimum".

>>>>> On Tue, 31 Aug 2004 16:08:33 +0100,
	Aidan Kehoe <kehoea@parhasard.net> said:

> (NS--not meaning to be especially formal, I'd have used your given
> name there if I could work out which it was--family name in capital
> letters makes this easier for the ignorant westerners out here,
> people.)

Noriyuki is my give name. :)
--
soda