Subject: Page daemon behavior part N
To: None <tech-kern@netbsd.org>
From: Charles M. Hannum <root@ihack.net>
List: tech-kern
Date: 01/25/2001 03:28:44
So I've experimented with a somewhat orthogonal change, which is a bit
simpler and is intended only to restore the `two-handed clock
algorithm' behavior from Mach. To review:
* One hand sweeps through the active pages and `deactivates' them.
* The other hand sweeps through the inactive pages, and either
reactivates them, frees them, or starts paging them out.
Due to the UVM behavior of revoking mappings when a page is
deactivated, the reactivate case currently happens by simply faulting
the page again. As I said before, this is suboptimal, but it does
work.
So, the problem this change addresses is only to not deactivate a page
if it has been recently used.
This appears to improve behavior *significantly* when reading large
volumes of data -- or, more precisely, when the read rate much higher
than the write rate -- including reading (but not copying) data off a
CD or DVD, or compiling.
It does *not* completely fix the case where massive amounts of data
are being written, though. E.g.:
dd if=/dev/zero of=foo bs=64k
cat title-key /dvd/video_ts/vts_01_?.vob | efdtt >movie.vob
cdd -a
In these cases, it appears that the data to be written backs up very
badly and causes process (e.g. the X server and my Emacs) to lose
pages. Some sort of flow control is badly needed to repair this.
Index: uvm_page_i.h
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_page_i.h,v
retrieving revision 1.14
diff -c -2 -r1.14 uvm_page_i.h
*** uvm_page_i.h 2000/11/27 07:47:42 1.14
--- uvm_page_i.h 2001/01/25 03:18:40
***************
*** 218,222 ****
pg->pqflags |= PQ_INACTIVE;
uvmexp.inactive++;
- pmap_clear_reference(pg);
if (pmap_is_modified(pg))
pg->flags &= ~PG_CLEAN;
--- 218,221 ----
Index: uvm_pdaemon.c
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_pdaemon.c,v
retrieving revision 1.27
diff -c -2 -r1.27 uvm_pdaemon.c
*** uvm_pdaemon.c 2001/01/25 00:10:03 1.27
--- uvm_pdaemon.c 2001/01/25 03:18:40
***************
*** 1100,1107 ****
/*
* deactivate this page if there's a shortage of
! * inactive pages.
*/
! if (inactive_shortage > 0) {
pmap_page_protect(p, VM_PROT_NONE);
/* no need to check wire_count as pg is "active" */
--- 1100,1108 ----
/*
* deactivate this page if there's a shortage of
! * inactive pages and it hasn't been touched since the
! * last scan.
*/
! if (inactive_shortage > 0 && !pmap_clear_reference(p)) {
pmap_page_protect(p, VM_PROT_NONE);
/* no need to check wire_count as pg is "active" */