summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-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;