diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2009-06-15 17:01:27 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2009-06-15 17:01:27 +0000 |
commit | 2ad23154352bb286faa9d4e90c688c5bea78c525 (patch) | |
tree | 74d852efc8530c595f03e7c280d4b345659b6e3e | |
parent | 53a176b4ab49f0631c3e478055286d9e4e625d32 (diff) |
Back out all the buffer cache changes I committed during c2k9. This reverts three
commits:
1) The sysctl allowing bufcachepercent to be changed at boot time.
2) The change moving the buffer cache hash chains to a red-black tree
3) The dynamic buffer cache (Which depended on the earlier too).
ok on the backout from marco and todd
27 files changed, 176 insertions, 254 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 4631a8f8c3e..bb3c8e97c59 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.95 2009/06/14 03:04:07 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.96 2009/06/15 17:01:25 beck Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -399,6 +399,12 @@ setup_buffers() */ if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; } /* diff --git a/sys/arch/aviion/aviion/machdep.c b/sys/arch/aviion/aviion/machdep.c index 3b8237656c5..ebff8ba9465 100644 --- a/sys/arch/aviion/aviion/machdep.c +++ b/sys/arch/aviion/aviion/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.28 2009/06/03 21:30:19 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.29 2009/06/15 17:01:25 beck Exp $ */ /* * Copyright (c) 2007 Miodrag Vallat. * @@ -293,6 +293,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index d560a1b7c58..c4b391071c6 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.121 2009/06/03 21:30:19 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.122 2009/06/15 17:01:25 beck Exp $ */ /* $NetBSD: machdep.c,v 1.121 1999/03/26 23:41:29 mycroft Exp $ */ /* @@ -290,6 +290,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c index f7c0af3f823..843dac586e3 100644 --- a/sys/arch/hppa/hppa/machdep.c +++ b/sys/arch/hppa/hppa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.172 2009/06/03 21:30:19 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.173 2009/06/15 17:01:25 beck Exp $ */ /* * Copyright (c) 1999-2003 Michael Shalayeff @@ -653,6 +653,12 @@ cpu_startup(void) if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/hppa64/hppa64/machdep.c b/sys/arch/hppa64/hppa64/machdep.c index e3385e60162..33a408a7a02 100644 --- a/sys/arch/hppa64/hppa64/machdep.c +++ b/sys/arch/hppa64/hppa64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.14 2009/06/03 21:30:19 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.15 2009/06/15 17:01:25 beck Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -406,6 +406,12 @@ cpu_startup(void) if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + printf("here3\n"); /* * Allocate a submap for exec arguments. This map effectively diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index ad3a266aa0f..2969cc3413c 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.452 2009/06/03 21:30:19 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.453 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -547,6 +547,11 @@ setup_buffers() if (bufpages == 0) bufpages = atop(avail_end) * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; } /* diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c index 27a6f7ae066..03281cec0cb 100644 --- a/sys/arch/luna88k/luna88k/machdep.c +++ b/sys/arch/luna88k/luna88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.63 2009/06/03 21:30:19 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.64 2009/06/15 17:01:26 beck Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -470,6 +470,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c index a86c163e416..9f992582dca 100644 --- a/sys/arch/mac68k/mac68k/machdep.c +++ b/sys/arch/mac68k/mac68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.148 2009/06/03 21:30:20 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.149 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */ /* @@ -419,6 +419,12 @@ cpu_startup(void) if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c index 0a3a0b876e4..ab9e2862361 100644 --- a/sys/arch/macppc/macppc/machdep.c +++ b/sys/arch/macppc/macppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.107 2009/06/09 01:12:38 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.108 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -509,6 +509,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c index 836bec8ec95..db6c36898db 100644 --- a/sys/arch/mvme68k/mvme68k/machdep.c +++ b/sys/arch/mvme68k/mvme68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.115 2009/06/03 21:30:20 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.116 2009/06/15 17:01:26 beck Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -265,6 +265,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c index 32c28247423..063acd72a66 100644 --- a/sys/arch/mvme88k/mvme88k/machdep.c +++ b/sys/arch/mvme88k/mvme88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.230 2009/06/03 21:30:20 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.231 2009/06/15 17:01:26 beck Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -404,6 +404,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/mvmeppc/mvmeppc/machdep.c b/sys/arch/mvmeppc/mvmeppc/machdep.c index 42da01b655a..a2432cce471 100644 --- a/sys/arch/mvmeppc/mvmeppc/machdep.c +++ b/sys/arch/mvmeppc/mvmeppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.57 2009/06/03 21:30:20 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.58 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -415,6 +415,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/sgi/sgi/machdep.c b/sys/arch/sgi/sgi/machdep.c index c44bd038eec..f296ef4b2b8 100644 --- a/sys/arch/sgi/sgi/machdep.c +++ b/sys/arch/sgi/sgi/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.73 2009/06/13 21:48:03 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.74 2009/06/15 17:01:26 beck Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -768,6 +768,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm. */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/socppc/socppc/machdep.c b/sys/arch/socppc/socppc/machdep.c index f1da92fde61..fc2a738d51b 100644 --- a/sys/arch/socppc/socppc/machdep.c +++ b/sys/arch/socppc/socppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.12 2009/06/09 01:12:38 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.13 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -772,6 +772,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/solbourne/solbourne/machdep.c b/sys/arch/solbourne/solbourne/machdep.c index cc3e64cf9a7..0c90df97b4d 100644 --- a/sys/arch/solbourne/solbourne/machdep.c +++ b/sys/arch/solbourne/solbourne/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.9 2009/06/03 21:30:20 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.10 2009/06/15 17:01:26 beck Exp $ */ /* OpenBSD: machdep.c,v 1.105 2005/04/11 15:13:01 deraadt Exp */ /* @@ -190,6 +190,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index ea63610774f..e1a7178feea 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.117 2009/06/03 21:30:20 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.118 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */ /* @@ -203,6 +203,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c index fd9433bcbba..21aba9fe1d3 100644 --- a/sys/arch/vax/vax/machdep.c +++ b/sys/arch/vax/vax/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.100 2009/06/03 21:30:20 beck Exp $ */ +/* $OpenBSD: machdep.c,v 1.101 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */ /* @@ -212,6 +212,12 @@ cpu_startup() if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; + /* Restrict to at most 25% filled kvm */ + if (bufpages > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / PAGE_SIZE / 4) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + PAGE_SIZE / 4; + /* * Allocate a submap for exec arguments. This map effectively limits * the number of processes exec'ing at any time. diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index d7a6e82b2dc..3844f123316 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.173 2009/06/08 00:52:23 deraadt Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.174 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -554,24 +554,6 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case KERN_CPTIME2: return (sysctl_cptime2(name + 1, namelen -1, oldp, oldlenp, newp, newlen)); - case KERN_CACHEPCT: { - int opct, pgs; - opct = bufcachepercent; - error = sysctl_int(oldp, oldlenp, newp, newlen, - &bufcachepercent); - if (error) - return(error); - if (bufcachepercent > 90 || bufcachepercent < 5) { - bufcachepercent = opct; - return (EINVAL); - } - if (bufcachepercent != opct) { - pgs = bufcachepercent * physmem / 100; - bufadjust(pgs); /* adjust bufpages */ - bufhighpages = bufpages; /* set high water mark */ - } - return(0); - } default: return (EOPNOTSUPP); } diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 42435d9e05f..0e7c21786ec 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1,7 +1,7 @@ -/* $OpenBSD: vfs_bio.c,v 1.116 2009/06/06 18:06:22 art Exp $ */ +/* $OpenBSD: vfs_bio.c,v 1.117 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */ -/* +/*- * Copyright (c) 1994 Christopher G. Demetriou * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -62,6 +62,20 @@ #include <miscfs/specfs/specdev.h> /* + * Definitions for the buffer hash lists. + */ +#define BUFHASH(dvp, lbn) \ + (&bufhashtbl[((long)(dvp) / sizeof(*(dvp)) + (int)(lbn)) & bufhash]) +LIST_HEAD(bufhashhdr, buf) *bufhashtbl, invalhash; +u_long bufhash; + +/* + * Insq/Remq for the buffer hash lists. + */ +#define binshash(bp, dp) LIST_INSERT_HEAD(dp, bp, b_hash) +#define bremhash(bp) LIST_REMOVE(bp, b_hash) + +/* * Definitions for the buffer free lists. */ #define BQUEUES 2 /* number of free buffer queues */ @@ -109,9 +123,6 @@ long hidirtypages; long locleanpages; long hicleanpages; long maxcleanpages; -long backoffpages; /* backoff counter for page allocations */ -long buflowpages; /* bufpages low water mark */ -long bufhighpages; /* bufpages high water mark */ /* XXX - should be defined here. */ extern int bufcachepercent; @@ -171,13 +182,9 @@ buf_put(struct buf *bp) panic("buf_put: b_dep is not empty"); #endif + bremhash(bp); LIST_REMOVE(bp, b_list); bcstats.numbufs--; - if (backoffpages) { - backoffpages -= atop(bp->b_bufsize); - if (backoffpages < 0) - backoffpages = 0; - } if (buf_dealloc_mem(bp) != 0) return; @@ -193,7 +200,7 @@ bufinit(void) struct bqueues *dp; /* XXX - for now */ - bufhighpages = buflowpages = bufpages = bufcachepercent = bufkvm = 0; + bufpages = bufcachepercent = bufkvm = 0; /* * If MD code doesn't say otherwise, use 10% of kvm for mappings and @@ -204,16 +211,6 @@ bufinit(void) if (bufpages == 0) bufpages = physmem * bufcachepercent / 100; - bufhighpages = bufpages; - - /* - * set the base backoff level for the buffer cache to bufpages. - * we will not allow uvm to steal back more than this number of - * pages - */ - buflowpages = physmem * 10 / 100; - - if (bufkvm == 0) bufkvm = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 10; @@ -240,6 +237,7 @@ bufinit(void) */ buf_mem_init(bufkvm); + bufhashtbl = hashinit(bufpages / 4, M_CACHE, M_WAITOK, &bufhash); hidirtypages = (bufpages / 4) * 3; lodirtypages = bufpages / 2; @@ -253,104 +251,6 @@ bufinit(void) maxcleanpages = locleanpages; } -/* - * Change cachepct - */ -void -bufadjust(int newbufpages) -{ - /* - * XXX - note, bufkvm was allocated once, based on 10% of physmem - * see above. - */ - struct buf *bp; - int s; - - s = splbio(); - bufpages = newbufpages; - - hidirtypages = (bufpages / 4) * 3; - lodirtypages = bufpages / 2; - - /* - * When we hit 95% of pages being clean, we bring them down to - * 90% to have some slack. - */ - hicleanpages = bufpages - (bufpages / 20); - locleanpages = bufpages - (bufpages / 10); - - maxcleanpages = locleanpages; - - /* - * If we we have more buffers allocated than bufpages, - * free them up to get back down. this may possibly consume - * all our clean pages... - */ - while ((bp = TAILQ_FIRST(&bufqueues[BQ_CLEAN])) && - (bcstats.numbufpages > bufpages)) { - bremfree(bp); - if (bp->b_vp) { - RB_REMOVE(buf_rb_bufs, - &bp->b_vp->v_bufs_tree, bp); - brelvp(bp); - } - buf_put(bp); - } - - /* - * Wake up cleaner if we're getting low on pages. We might - * now have too much dirty, or have fallen below our low - * water mark on clean pages so we need to free more stuff - * up. - */ - if (bcstats.numdirtypages >= hidirtypages || - bcstats.numcleanpages <= locleanpages) - wakeup(&bd_req); - - /* - * if immediate action has not freed up enough goo for us - * to proceed - we tsleep and wait for the cleaner above - * to do it's work and get us reduced down to sanity. - */ - while (bcstats.numbufpages > bufpages) { - tsleep(&needbuffer, PRIBIO, "needbuffer", 0); - } - splx(s); -} - -/* - * Make the buffer cache back off from cachepct. - */ -int -bufbackoff() -{ - /* - * Back off the amount of buffer cache pages. Called by the page - * daemon to consume buffer cache pages rather than swapping. - * - * On success, it frees N pages from the buffer cache, and sets - * a flag so that the next N allocations from buf_get will recycle - * a buffer rather than allocate a new one. It then returns 0 to the - * caller. - * - * on failure, it could free no pages from the buffer cache, does - * nothing and returns -1 to the caller. - */ - long d; - - if (bufpages <= buflowpages) - return(-1); - - if (bufpages - BACKPAGES >= buflowpages) - d = BACKPAGES; - else - d = bufpages - buflowpages; - backoffpages = BACKPAGES; - bufadjust(bufpages - d); - backoffpages = BACKPAGES; - return(0); -} - struct buf * bio_doread(struct vnode *vp, daddr64_t blkno, int size, int async) { @@ -776,12 +676,10 @@ brelse(struct buf *bp) CLR(bp->b_flags, B_DELWRI); } - if (bp->b_vp) { - RB_REMOVE(buf_rb_bufs, &bp->b_vp->v_bufs_tree, - bp); + if (bp->b_vp) brelvp(bp); - } - bp->b_vp = NULL; + bremhash(bp); + binshash(bp, &invalhash); /* * If the buffer has no associated data, place it back in the @@ -799,9 +697,6 @@ brelse(struct buf *bp) CLR(bp->b_flags, B_WANTED); wakeup(bp); } - if (bp->b_vp != NULL) - RB_REMOVE(buf_rb_bufs, - &bp->b_vp->v_bufs_tree, bp); buf_put(bp); splx(s); return; @@ -863,14 +758,15 @@ struct buf * incore(struct vnode *vp, daddr64_t blkno) { struct buf *bp; - struct buf b; - - /* Search buf lookup tree */ - b.b_lblkno = blkno; - bp = RB_FIND(buf_rb_bufs, &vp->v_bufs_tree, &b); - if (bp && !ISSET(bp->b_flags, B_INVAL)) - return(bp); - return(NULL); + + /* Search hash chain */ + LIST_FOREACH(bp, BUFHASH(vp, blkno), b_hash) { + if (bp->b_lblkno == blkno && bp->b_vp == vp && + !ISSET(bp->b_flags, B_INVAL)) + return (bp); + } + + return (NULL); } /* @@ -885,7 +781,6 @@ struct buf * getblk(struct vnode *vp, daddr64_t blkno, int size, int slpflag, int slptimeo) { struct buf *bp; - struct buf b; int s, error; /* @@ -899,9 +794,9 @@ getblk(struct vnode *vp, daddr64_t blkno, int size, int slpflag, int slptimeo) * the block until the write is finished. */ start: - b.b_lblkno = blkno; - bp = RB_FIND(buf_rb_bufs, &vp->v_bufs_tree, &b); - if (bp != NULL) { + LIST_FOREACH(bp, BUFHASH(vp, blkno), b_hash) { + if (bp->b_lblkno != blkno || bp->b_vp != vp) + continue; s = splbio(); if (ISSET(bp->b_flags, B_BUSY)) { @@ -950,24 +845,11 @@ geteblk(int size) struct buf * buf_get(struct vnode *vp, daddr64_t blkno, size_t size) { - static int gcount = 0; struct buf *bp; int poolwait = size == 0 ? PR_NOWAIT : PR_WAITOK; int npages; int s; - /* - * if we were previously backed off, slowly climb back up - * to the high water mark again. - */ - if ((backoffpages == 0) && (bufpages < bufhighpages)) { - if ( gcount == 0 ) { - bufadjust(bufpages + BACKPAGES); - gcount += BACKPAGES; - } else - gcount--; - } - s = splbio(); if (size) { /* @@ -985,11 +867,8 @@ buf_get(struct vnode *vp, daddr64_t blkno, size_t size) while (bcstats.numcleanpages > locleanpages) { bp = TAILQ_FIRST(&bufqueues[BQ_CLEAN]); bremfree(bp); - if (bp->b_vp) { - RB_REMOVE(buf_rb_bufs, - &bp->b_vp->v_bufs_tree, bp); + if (bp->b_vp) brelvp(bp); - } buf_put(bp); } } @@ -999,21 +878,16 @@ buf_get(struct vnode *vp, daddr64_t blkno, size_t size) /* * Free some buffers until we have enough space. */ - while ((bcstats.numbufpages + npages > bufpages) - || backoffpages) { + while (bcstats.numbufpages + npages > bufpages) { int freemax = 5; int i = freemax; while ((bp = TAILQ_FIRST(&bufqueues[BQ_CLEAN])) && i--) { bremfree(bp); - if (bp->b_vp) { - RB_REMOVE(buf_rb_bufs, - &bp->b_vp->v_bufs_tree, bp); + if (bp->b_vp) brelvp(bp); - } buf_put(bp); } - if (freemax == i && - (bcstats.numbufpages + npages > bufpages)) { + if (freemax == i) { needbuffer++; tsleep(&needbuffer, PRIBIO, "needbuffer", 0); splx(s); @@ -1054,12 +928,11 @@ buf_get(struct vnode *vp, daddr64_t blkno, size_t size) bp->b_blkno = bp->b_lblkno = blkno; bgetvp(vp, bp); - if (RB_INSERT(buf_rb_bufs, &vp->v_bufs_tree, bp)) - panic("buf_get: dup lblk vp %p bp %p", vp, bp); + binshash(bp, BUFHASH(vp, blkno)); } else { bp->b_vnbufs.le_next = NOLIST; SET(bp->b_flags, B_INVAL); - bp->b_vp = NULL; + binshash(bp, &invalhash); } LIST_INSERT_HEAD(&bufhead, bp, b_list); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ced2bdc291e..4d09d4f20a0 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.177 2009/06/06 18:06:22 art Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.178 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -59,7 +59,6 @@ #include <sys/mbuf.h> #include <sys/syscallargs.h> #include <sys/pool.h> -#include <sys/tree.h> #include <uvm/uvm_extern.h> #include <sys/sysctl.h> @@ -116,19 +115,6 @@ void printlockedvnodes(void); struct pool vnode_pool; -static int rb_buf_compare(struct buf *b1, struct buf *b2); -RB_GENERATE(buf_rb_bufs, buf, b_rbbufs, rb_buf_compare); - -static int -rb_buf_compare(struct buf *b1, struct buf *b2) -{ - if (b1->b_lblkno < b2->b_lblkno) - return(-1); - if (b1->b_lblkno > b2->b_lblkno) - return(1); - return(0); -} - /* * Initialize the vnode management data structures. */ @@ -359,7 +345,6 @@ getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *), ((TAILQ_FIRST(listhd = &vnode_hold_list) == NULL) || toggle))) { splx(s); vp = pool_get(&vnode_pool, PR_WAITOK | PR_ZERO); - RB_INIT(&vp->v_bufs_tree); numvnodes++; } else { for (vp = TAILQ_FIRST(listhd); vp != NULLVP; diff --git a/sys/sys/buf.h b/sys/sys/buf.h index d8b021a5f81..522a320711f 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.h,v 1.64 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: buf.h,v 1.65 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */ /* @@ -40,16 +40,12 @@ #ifndef _SYS_BUF_H_ #define _SYS_BUF_H_ #include <sys/queue.h> -#include <sys/tree.h> #define NOLIST ((struct buf *)0x87654321) struct buf; struct vnode; -struct buf_rb_bufs; -RB_PROTOTYPE(buf_rb_bufs, buf, b_rbbufs, rb_buf_compare); - LIST_HEAD(bufhead, buf); /* @@ -76,8 +72,8 @@ extern struct bio_ops { * The buffer header describes an I/O operation in the kernel. */ struct buf { - RB_ENTRY(buf) b_rbbufs; /* vnode "hash" tree */ LIST_ENTRY(buf) b_list; /* All allocated buffers. */ + LIST_ENTRY(buf) b_hash; /* Hash chain. */ LIST_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */ TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */ time_t b_synctime; /* Time this buffer should be flushed */ diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 402a926e398..b856a781827 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.h,v 1.94 2009/06/05 04:29:14 beck Exp $ */ +/* $OpenBSD: mount.h,v 1.95 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ /* @@ -504,14 +504,8 @@ struct bcachestats { int64_t cachehits; /* total reads found in cache */ }; #ifdef _KERNEL -#define BACKPAGES 100 extern struct bcachestats bcstats; -extern long buflowpages, bufhighpages; -#define BUFPAGES_DEFICIT (((buflowpages - bcstats.numbufpages) < 0) ? 0 \ - : buflowpages - bcstats.numbufpages) -extern int bufcachepercent; -extern void bufadjust(int); -extern int bufbackoff(void); +#define BUFPAGES_DEFICIT (bufpages - bcstats.numbufpages) #endif /* diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index 408f1c047ac..69c415c8a51 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.h,v 1.104 2009/06/03 15:47:13 jj Exp $ */ +/* $OpenBSD: syscall.h,v 1.105 2009/06/15 17:01:26 beck Exp $ */ /* * System call numbers. diff --git a/sys/sys/syscallargs.h b/sys/sys/syscallargs.h index 38df51dff5d..8aa98f64558 100644 --- a/sys/sys/syscallargs.h +++ b/sys/sys/syscallargs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: syscallargs.h,v 1.106 2009/06/03 15:47:13 jj Exp $ */ +/* $OpenBSD: syscallargs.h,v 1.107 2009/06/15 17:01:26 beck Exp $ */ /* * System call argument lists. diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 93fc0798768..b1cf095d9cf 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.98 2009/06/07 03:07:19 millert Exp $ */ +/* $OpenBSD: sysctl.h,v 1.99 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -184,9 +184,8 @@ struct ctlname { #define KERN_TIMECOUNTER 69 /* node: timecounter */ #define KERN_MAXLOCKSPERUID 70 /* int: locks per uid */ #define KERN_CPTIME2 71 /* array: cp_time2 */ -#define KERN_CACHEPCT 72 /* buffer cache % of physmem */ -#define KERN_FILE2 73 /* struct: file entries */ -#define KERN_MAXID 74 /* number of valid kern ids */ +#define KERN_FILE2 72 /* struct: file entries */ +#define KERN_MAXID 73 /* number of valid kern ids */ #define CTL_KERN_NAMES { \ { 0, 0 }, \ @@ -261,7 +260,6 @@ struct ctlname { { "timecounter", CTLTYPE_NODE }, \ { "maxlocksperuid", CTLTYPE_INT }, \ { "cp_time2", CTLTYPE_STRUCT }, \ - { "bufcachepercent", CTLTYPE_INT }, \ { "file2", CTLTYPE_STRUCT }, \ } diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 76a5fe81c41..e640dc36027 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.99 2009/06/03 14:45:55 jj Exp $ */ +/* $OpenBSD: vnode.h,v 1.100 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -32,12 +32,10 @@ * @(#)vnode.h 8.11 (Berkeley) 11/21/94 */ -#include <sys/buf.h> #include <sys/types.h> #include <sys/queue.h> #include <sys/lock.h> #include <sys/selinfo.h> -#include <sys/tree.h> #include <uvm/uvm.h> #include <uvm/uvm_vnode.h> @@ -81,8 +79,6 @@ enum vtagtype { */ LIST_HEAD(buflists, buf); -RB_HEAD(buf_rb_bufs, buf); - struct vnode { struct uvm_vnode v_uvm; /* uvm data */ int (**v_op)(void *); /* vnode operations vector */ @@ -98,7 +94,6 @@ struct vnode { struct mount *v_mount; /* ptr to vfs we are in */ TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ LIST_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ - struct buf_rb_bufs v_bufs_tree; /* lookup of all bufs */ struct buflists v_cleanblkhd; /* clean blocklist head */ struct buflists v_dirtyblkhd; /* dirty blocklist head */ u_int v_numoutput; /* num of writes in progress */ diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 3e88675842b..b30cf1e0a98 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.47 2009/06/06 23:35:08 art Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.48 2009/06/15 17:01:26 beck Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -214,8 +214,8 @@ uvm_pageout(void *arg) for (;;) { uvm_lock_fpageq(); UVMHIST_LOG(pdhist," <<SLEEPING>>",0,0,0,0); - msleep(&uvm.pagedaemon_proc, &uvm.fpageqlock, - PVM | PNORELOCK, "pgdaemon", 0); + msleep(&uvm.pagedaemon_proc, &uvm.fpageqlock, PVM | PNORELOCK, + "pgdaemon", 0); uvmexp.pdwoke++; UVMHIST_LOG(pdhist," <<WOKE UP>>",0,0,0,0); @@ -239,13 +239,11 @@ uvm_pageout(void *arg) uvmexp.inactarg); /* - * get pages from the buffer cache, or scan if needed + * scan if needed */ - if (uvmexp.inactive < uvmexp.inactarg) + if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg || + uvmexp.inactive < uvmexp.inactarg) { uvmpd_scan(); - else if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg) { - if (bufbackoff() == -1) - uvmpd_scan(); } /* |