diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2012-11-07 17:50:50 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2012-11-07 17:50:50 +0000 |
commit | b99784fe662faa712f3630b22e11e491a71180a5 (patch) | |
tree | 5e2f33011ce5e2868d515542f2ce7177cf0ad387 /sys/uvm | |
parent | 8c9e508e5ee189a27cad6ae4d3988986f019f80c (diff) |
Fix the buffer cache.
A long time ago (in vienna) the reserves for the cleaner and syncer were
removed. softdep and many things have not performed ths same ever since.
Follow on generations of buffer cache hackers assumed the exising code
was the reference and have been in frustrating state of coprophagia ever
since.
This commit
0) Brings back a (small) reserve allotment of buffer pages, and the kva to
map them, to allow the cleaner and syncer to run even when under intense
memory or kva pressure.
1) Fixes a lot of comments and variables to represent reality.
2) Simplifies and corrects how the buffer cache backs off down to the lowest
level.
3) Corrects how the page daemons asks the buffer cache to back off, ensuring
that uvmpd_scan is done to recover inactive pages in low memory situaitons
4) Adds a high water mark to the pool used to allocate struct buf's
5) Correct the cleaner and the sleep/wakeup cases in both low memory and low
kva situations. (including accounting for the cleaner/syncer reserve)
Tested by many, with very much helpful input from deraadt, miod, tobiasu,
kettenis and others.
ok kettenis@ deraadt@ jj@
Diffstat (limited to 'sys/uvm')
-rw-r--r-- | sys/uvm/uvm_pdaemon.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 77b204ea52a..47f85afc638 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.59 2011/07/06 19:50:38 beck Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.60 2012/11/07 17:50:49 beck Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -247,13 +247,28 @@ uvm_pageout(void *arg) if (pma != NULL || ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg) || ((uvmexp.inactive + BUFPAGES_INACT) < uvmexp.inactarg)) { - if (bufbackoff(&constraint, - (pma ? pma->pm_size : -1)) == 0) - work_done = 1; - else { - uvmpd_scan(); - work_done = 1; /* we hope... */ - } + u_int64_t free, size; + free = uvmexp.free - BUFPAGES_DEFICIT; + /* start with the size of what we are asking for */ + size = pma ? pma->pm_size : 0; + /* + * If we below our target, add twice the amount + * we are below the target to what we will ask + * the buffer cache to give back. We then ask + * the buffer cache to give us free pages by + * backing off. + */ + if (uvmexp.freetarg - free > 0) + size += (uvmexp.freetarg - free) * 2; + (void) bufbackoff(&constraint, size); + /* + * Now we scan to ensure we meet all our targets, + * we will not swap at this point, unless the buffer + * cache could not back off enough for us to meet + * our free page targets. + */ + uvmpd_scan(); + work_done = 1; /* XXX we hope... */ } /* |