diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2009-08-08 15:04:44 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2009-08-08 15:04:44 +0000 |
commit | 2d58dd87326d6060063b3fd69af5111759024a44 (patch) | |
tree | 569b9a723f8b8ef0762f2537b5c6565cafecba40 /sys/kern | |
parent | 48c93dcab82091d4520edffb2ce17ab53bb4a978 (diff) |
two things:
1) fix buffer cache low water mark to allow for extremely low memory machines
without dying
2) Add "show bcstats" to ddb to allow for looking at the buffer cache statistics in ddb
ok art@ oga@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_bio.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 045bd969ee3..f2821c6b233 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_bio.c,v 1.119 2009/08/02 16:28:40 beck Exp $ */ +/* $OpenBSD: vfs_bio.c,v 1.120 2009/08/08 15:04:43 beck Exp $ */ /* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */ /* @@ -112,6 +112,7 @@ long maxcleanpages; long backoffpages; /* backoff counter for page allocations */ long buflowpages; /* bufpages low water mark */ long bufhighpages; /* bufpages high water mark */ +long bufbackpages; /* number of pages we back off when asked to shrink */ /* XXX - should be defined here. */ extern int bufcachepercent; @@ -213,6 +214,14 @@ bufinit(void) */ buflowpages = physmem * 10 / 100; + /* + * set bufbackpages to 100 pages, or 10 percent of the low water mark + * if we don't have that many pages. + */ + + bufbackpages = buflowpages * 10 / 100; + if (bufbackpages > 100) + bufbackpages = 100; if (bufkvm == 0) bufkvm = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 10; @@ -341,13 +350,13 @@ bufbackoff() if (bufpages <= buflowpages) return(-1); - if (bufpages - BACKPAGES >= buflowpages) - d = BACKPAGES; + if (bufpages - bufbackpages >= buflowpages) + d = bufbackpages; else d = bufpages - buflowpages; - backoffpages = BACKPAGES; + backoffpages = bufbackpages; bufadjust(bufpages - d); - backoffpages = BACKPAGES; + backoffpages = bufbackpages; return(0); } @@ -963,8 +972,8 @@ buf_get(struct vnode *vp, daddr64_t blkno, size_t size) */ if ((backoffpages == 0) && (bufpages < bufhighpages)) { if ( gcount == 0 ) { - bufadjust(bufpages + BACKPAGES); - gcount += BACKPAGES; + bufadjust(bufpages + bufbackpages); + gcount += bufbackpages; } else gcount--; } @@ -1220,3 +1229,20 @@ biodone(struct buf *bp) } } } + +#ifdef DDB +void bcstats_print(int (*)(const char *, ...)); +/* + * bcstats_print: ddb hook to print interesting buffer cache counters + */ +void +bcstats_print(int (*pr)(const char *, ...)) +{ + (*pr)("Current Buffer Cache status:\n"); + (*pr)("numbufs %d freebufs %d\n", bcstats.numbufs, bcstats.freebufs); + (*pr)("bufpages %d freepages %d dirtypages %d\n", bcstats.numbufpages, + bcstats.numfreepages, bcstats.numdirtypages); + (*pr)("pendingreads %d, pendingwrites %d\n", + bcstats.pendingreads, bcstats.pendingwrites); +} +#endif |