diff options
author | alc <alc@FreeBSD.org> | 2008-05-10 18:55:35 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2008-05-10 18:55:35 +0000 |
commit | 5a23437099f2b97c9acda670eb588825ed1f44dd (patch) | |
tree | d385d237ca987c5a7b00e1291306c60aa868cdf7 /sys/vm | |
parent | 840e3ca1b5be5d79f3f4ed5f4b66a01bed910f1e (diff) | |
download | FreeBSD-src-5a23437099f2b97c9acda670eb588825ed1f44dd.zip FreeBSD-src-5a23437099f2b97c9acda670eb588825ed1f44dd.tar.gz |
Generalize vm_map_find(9)'s parameter "find_space". Specifically, add
support for VMFS_ALIGNED_SPACE, which requests the allocation of an
address range best suited to superpages. The old options TRUE and FALSE
are mapped to VMFS_ANY_SPACE and VMFS_NO_SPACE, so that there is no
immediate need to update all of vm_map_find(9)'s callers.
While I'm here, correct a misstatement about vm_map_find(9)'s return
values in the man page.
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.c | 23 | ||||
-rw-r--r-- | sys/vm/vm_map.h | 10 |
2 files changed, 23 insertions, 10 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 5a98ce5..8873b98 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1200,7 +1200,7 @@ vm_map_fixed(vm_map_t map, vm_object_t object, vm_ooffset_t offset, int vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset, vm_offset_t *addr, /* IN/OUT */ - vm_size_t length, boolean_t find_space, vm_prot_t prot, + vm_size_t length, int find_space, vm_prot_t prot, vm_prot_t max, int cow) { vm_offset_t start; @@ -1208,15 +1208,20 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset, start = *addr; vm_map_lock(map); - if (find_space) { - if (vm_map_findspace(map, start, length, addr)) { - vm_map_unlock(map); - return (KERN_NO_SPACE); + do { + if (find_space != VMFS_NO_SPACE) { + if (vm_map_findspace(map, start, length, addr)) { + vm_map_unlock(map); + return (KERN_NO_SPACE); + } + if (find_space == VMFS_ALIGNED_SPACE) + pmap_align_superpage(object, offset, addr, + length); + start = *addr; } - start = *addr; - } - result = vm_map_insert(map, object, offset, - start, start + length, prot, max, cow); + result = vm_map_insert(map, object, offset, start, start + + length, prot, max, cow); + } while (result == KERN_NO_SPACE && find_space == VMFS_ALIGNED_SPACE); vm_map_unlock(map); return (result); } diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 37d9084..bc2ae43 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -325,6 +325,13 @@ long vmspace_wired_count(struct vmspace *vmspace); #define VM_FAULT_DIRTY 8 /* Dirty the page */ /* + * The following "find_space" options are supported by vm_map_find() + */ +#define VMFS_NO_SPACE 0 /* don't find; use the given range */ +#define VMFS_ANY_SPACE 1 /* find a range with any alignment */ +#define VMFS_ALIGNED_SPACE 2 /* find a superpage-aligned range */ + +/* * vm_map_wire and vm_map_unwire option flags */ #define VM_MAP_WIRE_SYSTEM 0 /* wiring in a kernel map */ @@ -337,7 +344,8 @@ long vmspace_wired_count(struct vmspace *vmspace); boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t); vm_map_t vm_map_create(pmap_t, vm_offset_t, vm_offset_t); int vm_map_delete (vm_map_t, vm_offset_t, vm_offset_t); -int vm_map_find (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, boolean_t, vm_prot_t, vm_prot_t, int); +int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, + int, vm_prot_t, vm_prot_t, int); int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int); int vm_map_findspace (vm_map_t, vm_offset_t, vm_size_t, vm_offset_t *); |