diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2009-10-14 17:53:31 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2009-10-14 17:53:31 +0000 |
commit | ca04dec67f733294d0f4a032c2b305282eef4045 (patch) | |
tree | 4f65b0bc97b6adc5f65cb0f1f56c8bcd9bd86353 /sys | |
parent | 817f1a5b40babfeb9e8700a97ad73480965eea44 (diff) |
Fix buffer cache backoff in the page daemon - deal with inactive pages to
more correctly reflect the new state of the world - that is - how many pages
can be cheaply reclaimed - which now includes clean buffer cache pages.
This change fixes situations where people would be running with a large bufcachepercent, and still notice swapping without the buffer cache backing off.
ok oga@, testing by many on tech@ and others. Thanks.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/sys/mount.h | 4 | ||||
-rw-r--r-- | sys/uvm/uvm_page.c | 4 | ||||
-rw-r--r-- | sys/uvm/uvm_pdaemon.c | 15 |
3 files changed, 9 insertions, 14 deletions
diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 7d2b4532a22..c10e34cd5a3 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.h,v 1.98 2009/08/09 14:37:46 art Exp $ */ +/* $OpenBSD: mount.h,v 1.99 2009/10/14 17:53:30 beck Exp $ */ /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ /* @@ -509,6 +509,8 @@ extern struct bcachestats bcstats; extern long buflowpages, bufhighpages, bufbackpages; #define BUFPAGES_DEFICIT (((buflowpages - bcstats.numbufpages) < 0) ? 0 \ : buflowpages - bcstats.numbufpages) +#define BUFPAGES_INACT (((bcstats.numcleanpages - buflowpages) < 0) ? 0 \ + : bcstats.numcleanpages - buflowpages) extern int bufcachepercent; extern void bufadjust(int); extern int bufbackoff(void); diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index af2614506a5..72bbce4a874 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.96 2009/08/13 15:29:59 deraadt Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.97 2009/10/14 17:53:30 beck Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -794,7 +794,7 @@ uvm_pagealloc_strat(struct uvm_object *obj, voff_t off, struct vm_anon *anon, */ if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freemin || ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg && - uvmexp.inactive < uvmexp.inactarg)) + (uvmexp.inactive + BUFPAGES_INACT) < uvmexp.inactarg)) wakeup(&uvm.pagedaemon); /* diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 483ac2ae6ba..a4b44161fda 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.54 2009/08/08 13:43:59 beck Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.55 2009/10/14 17:53:30 beck Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -212,7 +212,6 @@ uvm_pageout(void *arg) */ for (;;) { - int scanned = 0; uvm_lock_fpageq(); UVMHIST_LOG(pdhist," <<SLEEPING>>",0,0,0,0); msleep(&uvm.pagedaemon, &uvm.fpageqlock, PVM | PNORELOCK, @@ -242,18 +241,12 @@ uvm_pageout(void *arg) /* * get pages from the buffer cache, or scan if needed */ - if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg) { - if (bufbackoff() == -1) { + if (((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg) || + ((uvmexp.inactive + BUFPAGES_INACT) < uvmexp.inactarg)) { + if (bufbackoff() == -1) uvmpd_scan(); - scanned = 1; - } else - scanned = 0; } - if (!scanned && (uvmexp.inactive < uvmexp.inactarg)) - uvmpd_scan(); - - /* * if there's any free memory to be had, * wake up any waiters. |