summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-02-01 11:02:42 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-02-01 11:02:42 +0000
commit595dd335893d246bb8a7f18605972d1a426cf870 (patch)
tree6ec994964b439aeb25b054b2abc6e8381f52260c /sys
parentbd8e2883dc73960cd3e30c0dff751a46b7a53feb (diff)
Implement BUFCACHEPERCENT. Allow bufpages/nbuf larger than 1 (still max out
at all buffers be MAXBSIZE). Remove faulty limit test of buffer pages allocation. The check is now done at the bufpages+nbuf calculations.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/arc/arc/machdep.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/sys/arch/arc/arc/machdep.c b/sys/arch/arc/arc/machdep.c
index 755fd0f1954..36aba12888a 100644
--- a/sys/arch/arc/arc/machdep.c
+++ b/sys/arch/arc/arc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.17 1997/01/28 03:54:52 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.18 1997/02/01 11:02:41 deraadt Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 8.3 (Berkeley) 1/12/94
- * $Id: machdep.c,v 1.17 1997/01/28 03:54:52 deraadt Exp $
+ * $Id: machdep.c,v 1.18 1997/02/01 11:02:41 deraadt Exp $
*/
/* from: Utah Hdr: machdep.c 1.63 91/04/24 */
@@ -406,6 +406,10 @@ mips_init(argc, argv, code)
valloc(msqids, struct msqid_ds, msginfo.msgmni);
#endif
+#ifndef BUFCACHEPERCENT
+#define BUFCACHEPERCENT 5
+#endif
+
/*
* Determine how many buffers to allocate.
* We allocate more buffer space than the BSD standard of
@@ -413,13 +417,29 @@ mips_init(argc, argv, code)
* We just allocate a flat 10%. Ensure a minimum of 16 buffers.
* We allocate 1/2 as many swap buffer headers as file i/o buffers.
*/
- if (bufpages == 0)
- bufpages = physmem / 10 / CLSIZE;
+ if (bufpages == 0) {
+ if (physmem < btoc(2 * 1024 * 1024))
+ bufpages = physmem / (10 * CLSIZE);
+ else
+ bufpages = (btoc(2 * 1024 * 1024) + physmem) /
+ ((100/BUFCACHEPERCENT) * CLSIZE);
+ }
if (nbuf == 0) {
nbuf = bufpages;
if (nbuf < 16)
nbuf = 16;
}
+
+ /* Restrict to at most 70% filled kvm */
+ if (nbuf * MAXBSIZE >
+ (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) * 7 / 10)
+ nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
+ MAXBSIZE * 7 / 10;
+
+ /* More buffer pages than fits into the buffers is senseless. */
+ if (bufpages > nbuf * MAXBSIZE / CLBYTES)
+ bufpages = nbuf * MAXBSIZE / CLBYTES;
+
if (nswbuf == 0) {
nswbuf = (nbuf / 2) &~ 1; /* force even */
if (nswbuf > 256)
@@ -561,6 +581,12 @@ cpu_startup()
panic("startup: cannot allocate buffers");
base = bufpages / nbuf;
residual = bufpages % nbuf;
+ if (base >= MAXBSIZE / CLBYTES) {
+ /* don't want to alloc more physical mem than needed */
+ base = MAXBSIZE / CLBYTES;
+ residual = 0;
+ }
+
for (i = 0; i < nbuf; i++) {
vm_size_t curbufsize;
vm_offset_t curbuf;