diff options
author | dg <dg@FreeBSD.org> | 1994-08-30 18:19:11 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1994-08-30 18:19:11 +0000 |
commit | f81bd8035baf33a0773ca92bf6cb09e3110181e1 (patch) | |
tree | c37f108a0e651cf3fc64d62e703eb3f876998309 | |
parent | 4e783802c8c8d5fc36486bd75ab60cc96641b82c (diff) | |
download | FreeBSD-src-f81bd8035baf33a0773ca92bf6cb09e3110181e1.zip FreeBSD-src-f81bd8035baf33a0773ca92bf6cb09e3110181e1.tar.gz |
Changed to reclaim memory from other buffers to eliminate memory
thrashing.
Submitted by: John Dyson
-rw-r--r-- | sys/kern/vfs_bio.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 594dd7ba..509615b 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -16,7 +16,7 @@ * 4. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: vfs_bio.c,v 1.8 1994/08/08 15:40:59 wollman Exp $ + * $Id: vfs_bio.c,v 1.9 1994/08/18 22:35:06 wollman Exp $ */ #include <sys/param.h> @@ -661,6 +661,11 @@ vfs_update() { } } +#define MAXFREEBP 128 +#define LDFREE_BUSY 1 +#define LDFREE_WANT 2 +int loadfreeing; +struct buf *freebp[MAXFREEBP]; /* * these routines are not in the correct place (yet) * also they work *ONLY* for kernel_pmap!!! @@ -676,7 +681,37 @@ vm_hold_load_pages(vm_offset_t froma, vm_offset_t toa) { vm_offset_t pa; tryagain: - if (cnt.v_free_count <= cnt.v_free_reserved) { +/* + * don't allow buffer cache to cause VM paging + */ + if ( cnt.v_free_count < cnt.v_free_min) { + if( !loadfreeing ) { + int n=0; + struct buf *bp; + loadfreeing = LDFREE_BUSY; + while( (cnt.v_free_count <= cnt.v_free_min) && + (n < MAXFREEBP)) { + bp = geteblk(0); + if( bp) + freebp[n++] = bp; + else + break; + } + while(--n >= 0) { + brelse(freebp[n]); + } + if( loadfreeing & LDFREE_WANT) + wakeup((caddr_t) &loadfreeing); + loadfreeing = 0; + } else { + loadfreeing |= LDFREE_WANT; + tsleep(&loadfreeing, PRIBIO, "biofree", 0); + } + } + + + if (cnt.v_free_count <= + cnt.v_free_reserved + (toa-froma) / PAGE_SIZE) { VM_WAIT; goto tryagain; } |