diff options
author | Alan Cox <alc@FreeBSD.org> | 2009-06-17 17:19:48 +0000 |
---|---|---|
committer | Alan Cox <alc@FreeBSD.org> | 2009-06-17 17:19:48 +0000 |
commit | d78200e4e85e4c1c6f763c62647fdaf859bc45f2 (patch) | |
tree | 645f687c5c92adb1dfc423f6cca74d4c9292981f /sys/vm | |
parent | 30a2bd2f78b7eec1f7efdaffb3eaf0a00f8e1e29 (diff) | |
download | src-d78200e4e85e4c1c6f763c62647fdaf859bc45f2.tar.gz src-d78200e4e85e4c1c6f763c62647fdaf859bc45f2.zip |
Refactor contigmalloc() into two functions: a simple front-end that deals
with the malloc tag and calls a new back-end, kmem_alloc_contig(), that
allocates the pages and maps them.
The motivations for this change are two-fold: (1) A cache mode parameter
will be added to kmem_alloc_contig(). In other words, kmem_alloc_contig()
will be extended to support the allocation of memory with caller-specified
caching. (2) The UMA allocation function that is used by the two jumbo
frames zones can use kmem_alloc_contig() in place of contigmalloc() and
thereby avoid having free jumbo frames held by the zone counted as live
malloc()ed memory.
Notes
Notes:
svn path=/head/; revision=194376
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_contig.c | 27 | ||||
-rw-r--r-- | sys/vm/vm_extern.h | 3 |
2 files changed, 22 insertions, 8 deletions
diff --git a/sys/vm/vm_contig.c b/sys/vm/vm_contig.c index 83ae7385599a..8dec3b57f890 100644 --- a/sys/vm/vm_contig.c +++ b/sys/vm/vm_contig.c @@ -193,7 +193,7 @@ vm_page_release_contig(vm_page_t m, vm_pindex_t count) * specified through the given flags, then the pages are zeroed * before they are mapped. */ -static void * +static vm_offset_t contigmapping(vm_map_t map, vm_size_t size, vm_page_t m, int flags) { vm_object_t object = kernel_object; @@ -202,7 +202,7 @@ contigmapping(vm_map_t map, vm_size_t size, vm_page_t m, int flags) vm_map_lock(map); if (vm_map_findspace(map, vm_map_min(map), size, &addr)) { vm_map_unlock(map); - return (NULL); + return (0); } vm_object_reference(object); vm_map_insert(map, object, addr - VM_MIN_KERNEL_ADDRESS, @@ -220,7 +220,7 @@ contigmapping(vm_map_t map, vm_size_t size, vm_page_t m, int flags) VM_OBJECT_UNLOCK(object); vm_map_wire(map, addr, addr + size, VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); - return ((void *)addr); + return (addr); } void * @@ -234,6 +234,19 @@ contigmalloc( unsigned long boundary) { void *ret; + + ret = (void *)kmem_alloc_contig(kernel_map, size, flags, low, high, + alignment, boundary); + if (ret != NULL) + malloc_type_allocated(type, round_page(size)); + return (ret); +} + +vm_offset_t +kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, vm_paddr_t low, + vm_paddr_t high, unsigned long alignment, unsigned long boundary) +{ + vm_offset_t ret; vm_page_t pages; unsigned long npgs; int actl, actmax, inactl, inactmax, tries; @@ -265,13 +278,11 @@ again: tries++; goto retry; } - ret = NULL; + ret = 0; } else { - ret = contigmapping(kernel_map, size, pages, flags); - if (ret == NULL) + ret = contigmapping(map, size, pages, flags); + if (ret == 0) vm_page_release_contig(pages, npgs); - else - malloc_type_allocated(type, npgs << PAGE_SHIFT); } return (ret); } diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index 475a20ef3ef7..efd363aa5978 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -44,6 +44,9 @@ struct vnode; int kernacc(void *, int, int); vm_offset_t kmem_alloc(vm_map_t, vm_size_t); +vm_offset_t kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, + vm_paddr_t low, vm_paddr_t high, unsigned long alignment, + unsigned long boundary); vm_offset_t kmem_alloc_nofault(vm_map_t, vm_size_t); vm_offset_t kmem_alloc_wait(vm_map_t, vm_size_t); void kmem_free(vm_map_t, vm_offset_t, vm_size_t); |