diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2008-07-02 15:21:34 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2008-07-02 15:21:34 +0000 |
commit | d034dde8db4cec62e959d1b5800dbf696d646924 (patch) | |
tree | 78d1c7c906ee567135863b97a0e079718240d96b | |
parent | 3c56feb2b4ddf8f30afb1bbd4050a0cf5dde192e (diff) |
Make the pagedaemon a bit happier.
1. When checking if the pagedaemon should be awakened and to see how
much work it should do, consider the buffer cache deficit
(how much pages the buffer cache can eat max vs. how much it has
now) as pages that are not free. They are actually still usable by
the allocator, but the presure on the pagedaemon is increased when
we starting to chew into the memory that the buffer cache wants to
use.
2. Remove the stupid 512kB limit of how much memory should be our
free target. That maybe made sense on 68k, but on modern systems
512k is just a joke. Keep it at 3% of physical memory just like
it was meant to be.
3. When doing allocations for the pagedaemon, always let it use the
reserve. the whole UVM_OBJ_IS_KERN_OBJECT is silly and doesn't
work in most cases anyway. We still don't have a reserve for
the pagedaemon in the km_page allocator, but this seems to help
enough. (yes, there are still bad cases in that code and the comment
is only half-true, the whole section needs a massage, but that will
happen later, this diff only touches pagedaemon parts)
Testing by many, prodded by theo.
-rw-r--r-- | sys/sys/mount.h | 3 | ||||
-rw-r--r-- | sys/uvm/uvm_page.c | 23 | ||||
-rw-r--r-- | sys/uvm/uvm_pdaemon.c | 27 |
3 files changed, 20 insertions, 33 deletions
diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 235d9987d35..a9a157525e1 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.h,v 1.88 2008/06/13 01:59:45 rainer Exp $ */ +/* $OpenBSD: mount.h,v 1.89 2008/07/02 15:21:33 art Exp $ */ /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ /* @@ -504,6 +504,7 @@ struct bcachestats { }; #ifdef _KERNEL extern struct bcachestats bcstats; +#define BUFPAGES_DEFICIT (bufpages - bcstats.numbufpages) #endif /* diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index 1c05a735763..8a90c987693 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.66 2008/04/12 20:37:35 miod Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.67 2008/07/02 15:21:33 art Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -78,6 +78,7 @@ #include <sys/sched.h> #include <sys/kernel.h> #include <sys/vnode.h> +#include <sys/mount.h> #include <uvm/uvm.h> @@ -929,18 +930,10 @@ uvm_pagealloc_strat(obj, off, anon, flags, strat, free_list) * check to see if we need to generate some free pages waking * the pagedaemon. */ - -#ifdef UBC - if (uvmexp.free + uvmexp.paging < uvmexp.freemin || - (uvmexp.free + uvmexp.paging < uvmexp.freetarg && - uvmexp.inactive < uvmexp.inactarg)) { - wakeup(&uvm.pagedaemon); - } -#else - if (uvmexp.free < uvmexp.freemin || (uvmexp.free < uvmexp.freetarg && - uvmexp.inactive < uvmexp.inactarg)) + if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freemin || + ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg && + uvmexp.inactive < uvmexp.inactarg)) wakeup(&uvm.pagedaemon); -#endif /* * fail if any of these conditions is true: @@ -954,9 +947,9 @@ uvm_pagealloc_strat(obj, off, anon, flags, strat, free_list) use_reserve = (flags & UVM_PGA_USERESERVE) || (obj && UVM_OBJ_IS_KERN_OBJECT(obj)); if ((uvmexp.free <= uvmexp.reserve_kernel && !use_reserve) || - (uvmexp.free <= uvmexp.reserve_pagedaemon && - !(use_reserve && (curproc == uvm.pagedaemon_proc || - curproc == syncerproc)))) + (uvmexp.free <= uvmexp.reserve_pagedaemon && + !((curproc == uvm.pagedaemon_proc) || + (curproc == syncerproc)))) goto fail; #if PGFL_NQUEUES != 2 diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 7e919ea2db7..c1444eb6aeb 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.34 2007/12/18 11:05:52 thib Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.35 2008/07/02 15:21:33 art Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -78,6 +78,7 @@ #include <sys/pool.h> #include <sys/buf.h> #include <sys/vnode.h> +#include <sys/mount.h> #include <uvm/uvm.h> @@ -160,7 +161,7 @@ uvm_wait(wmsg) */ static void -uvmpd_tune() +uvmpd_tune(void) { UVMHIST_FUNC("uvmpd_tune"); UVMHIST_CALLED(pdhist); @@ -169,7 +170,9 @@ uvmpd_tune() /* between 16k and 512k */ /* XXX: what are these values good for? */ uvmexp.freemin = max(uvmexp.freemin, (16*1024) >> PAGE_SHIFT); +#if 0 uvmexp.freemin = min(uvmexp.freemin, (512*1024) >> PAGE_SHIFT); +#endif /* Make sure there's always a user page free. */ if (uvmexp.freemin < uvmexp.reserve_kernel + 1) @@ -244,17 +247,8 @@ uvm_pageout(void *arg) /* * scan if needed */ - -#ifdef UBC - if (uvmexp.free + uvmexp.paging < uvmexp.freetarg || - uvmexp.inactive < uvmexp.inactarg || - uvm_pgcnt_vnode > - (uvmexp.active + uvmexp.inactive + uvmexp.wired + - uvmexp.free) * 13 / 16) { -#else - if (uvmexp.free < uvmexp.freetarg || + if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg || uvmexp.inactive < uvmexp.inactarg) { -#endif uvmpd_scan(); } @@ -416,7 +410,7 @@ uvmpd_scan_inactive(pglst) */ uvm_lock_fpageq(); - free = uvmexp.free; + free = uvmexp.free - BUFPAGES_DEFICIT; uvm_unlock_fpageq(); if (free + uvmexp.paging >= uvmexp.freetarg << 2 || @@ -955,7 +949,7 @@ uvmpd_scan_inactive(pglst) */ void -uvmpd_scan() +uvmpd_scan(void) { int free, inactive_shortage, swap_shortage, pages_freed; struct vm_page *p, *nextpg; @@ -970,7 +964,7 @@ uvmpd_scan() * get current "free" page count */ uvm_lock_fpageq(); - free = uvmexp.free; + free = uvmexp.free - BUFPAGES_DEFICIT; uvm_unlock_fpageq(); #ifndef __SWAP_BROKEN @@ -985,7 +979,6 @@ uvmpd_scan() uvm_unlock_pageq(); uvm_swapout_threads(); uvm_lock_pageq(); - } #endif @@ -1004,7 +997,7 @@ uvmpd_scan() */ got_it = FALSE; - pages_freed = uvmexp.pdfreed; + pages_freed = uvmexp.pdfreed; /* XXX - int */ if ((uvmexp.pdrevs & 1) != 0 && uvmexp.nswapdev != 0) got_it = uvmpd_scan_inactive(&uvm.page_inactive_swp); if (!got_it) |