diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-10-25 11:14:17 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-10-25 11:14:17 +0000 |
commit | a837e08e3febb5620920b855ae00e03b1bf3bc03 (patch) | |
tree | e23e3e5cf06811b7960c005eee019ecc8f39e07b /sys | |
parent | 613ad0c8bdad3b3a6f611f37b4fa86e5b8ffe88c (diff) |
grow kvm space; fix an over-agressive pmap optimization
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/conf/Makefile.i386 | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 19 | ||||
-rw-r--r-- | sys/arch/i386/i386/pmap.c | 36 | ||||
-rw-r--r-- | sys/arch/i386/i386/pmap.old.c | 36 | ||||
-rw-r--r-- | sys/arch/i386/include/param.h | 8 | ||||
-rw-r--r-- | sys/arch/i386/include/pmap.h | 9 | ||||
-rw-r--r-- | sys/arch/i386/include/pmap.old.h | 9 | ||||
-rw-r--r-- | sys/arch/i386/include/vmparam.h | 8 |
8 files changed, 93 insertions, 36 deletions
diff --git a/sys/arch/i386/conf/Makefile.i386 b/sys/arch/i386/conf/Makefile.i386 index 8ebfdc2686a..50aa6a56c0f 100644 --- a/sys/arch/i386/conf/Makefile.i386 +++ b/sys/arch/i386/conf/Makefile.i386 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.i386,v 1.15 1996/10/17 21:47:11 niklas Exp $ +# $OpenBSD: Makefile.i386,v 1.16 1996/10/25 11:14:10 deraadt Exp $ # $NetBSD: Makefile.i386,v 1.67 1996/05/11 16:12:11 mycroft Exp $ # Makefile for OpenBSD @@ -47,7 +47,7 @@ CMACHFLAGS= CFLAGS= ${DEBUG} -O2 ${CDIAGFLAGS} ${CMACHFLAGS} ${COPTS} AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE -LINKFLAGS= -z -Ttext F8100000 -e start +LINKFLAGS= -z -Ttext F0100000 -e start ### find out what to use for libkern .include "$S/lib/libkern/Makefile.inc" diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index a8be82eebae..e1650588df8 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.26 1996/10/25 06:20:14 downsj Exp $ */ +/* $OpenBSD: machdep.c,v 1.27 1996/10/25 11:14:12 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.202 1996/05/18 15:54:59 christos Exp $ */ /*- @@ -217,12 +217,15 @@ cpu_startup() if (vm_map_find(buffer_map, vm_object_allocate(size), (vm_offset_t)0, &minaddr, size, FALSE) != KERN_SUCCESS) panic("startup: cannot allocate buffers"); - if ((bufpages / nbuf) >= btoc(MAXBSIZE)) { - /* don't want to alloc more physical mem than needed */ - bufpages = btoc(MAXBSIZE) * nbuf; - } + base = bufpages / nbuf; residual = bufpages % nbuf; + if (base >= MAXBSIZE) { + /* don't want to alloc more physical mem than needed */ + base = MAXBSIZE; + residual = 0; + } + for (i = 0; i < nbuf; i++) { vm_size_t curbufsize; vm_offset_t curbuf; @@ -366,6 +369,12 @@ allocsys(v) else bufpages = (btoc(2 * 1024 * 1024) + physmem) / ((100/BUFCACHEPERCENT) * CLSIZE); + + /* Restrict to at most 70% filled kvm */ + if (bufpages * MAXBSIZE * 7 / 10 > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS)) + bufpages = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + MAXBSIZE * 7 / 10; if (nbuf == 0) { nbuf = bufpages; if (nbuf < 16) diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index 7528cffd39c..cf4c5717c1f 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.14 1996/10/18 15:33:08 mickey Exp $ */ +/* $OpenBSD: pmap.c,v 1.15 1996/10/25 11:14:13 deraadt Exp $ */ /* $NetBSD: pmap.c,v 1.36 1996/05/03 19:42:22 christos Exp $ */ /* @@ -226,6 +226,7 @@ pmap_bootstrap(virtual_start) vm_offset_t va; pt_entry_t *pte; #endif + /* XXX: allow for msgbuf */ avail_end -= i386_round_page(sizeof(struct msgbuf)); @@ -297,6 +298,19 @@ pmap_bootstrap(virtual_start) } #endif + /* flawed, no mappings?? */ + if (ctob(physmem) > 31*1024*1024 && MAXKPDE != NKPDE) { + vm_offset_t p; + int i; + + p = pmap_steal_memory((MAXKPDE-NKPDE+1) * NBPG); + bzero((void *)p, (MAXKPDE-NKPDE+1) * NBPG); + p = round_page(p); + for (i = NKPDE; i < MAXKPDE; i++, p += NBPG) + PTD[KPTDI+i] = (pd_entry_t)p | + PG_V | PG_KW; + } + pmap_update(); } @@ -640,11 +654,12 @@ pmap_pinit(pmap) pmap->pm_pdir = (pd_entry_t *) kmem_alloc(kernel_map, NBPG); /* wire in kernel global address entries */ - bcopy(&PTD[KPTDI], &pmap->pm_pdir[KPTDI], NKPDE * sizeof(pd_entry_t)); + bcopy(&PTD[KPTDI], &pmap->pm_pdir[KPTDI], MAXKPDE * + sizeof(pd_entry_t)); /* install self-referential address mapping entry */ - pmap->pm_pdir[PTDPTDI] = - pmap_extract(pmap_kernel(), (vm_offset_t)pmap->pm_pdir) | PG_V | PG_KW; + pmap->pm_pdir[PTDPTDI] = pmap_extract(pmap_kernel(), + (vm_offset_t)pmap->pm_pdir) | PG_V | PG_KW; pmap->pm_count = 1; simple_lock_init(&pmap->pm_lock); @@ -786,6 +801,13 @@ pmap_remove(pmap, sva, eva) } } + pte = pmap_pte(pmap, sva); + if (pte == NULL) { + /* We can race ahead here, to the next pde. */ + sva = (sva & PD_MASK) + NBPD; + continue; + } + if (!pmap_pte_v(pte)) { #ifdef __GNUC__ /* @@ -1107,19 +1129,19 @@ pmap_enter(pmap, va, pa, prot, wired) * educated guess as to which vm_map to use by using curproc. * this is a workaround and may not fully solve the problem? */ - struct vm_map *vmap; int rv; vm_offset_t v; if (curproc == NULL || curproc->p_vmspace == NULL || - pmap != &curproc->p_vmspace->vm_pmap) - panic("ptdi %x", pmap->pm_pdir[PTDPTDI]); + pmap != &curproc->p_vmspace->vm_pmap) + panic("ptdi %x", pmap->pm_pdir[PTDPTDI]); /* our guess about the vm_map was good! fault it in. */ vmap = &curproc->p_vmspace->vm_map; v = trunc_page(vtopte(va)); + printf("faulting in a pt page map %x va %x\n", vmap, v); rv = vm_fault(vmap, v, VM_PROT_READ|VM_PROT_WRITE, FALSE); if (rv != KERN_SUCCESS) panic("ptdi2 %x", pmap->pm_pdir[PTDPTDI]); diff --git a/sys/arch/i386/i386/pmap.old.c b/sys/arch/i386/i386/pmap.old.c index 5e756ed7cc7..57ae1e13313 100644 --- a/sys/arch/i386/i386/pmap.old.c +++ b/sys/arch/i386/i386/pmap.old.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.old.c,v 1.14 1996/10/18 15:33:08 mickey Exp $ */ +/* $OpenBSD: pmap.old.c,v 1.15 1996/10/25 11:14:13 deraadt Exp $ */ /* $NetBSD: pmap.c,v 1.36 1996/05/03 19:42:22 christos Exp $ */ /* @@ -226,6 +226,7 @@ pmap_bootstrap(virtual_start) vm_offset_t va; pt_entry_t *pte; #endif + /* XXX: allow for msgbuf */ avail_end -= i386_round_page(sizeof(struct msgbuf)); @@ -297,6 +298,19 @@ pmap_bootstrap(virtual_start) } #endif + /* flawed, no mappings?? */ + if (ctob(physmem) > 31*1024*1024 && MAXKPDE != NKPDE) { + vm_offset_t p; + int i; + + p = pmap_steal_memory((MAXKPDE-NKPDE+1) * NBPG); + bzero((void *)p, (MAXKPDE-NKPDE+1) * NBPG); + p = round_page(p); + for (i = NKPDE; i < MAXKPDE; i++, p += NBPG) + PTD[KPTDI+i] = (pd_entry_t)p | + PG_V | PG_KW; + } + pmap_update(); } @@ -640,11 +654,12 @@ pmap_pinit(pmap) pmap->pm_pdir = (pd_entry_t *) kmem_alloc(kernel_map, NBPG); /* wire in kernel global address entries */ - bcopy(&PTD[KPTDI], &pmap->pm_pdir[KPTDI], NKPDE * sizeof(pd_entry_t)); + bcopy(&PTD[KPTDI], &pmap->pm_pdir[KPTDI], MAXKPDE * + sizeof(pd_entry_t)); /* install self-referential address mapping entry */ - pmap->pm_pdir[PTDPTDI] = - pmap_extract(pmap_kernel(), (vm_offset_t)pmap->pm_pdir) | PG_V | PG_KW; + pmap->pm_pdir[PTDPTDI] = pmap_extract(pmap_kernel(), + (vm_offset_t)pmap->pm_pdir) | PG_V | PG_KW; pmap->pm_count = 1; simple_lock_init(&pmap->pm_lock); @@ -786,6 +801,13 @@ pmap_remove(pmap, sva, eva) } } + pte = pmap_pte(pmap, sva); + if (pte == NULL) { + /* We can race ahead here, to the next pde. */ + sva = (sva & PD_MASK) + NBPD; + continue; + } + if (!pmap_pte_v(pte)) { #ifdef __GNUC__ /* @@ -1107,19 +1129,19 @@ pmap_enter(pmap, va, pa, prot, wired) * educated guess as to which vm_map to use by using curproc. * this is a workaround and may not fully solve the problem? */ - struct vm_map *vmap; int rv; vm_offset_t v; if (curproc == NULL || curproc->p_vmspace == NULL || - pmap != &curproc->p_vmspace->vm_pmap) - panic("ptdi %x", pmap->pm_pdir[PTDPTDI]); + pmap != &curproc->p_vmspace->vm_pmap) + panic("ptdi %x", pmap->pm_pdir[PTDPTDI]); /* our guess about the vm_map was good! fault it in. */ vmap = &curproc->p_vmspace->vm_map; v = trunc_page(vtopte(va)); + printf("faulting in a pt page map %x va %x\n", vmap, v); rv = vm_fault(vmap, v, VM_PROT_READ|VM_PROT_WRITE, FALSE); if (rv != KERN_SUCCESS) panic("ptdi2 %x", pmap->pm_pdir[PTDPTDI]); diff --git a/sys/arch/i386/include/param.h b/sys/arch/i386/include/param.h index 7fdea524187..4e7f087db1c 100644 --- a/sys/arch/i386/include/param.h +++ b/sys/arch/i386/include/param.h @@ -1,4 +1,4 @@ -/* $OpenBSD: param.h,v 1.3 1996/04/18 19:21:38 niklas Exp $ */ +/* $OpenBSD: param.h,v 1.4 1996/10/25 11:14:15 deraadt Exp $ */ /* $NetBSD: param.h,v 1.29 1996/03/04 05:04:26 cgd Exp $ */ /*- @@ -70,9 +70,11 @@ #define PGOFSET (NBPG-1) /* byte offset into page */ #define NPTEPG (NBPG/(sizeof (pt_entry_t))) -#define KERNBASE 0xf8000000 /* start of kernel virtual space */ +#define KERNBASE 0xf0000000 /* start of kernel virtual space */ +#if 0 #define KERNSIZE 0x01800000 /* size of kernel virtual space */ -#define KERNTEXTOFF 0xf8100000 /* start of kernel text */ +#endif +#define KERNTEXTOFF 0xf0100000 /* start of kernel text */ #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ diff --git a/sys/arch/i386/include/pmap.h b/sys/arch/i386/include/pmap.h index 3c836956800..4d43e526f80 100644 --- a/sys/arch/i386/include/pmap.h +++ b/sys/arch/i386/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.6 1996/05/26 00:06:07 deraadt Exp $ */ +/* $OpenBSD: pmap.h,v 1.7 1996/10/25 11:14:16 deraadt Exp $ */ /* $NetBSD: pmap.h,v 1.23 1996/05/03 19:26:30 christos Exp $ */ /* @@ -66,9 +66,10 @@ * One page directory, shared between * kernel and user modes. */ -#define PTDPTDI 0x3df /* ptd entry that points to ptd! */ -#define KPTDI 0x3e0 /* start of kernel virtual pde's */ -#define NKPDE 31 +#define PTDPTDI 0x3bf /* ptd entry that points to ptd! */ +#define KPTDI 0x3c0 /* start of kernel virtual pde's */ +#define NKPDE 63 /* # to static alloc */ +#define MAXKPDE (APTDPTDI-KPTDI) #define APTDPTDI 0x3ff /* start of alternate page directory */ /* diff --git a/sys/arch/i386/include/pmap.old.h b/sys/arch/i386/include/pmap.old.h index 0a3f15c7ad3..3fbeaf58fdd 100644 --- a/sys/arch/i386/include/pmap.old.h +++ b/sys/arch/i386/include/pmap.old.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.old.h,v 1.6 1996/05/26 00:06:07 deraadt Exp $ */ +/* $OpenBSD: pmap.old.h,v 1.7 1996/10/25 11:14:16 deraadt Exp $ */ /* $NetBSD: pmap.h,v 1.23 1996/05/03 19:26:30 christos Exp $ */ /* @@ -66,9 +66,10 @@ * One page directory, shared between * kernel and user modes. */ -#define PTDPTDI 0x3df /* ptd entry that points to ptd! */ -#define KPTDI 0x3e0 /* start of kernel virtual pde's */ -#define NKPDE 31 +#define PTDPTDI 0x3bf /* ptd entry that points to ptd! */ +#define KPTDI 0x3c0 /* start of kernel virtual pde's */ +#define NKPDE 63 /* # to static alloc */ +#define MAXKPDE (APTDPTDI-KPTDI) #define APTDPTDI 0x3ff /* start of alternate page directory */ /* diff --git a/sys/arch/i386/include/vmparam.h b/sys/arch/i386/include/vmparam.h index 8de4f0957bf..00f9036cca8 100644 --- a/sys/arch/i386/include/vmparam.h +++ b/sys/arch/i386/include/vmparam.h @@ -130,12 +130,12 @@ /* user/kernel map constants */ #define VM_MIN_ADDRESS ((vm_offset_t)0) -/* PTDPTDI<<PDSHIFT - UPAGES*NBPG */ -#define VM_MAXUSER_ADDRESS ((vm_offset_t)0xf7bfe000) +/* PTDPTDI<<PDSHIFT - USPACE */ +#define VM_MAXUSER_ADDRESS ((vm_offset_t)0xefbfe000) /* PTDPTDI<<PDSHIFT + PTDPTDI<<PGSHIFT */ -#define VM_MAX_ADDRESS ((vm_offset_t)0xf7fdf000) +#define VM_MAX_ADDRESS ((vm_offset_t)0xeffdf000) /* KPTDI<<PDSHIFT */ -#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)0xf8000000) +#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)0xf0000000) /* APTDPTDI<<PDSHIFT */ #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)0xffc00000) |