summaryrefslogtreecommitdiff
path: root/sys/arch/mac68k
diff options
context:
space:
mode:
authorPedro Martelletto <pedro@cvs.openbsd.org>2007-05-26 20:26:52 +0000
committerPedro Martelletto <pedro@cvs.openbsd.org>2007-05-26 20:26:52 +0000
commit196f5066228d908cbac060396a1aba557efe1ef3 (patch)
tree5c48aa4f82af6d902afe35afb642c3d4225a1a07 /sys/arch/mac68k
parent6e18a0b85a66c596fb041fbf27229487f6661bbf (diff)
Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.
Diffstat (limited to 'sys/arch/mac68k')
-rw-r--r--sys/arch/mac68k/mac68k/machdep.c78
1 files changed, 10 insertions, 68 deletions
diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c
index 46956d3b101..02e1ebc0128 100644
--- a/sys/arch/mac68k/mac68k/machdep.c
+++ b/sys/arch/mac68k/mac68k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.137 2007/05/23 20:33:46 pvalchev Exp $ */
+/* $OpenBSD: machdep.c,v 1.138 2007/05/26 20:26:50 pedro Exp $ */
/* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */
/*
@@ -173,12 +173,6 @@ struct vm_map *phys_map = NULL;
/*
* Declare these as initialized data so we can patch them.
*/
-#ifdef NBUF
-int nbuf = NBUF;
-#else
-int nbuf = 0;
-#endif
-
#ifndef BUFCACHEPERCENT
#define BUFCACHEPERCENT 5
#endif
@@ -364,7 +358,6 @@ cpu_startup(void)
caddr_t v;
unsigned i;
int vers;
- int base, residual;
vaddr_t minaddr, maxaddr;
vsize_t size = 0; /* To avoid compiler warning */
int delay;
@@ -419,43 +412,17 @@ cpu_startup(void)
panic("startup: table size inconsistency");
/*
- * Now allocate buffers proper. They are different than the above
- * in that they usually occupy more virtual memory than physical.
+ * Determine how many buffers to allocate.
+ * We allocate bufcachepercent% of memory for buffer space.
*/
- size = MAXBSIZE * nbuf;
- if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size),
- NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE,
- UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0)))
- panic("startup: cannot allocate VM for buffers");
- minaddr = (vaddr_t)buffers;
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- for (i = 0; i < nbuf; i++) {
- vsize_t curbufsize;
- vaddr_t curbuf;
- struct vm_page *pg;
+ if (bufpages == 0)
+ bufpages = physmem * bufcachepercent / 100;
- /*
- * Each buffer has MAXBSIZE bytes of VM space allocated. Of
- * that MAXBSIZE space, we allocate and map (base+1) pages
- * for the first "residual" buffers, and then we allocate
- * "base" pages for the rest.
- */
- curbuf = (vaddr_t) buffers + (i * MAXBSIZE);
- curbufsize = PAGE_SIZE * ((i < residual) ? (base+1) : base);
-
- while (curbufsize) {
- pg = uvm_pagealloc(NULL, 0, NULL, 0);
- if (pg == NULL)
- panic("cpu_startup: not enough memory for "
- "buffer cache");
- pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
- VM_PROT_READ|VM_PROT_WRITE);
- curbuf += PAGE_SIZE;
- curbufsize -= PAGE_SIZE;
- }
- pmap_update(pmap_kernel());
- }
+ /* 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
@@ -472,8 +439,6 @@ cpu_startup(void)
printf("avail mem = %lu (%luMB)\n", ptoa(uvmexp.free),
ptoa(uvmexp.free) / 1024 / 1024);
- printf("using %d buffers containing %u bytes (%uK) of memory\n",
- nbuf, bufpages * PAGE_SIZE, bufpages * PAGE_SIZE / 1024);
/*
* Set up CPU-specific registers, cache, etc.
@@ -526,29 +491,6 @@ allocsys(v)
valloc(msqids, struct msqid_ds, msginfo.msgmni);
#endif
- /*
- * Determine how many buffers to allocate (enough to
- * hold 5% of total physical memory, but at least 16).
- * Allocate 1/2 as many swap buffer headers as file i/o buffers.
- */
- if (bufpages == 0)
- bufpages = physmem * bufcachepercent / 100;
- 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 / PAGE_SIZE)
- bufpages = nbuf * MAXBSIZE / PAGE_SIZE;
-
- valloc(buf, struct buf, nbuf);
return (v);
}