summaryrefslogtreecommitdiff
path: root/sys/arch/arm
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/arm
parent6e18a0b85a66c596fb041fbf27229487f6661bbf (diff)
Dynamic buffer cache. Initial diff from mickey@, okay art@ beck@ toby@
deraadt@ dlg@.
Diffstat (limited to 'sys/arch/arm')
-rw-r--r--sys/arch/arm/arm/arm32_machdep.c88
1 files changed, 11 insertions, 77 deletions
diff --git a/sys/arch/arm/arm/arm32_machdep.c b/sys/arch/arm/arm/arm32_machdep.c
index ce628cccc41..81b7fe52ca6 100644
--- a/sys/arch/arm/arm/arm32_machdep.c
+++ b/sys/arch/arm/arm/arm32_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arm32_machdep.c,v 1.23 2007/05/23 20:33:46 pvalchev Exp $ */
+/* $OpenBSD: arm32_machdep.c,v 1.24 2007/05/26 20:26:50 pedro Exp $ */
/* $NetBSD: arm32_machdep.c,v 1.42 2003/12/30 12:33:15 pk Exp $ */
/*
@@ -76,12 +76,6 @@ struct vm_map *phys_map = NULL;
extern int physmem;
caddr_t allocsys(caddr_t);
-#ifdef NBUF
-int nbuf = NBUF;
-#else
-int nbuf = 0;
-#endif
-
#ifndef BUFCACHEPERCENT
#define BUFCACHEPERCENT 5
#endif
@@ -263,8 +257,6 @@ cpu_startup()
paddr_t maxaddr;
caddr_t sysbase;
caddr_t size;
- vsize_t bufsize;
- int base, residual;
proc0paddr = (struct user *)kernelstack.pv_va;
proc0.p_addr = proc0paddr;
@@ -328,49 +320,18 @@ cpu_startup()
if ((caddr_t)((allocsys(sysbase) - sysbase)) != size)
panic("cpu_startup: system 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.
*/
- bufsize = MAXBSIZE * nbuf;
- if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(bufsize),
- NULL, UVM_UNKNOWN_OFFSET, 0,
- UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE,
- UVM_ADV_NORMAL, 0)) != 0)
- panic("cpu_startup: cannot allocate UVM space for buffers");
- minaddr = (vaddr_t)buffers;
- if ((bufpages / nbuf) >= btoc(MAXBSIZE)) {
- /* don't want to alloc more physical mem than needed */
- bufpages = btoc(MAXBSIZE) * nbuf;
- }
+ if (bufpages == 0)
+ bufpages = physmem * bufcachepercent / 100;
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- for (loop = 0; loop < nbuf; ++loop) {
- vsize_t curbufsize;
- vaddr_t curbuf;
- struct vm_page *pg;
-
- /*
- * 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 + (loop * MAXBSIZE);
- curbufsize = NBPG * ((loop < 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
@@ -557,33 +518,6 @@ allocsys(caddr_t v)
valloc(msghdrs, struct msg, msginfo.msgtql);
valloc(msqids, struct msqid_ds, msginfo.msgmni);
#endif
- /*
- * Determine how many buffers to allocate. We use 10% of the
- * first 2MB of memory, and 5% of the rest, with a minimum of 16
- * buffers. We allocate 1/2 as many swap buffer headers as file
- * i/o buffers.
- */
- if (bufpages == 0) {
- bufpages = (btoc(2 * 1024 * 1024) + physmem) *
- bufcachepercent / 100;
- }
- if (nbuf == 0) {
- nbuf = bufpages;
- if (nbuf < 16)
- nbuf = 16;
- }
-
- /* Restrict to at most 35% filled kvm */
- /* XXX - This needs UBC... */
- if (nbuf >
- (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / MAXBSIZE * 35 / 100)
- nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
- MAXBSIZE * 35 / 100;
-
- /* 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;
}