diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 85c53922913b..c51a9cac66cd 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -711,8 +711,6 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, vm_map_entry_t temp_entry; vm_eflags_t protoeflags; - GIANT_REQUIRED; - /* * Check that the start and end points are not bogus. */ @@ -753,6 +751,7 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, protoeflags |= MAP_ENTRY_NOCOREDUMP; if (object) { + GIANT_REQUIRED; /* * When object is non-NULL, it could be shared with another * process. We have to set or clear OBJ_ONEMAPPING @@ -847,6 +846,7 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, #endif if (cow & (MAP_PREFAULT|MAP_PREFAULT_PARTIAL)) { + GIANT_REQUIRED; pmap_object_init_pt(map->pmap, start, object, OFF_TO_IDX(offset), end - start, cow & MAP_PREFAULT_PARTIAL); diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index d04694153fba..b07d6b8a40b8 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1813,18 +1813,17 @@ again: * The object must *not* be locked. */ boolean_t -vm_object_coalesce(vm_object_t prev_object, vm_pindex_t prev_pindex, vm_size_t prev_size, vm_size_t next_size) +vm_object_coalesce(vm_object_t prev_object, vm_pindex_t prev_pindex, + vm_size_t prev_size, vm_size_t next_size) { vm_pindex_t next_pindex; - GIANT_REQUIRED; - - if (prev_object == NULL) { + if (prev_object == NULL) return (TRUE); - } - + mtx_lock(&Giant); if (prev_object->type != OBJT_DEFAULT && prev_object->type != OBJT_SWAP) { + mtx_unlock(&Giant); return (FALSE); } @@ -1839,6 +1838,7 @@ vm_object_coalesce(vm_object_t prev_object, vm_pindex_t prev_pindex, vm_size_t p * pages not mapped to prev_entry may be in use anyway) */ if (prev_object->backing_object != NULL) { + mtx_unlock(&Giant); return (FALSE); } @@ -1848,6 +1848,7 @@ vm_object_coalesce(vm_object_t prev_object, vm_pindex_t prev_pindex, vm_size_t p if ((prev_object->ref_count > 1) && (prev_object->size != next_pindex)) { + mtx_unlock(&Giant); return (FALSE); } @@ -1870,6 +1871,7 @@ vm_object_coalesce(vm_object_t prev_object, vm_pindex_t prev_pindex, vm_size_t p if (next_pindex + next_size > prev_object->size) prev_object->size = next_pindex + next_size; + mtx_unlock(&Giant); return (TRUE); }