diff options
author | alc <alc@FreeBSD.org> | 2003-11-05 05:48:22 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2003-11-05 05:48:22 +0000 |
commit | 883d4c8c44860cd74bbb5c878c1baf7406ac7380 (patch) | |
tree | 47f457556827e00d98713467185b3234244efaa2 /sys/vm | |
parent | 9f266b0941e7bf6d4bb1085e29c18812a7c34534 (diff) | |
download | FreeBSD-src-883d4c8c44860cd74bbb5c878c1baf7406ac7380.zip FreeBSD-src-883d4c8c44860cd74bbb5c878c1baf7406ac7380.tar.gz |
- Move the implementation of OBJ_ONEMAPPING from vm_map_delete() to
vm_map_entry_delete() so that all of the vm object manipulation is
performed in one place.
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 0712446..1586cb3 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2106,11 +2106,32 @@ vm_map_entry_unwire(vm_map_t map, vm_map_entry_t entry) static void vm_map_entry_delete(vm_map_t map, vm_map_entry_t entry) { + vm_object_t object; + vm_pindex_t offidxstart, offidxend, count; + vm_map_entry_unlink(map, entry); map->size -= entry->end - entry->start; - if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) { - vm_object_deallocate(entry->object.vm_object); + if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) == 0 && + (object = entry->object.vm_object) != NULL) { + count = OFF_TO_IDX(entry->end - entry->start); + offidxstart = OFF_TO_IDX(entry->offset); + offidxend = offidxstart + count; + VM_OBJECT_LOCK(object); + if (object->ref_count != 1 && + ((object->flags & (OBJ_NOSPLIT|OBJ_ONEMAPPING)) == OBJ_ONEMAPPING || + object == kernel_object || object == kmem_object) && + (object->type == OBJT_DEFAULT || object->type == OBJT_SWAP)) { + vm_object_collapse(object); + vm_object_page_remove(object, offidxstart, offidxend, FALSE); + if (object->type == OBJT_SWAP) + swap_pager_freespace(object, offidxstart, count); + if (offidxend >= object->size && + offidxstart < object->size) + object->size = offidxstart; + } + VM_OBJECT_UNLOCK(object); + vm_object_deallocate(object); } vm_map_entry_dispose(map, entry); @@ -2125,7 +2146,6 @@ vm_map_entry_delete(vm_map_t map, vm_map_entry_t entry) int vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end) { - vm_object_t object; vm_map_entry_t entry; vm_map_entry_t first_entry; @@ -2153,8 +2173,6 @@ vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end) */ while ((entry != &map->header) && (entry->start < end)) { vm_map_entry_t next; - vm_offset_t s, e; - vm_pindex_t offidxstart, offidxend, count; /* * Wait for wiring or unwiring of an entry to complete. @@ -2189,14 +2207,8 @@ vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end) } vm_map_clip_end(map, entry, end); - s = entry->start; - e = entry->end; next = entry->next; - offidxstart = OFF_TO_IDX(entry->offset); - count = OFF_TO_IDX(e - s); - object = entry->object.vm_object; - /* * Unwire before removing addresses from the pmap; otherwise, * unwiring will put the entries back in the pmap. @@ -2205,28 +2217,10 @@ vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end) vm_map_entry_unwire(map, entry); } - offidxend = offidxstart + count; - mtx_lock(&Giant); vm_page_lock_queues(); - pmap_remove(map->pmap, s, e); + pmap_remove(map->pmap, entry->start, entry->end); vm_page_unlock_queues(); - if (object != NULL) { - VM_OBJECT_LOCK(object); - if (object->ref_count != 1 && - ((object->flags & (OBJ_NOSPLIT|OBJ_ONEMAPPING)) == OBJ_ONEMAPPING || - object == kernel_object || object == kmem_object) && - (object->type == OBJT_DEFAULT || object->type == OBJT_SWAP)) { - vm_object_collapse(object); - vm_object_page_remove(object, offidxstart, offidxend, FALSE); - if (object->type == OBJT_SWAP) - swap_pager_freespace(object, offidxstart, count); - if (offidxend >= object->size && - offidxstart < object->size) - object->size = offidxstart; - } - VM_OBJECT_UNLOCK(object); - } mtx_unlock(&Giant); /* |