diff options
author | dyson <dyson@FreeBSD.org> | 1997-08-05 00:02:08 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1997-08-05 00:02:08 +0000 |
commit | 8fa8ae3d0d6a785deced2be3e7fd647f31aaf23e (patch) | |
tree | c5bee309962268ed673826beec543a2de0ff70aa /sys/vm | |
parent | 257e5090900068920bc5af171dec41a2939a084f (diff) | |
download | FreeBSD-src-8fa8ae3d0d6a785deced2be3e7fd647f31aaf23e.zip FreeBSD-src-8fa8ae3d0d6a785deced2be3e7fd647f31aaf23e.tar.gz |
Get rid of the ad-hoc memory allocator for vm_map_entries, in lieu of
a simple, clean zone type allocator. This new allocator will also be
used for machine dependent pmap PV entries.
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_kern.c | 3 | ||||
-rw-r--r-- | sys/vm/vm_map.c | 165 | ||||
-rw-r--r-- | sys/vm/vm_map.h | 7 | ||||
-rw-r--r-- | sys/vm/vm_object.c | 5 | ||||
-rw-r--r-- | sys/vm/vm_object.h | 3 | ||||
-rw-r--r-- | sys/vm/vm_page.c | 24 |
6 files changed, 45 insertions, 162 deletions
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index ea1165b..9b3bbbc 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_kern.c,v 1.37 1997/06/22 15:47:11 peter Exp $ + * $Id: vm_kern.c,v 1.38 1997/08/02 14:33:26 bde Exp $ */ /* @@ -443,6 +443,7 @@ kmem_init(start, end) vm_map_lock(m); /* N.B.: cannot use kgdb to debug, starting with this assignment ... */ kernel_map = m; + kernel_map->system_map = 1; (void) vm_map_insert(m, NULL, (vm_offset_t) 0, VM_MIN_KERNEL_ADDRESS, start, VM_PROT_ALL, VM_PROT_ALL, 0); /* ... and ending with the completion of the above `insert' */ diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index e047dab..2b6680e 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_map.c,v 1.78 1997/06/23 21:51:03 tegge Exp $ + * $Id: vm_map.c,v 1.79 1997/07/27 04:44:12 dyson Exp $ */ /* @@ -89,6 +89,7 @@ #include <vm/vm_pager.h> #include <vm/vm_extern.h> #include <vm/default_pager.h> +#include <vm/vm_zone.h> /* * Virtual memory maps provide for the mapping, protection, @@ -148,20 +149,17 @@ * maps and requires map entries. */ -vm_offset_t kentry_data; -vm_size_t kentry_data_size; -static vm_map_entry_t kentry_free; -static vm_map_t kmap_free; extern char kstack[]; extern int inmprotect; static int kentry_count; -static vm_offset_t mapvm_start, mapvm, mapvmmax; -static int mapvmpgcnt; - -static struct vm_map_entry *mappool; -static int mappoolcnt; -#define KENTRY_LOW_WATER 128 +static struct vm_zone kmapentzone_store, mapentzone_store, mapzone_store; +static vm_zone_t mapentzone, kmapentzone, mapzone; +static struct vm_object kmapentobj, mapentobj, mapobj; +#define MAP_ENTRY_INIT 128 +struct vm_map_entry map_entry_init[MAX_MAPENT]; +struct vm_map_entry kmap_entry_init[MAX_KMAPENT]; +struct vm_map map_init[MAX_KMAP]; static void _vm_map_clip_end __P((vm_map_t, vm_map_entry_t, vm_offset_t)); static void _vm_map_clip_start __P((vm_map_t, vm_map_entry_t, vm_offset_t)); @@ -175,33 +173,15 @@ static void vm_map_copy_entry __P((vm_map_t, vm_map_t, vm_map_entry_t, void vm_map_startup() { - register int i; - register vm_map_entry_t mep; - vm_map_t mp; - - /* - * Static map structures for allocation before initialization of - * kernel map or kmem map. vm_map_create knows how to deal with them. - */ - kmap_free = mp = (vm_map_t) kentry_data; - i = MAX_KMAP; - while (--i > 0) { - mp->header.next = (vm_map_entry_t) (mp + 1); - mp++; - } - mp++->header.next = NULL; - - /* - * Form a free list of statically allocated kernel map entries with - * the rest. - */ - kentry_free = mep = (vm_map_entry_t) mp; - kentry_count = i = (kentry_data_size - MAX_KMAP * sizeof *mp) / sizeof *mep; - while (--i > 0) { - mep->next = mep + 1; - mep++; - } - mep->next = NULL; + mapzone = &mapzone_store; + _zbootinit(mapzone, "MAP", sizeof (struct vm_map), + map_init, MAX_KMAP); + kmapentzone = &kmapentzone_store; + _zbootinit(kmapentzone, "KMAP ENTRY", sizeof (struct vm_map_entry), + kmap_entry_init, MAX_KMAPENT); + mapentzone = &mapentzone_store; + _zbootinit(mapentzone, "MAP ENTRY", sizeof (struct vm_map_entry), + map_entry_init, MAX_MAPENT); } /* @@ -216,14 +196,6 @@ vmspace_alloc(min, max, pageable) { register struct vmspace *vm; - if (mapvmpgcnt == 0 && mapvm == 0) { - mapvmpgcnt = (cnt.v_page_count * sizeof(struct vm_map_entry) + PAGE_SIZE - 1) / PAGE_SIZE; - mapvm_start = mapvm = kmem_alloc_pageable(kernel_map, - mapvmpgcnt * PAGE_SIZE); - mapvmmax = mapvm_start + mapvmpgcnt * PAGE_SIZE; - if (!mapvm) - mapvmpgcnt = 0; - } MALLOC(vm, struct vmspace *, sizeof(struct vmspace), M_VMMAP, M_WAITOK); bzero(vm, (caddr_t) &vm->vm_startcopy - (caddr_t) vm); vm_map_init(&vm->vm_map, min, max, pageable); @@ -234,6 +206,16 @@ vmspace_alloc(min, max, pageable) } void +vm_init2(void) { + _zinit(kmapentzone, &kmapentobj, + NULL, 0, 4096, ZONE_INTERRUPT, 4); + _zinit(mapentzone, &mapentobj, + NULL, 0, 0, ZONE_WAIT, 4); + _zinit(mapzone, &mapobj, + NULL, 0, 0, ZONE_WAIT, 4); +} + +void vmspace_free(vm) register struct vmspace *vm; { @@ -278,15 +260,7 @@ vm_map_create(pmap, min, max, pageable) { register vm_map_t result; - if (kmem_map == NULL) { - result = kmap_free; - if (result == NULL) - panic("vm_map_create: out of maps"); - kmap_free = (vm_map_t) result->header.next; - } else - MALLOC(result, vm_map_t, sizeof(struct vm_map), - M_VMMAP, M_WAITOK); - + result = zalloc(mapzone); vm_map_init(result, min, max, pageable); result->pmap = pmap; return (result); @@ -308,6 +282,7 @@ vm_map_init(map, min, max, pageable) map->size = 0; map->ref_count = 1; map->is_main_map = TRUE; + map->system_map = 0; map->min_offset = min; map->max_offset = max; map->entries_pageable = pageable; @@ -328,20 +303,7 @@ vm_map_entry_dispose(map, entry) vm_map_t map; vm_map_entry_t entry; { - int s; - - if (map == kernel_map || map == kmem_map || - map == mb_map || map == pager_map) { - s = splvm(); - entry->next = kentry_free; - kentry_free = entry; - ++kentry_count; - splx(s); - } else { - entry->next = mappool; - mappool = entry; - ++mappoolcnt; - } + zfree((map->system_map || !mapentzone) ? kmapentzone : mapentzone, entry); } /* @@ -354,68 +316,7 @@ static vm_map_entry_t vm_map_entry_create(map) vm_map_t map; { - vm_map_entry_t entry; - int i; - int s; - - /* - * This is a *very* nasty (and sort of incomplete) hack!!!! - */ - if (kentry_count < KENTRY_LOW_WATER) { - s = splvm(); - if (mapvmpgcnt && mapvm) { - vm_page_t m; - - m = vm_page_alloc(kernel_object, - OFF_TO_IDX(mapvm - VM_MIN_KERNEL_ADDRESS), - (map == kmem_map || map == mb_map) ? VM_ALLOC_INTERRUPT : VM_ALLOC_NORMAL); - - if (m) { - int newentries; - - newentries = (PAGE_SIZE / sizeof(struct vm_map_entry)); - vm_page_wire(m); - PAGE_WAKEUP(m); - m->valid = VM_PAGE_BITS_ALL; - pmap_kenter(mapvm, VM_PAGE_TO_PHYS(m)); - m->flags |= PG_WRITEABLE; - - entry = (vm_map_entry_t) mapvm; - mapvm += PAGE_SIZE; - --mapvmpgcnt; - - for (i = 0; i < newentries; i++) { - vm_map_entry_dispose(kernel_map, entry); - entry++; - } - } - } - splx(s); - } - - if (map == kernel_map || map == kmem_map || - map == mb_map || map == pager_map) { - s = splvm(); - entry = kentry_free; - if (entry) { - kentry_free = entry->next; - --kentry_count; - } else { - panic("vm_map_entry_create: out of map entries for kernel"); - } - splx(s); - } else { - entry = mappool; - if (entry) { - mappool = entry->next; - --mappoolcnt; - } else { - MALLOC(entry, vm_map_entry_t, sizeof(struct vm_map_entry), - M_VMMAPENT, M_WAITOK); - } - } - - return (entry); + return zalloc((map->system_map || !mapentzone) ? kmapentzone : mapentzone); } /* @@ -496,7 +397,7 @@ vm_map_deallocate(map) vm_map_unlock(map); - FREE(map, M_VMMAP); + zfree(mapzone, map); } /* diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 8438ccf..7b87856 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_map.h,v 1.25 1997/04/06 02:29:44 dyson Exp $ + * $Id: vm_map.h,v 1.26 1997/04/07 07:16:06 peter Exp $ */ /* @@ -131,7 +131,8 @@ struct vm_map { struct vm_map_entry header; /* List of entries */ int nentries; /* Number of entries */ vm_size_t size; /* virtual size */ - boolean_t is_main_map; /* Am I a main map? */ + unsigned char is_main_map; /* Am I a main map? */ + unsigned char system_map; /* Am I a system map? */ int ref_count; /* Reference count */ struct simplelock ref_lock; /* Lock for ref_count field */ vm_map_entry_t hint; /* hint for quick lookups */ @@ -231,6 +232,7 @@ typedef struct { /* XXX: number of kernel maps and entries to statically allocate */ #define MAX_KMAP 10 #define MAX_KMAPENT 128 +#define MAX_MAPENT 128 /* * Copy-on-write flags for vm_map operations @@ -279,6 +281,7 @@ void vm_map_startup __P((void)); int vm_map_submap __P((vm_map_t, vm_offset_t, vm_offset_t, vm_map_t)); void vm_map_madvise __P((vm_map_t, pmap_t, vm_offset_t, vm_offset_t, int)); void vm_map_simplify_entry __P((vm_map_t, vm_map_entry_t)); +void vm_init2 __P((void)); #endif #endif /* _VM_MAP_ */ diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 59d20e0..27cc9c1 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_object.c,v 1.93 1997/06/22 03:00:24 dyson Exp $ + * $Id: vm_object.c,v 1.94 1997/06/22 15:47:16 peter Exp $ */ /* @@ -92,7 +92,6 @@ #include <vm/vm_kern.h> #include <vm/vm_extern.h> -static void _vm_object_allocate __P((objtype_t, vm_size_t, vm_object_t)); static void vm_object_qcollapse __P((vm_object_t object)); #ifdef not_used static void vm_object_deactivate_pages __P((vm_object_t)); @@ -142,7 +141,7 @@ static long object_collapses; static long object_bypasses; static int next_index; -static void +void _vm_object_allocate(type, size, object) objtype_t type; vm_size_t size; diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 34457f7..8cf0499 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id$ + * $Id: vm_object.h,v 1.35 1997/02/22 09:48:29 peter Exp $ */ /* @@ -171,6 +171,7 @@ vm_object_pip_wakeup(vm_object_t object) } vm_object_t vm_object_allocate __P((objtype_t, vm_size_t)); +void _vm_object_allocate __P((objtype_t, vm_size_t, vm_object_t)); void vm_object_cache_clear __P((void)); boolean_t vm_object_coalesce __P((vm_object_t, vm_pindex_t, vm_size_t, vm_size_t)); void vm_object_collapse __P((vm_object_t)); diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index fdb82c1..6d22ac5 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)vm_page.c 7.4 (Berkeley) 5/7/91 - * $Id: vm_page.c,v 1.77 1997/03/23 02:44:54 dyson Exp $ + * $Id: vm_page.c,v 1.78 1997/05/01 14:36:01 dyson Exp $ */ /* @@ -286,28 +286,6 @@ vm_page_startup(starta, enda, vaddr) } /* - * round (or truncate) the addresses to our page size. - */ - - /* - * Pre-allocate maps and map entries that cannot be dynamically - * allocated via malloc(). The maps include the kernel_map and - * kmem_map which must be initialized before malloc() will work - * (obviously). Also could include pager maps which would be - * allocated before kmeminit. - * - * Allow some kernel map entries... this should be plenty since people - * shouldn't be cluttering up the kernel map (they should use their - * own maps). - */ - - kentry_data_size = MAX_KMAP * sizeof(struct vm_map) + - MAX_KMAPENT * sizeof(struct vm_map_entry); - kentry_data_size = round_page(kentry_data_size); - kentry_data = (vm_offset_t) vaddr; - vaddr += kentry_data_size; - - /* * Validate these zone addresses. */ |