Subject: Page reactivation path in pdaemon -- time to remove it?
To: NetBSD tech-kern <tech-kern@netbsd.org>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 02/26/2004 13:23:26
--Apple-Mail-95-739158525
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed

Hi folks...

I think it's time to remove the generic "reactivate" path from the 
inactive queue scan.  Or at least adjust how it works.

Take a look at uvm_pdaemon.c:452.  In January, 2001, I added this code 
to improve the performance of the system under moderate to high memory 
and I/O load.  What it does is move a page that has been referenced 
back to the active queue.  This actually implements the 
two-handed-clock algorithm the way I think was intended:

	1. Active pages are scanned.  Pages that have not been referenced
	   since the last active scan are moved to the inactive queue.

	2. Inactive pages are scanned.  Pages that have been referenced
	   since being put on the inactive queue are moved back to the
	   active queue.  Otherwise, the page is cleaned / freed.

The idea is that this finds your working set and keeps it in core.

However, I've recently discovered a serious problem with this.  
Basically, if you have some VERY ACTIVE files that consume nearly all 
physical memory, those pages will always be reactivated.  This 
effectively defeats the memory usage balancing that was added by Chuq 
Silvers a couple of months later.  E.g. consider you have your "vnode 
page" threshold tuned to 50%, but they're currently consuming 80%.  
Suddenly you need to free a page, but all those file pages are 
active... they get reactivated without any consideration for the page 
type.  Now let's say your low water mark for the other types are set 
higher than their current usage... suddenly you can't free ANY pages, 
and some poor process gets shot in the head - "out of swap".

Does anyone have any thoughts on how to fix this problem?  I'm inclined 
to kill the reactivation path completely, but I would prefer reactivate 
an actually active page of a certain type than an inactive one.

         -- Jason R. Thorpe <thorpej@wasabisystems.com>

--Apple-Mail-95-739158525
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFAPmPPOpVKkaBm8XkRAhdgAKC5gD25Qag0asxyzksnpG38DLp0PgCfQXN+
p4bfd9caz396g822Qv55Vmw=
=ovJd
-----END PGP SIGNATURE-----

--Apple-Mail-95-739158525--