o Acquire and release Giant in vm_object_reference() and
vm_object_deallocate(), replacing the assertion GIANT_REQUIRED. o Remove GIANT_REQUIRED from vm_map_protect() and vm_map_simplify_entry(). o Acquire and release Giant around vm_map_protect()'s call to pmap_protect(). Altogether, these changes eliminate the need for mprotect() to acquire and release Giant.
This commit is contained in:
parent
34259ca951
commit
e7bbea38d9
@ -938,8 +938,6 @@ vm_map_simplify_entry(vm_map_t map, vm_map_entry_t entry)
|
||||
vm_map_entry_t next, prev;
|
||||
vm_size_t prevsize, esize;
|
||||
|
||||
GIANT_REQUIRED;
|
||||
|
||||
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
|
||||
return;
|
||||
|
||||
@ -1187,7 +1185,6 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
|
||||
vm_map_entry_t current;
|
||||
vm_map_entry_t entry;
|
||||
|
||||
GIANT_REQUIRED;
|
||||
vm_map_lock(map);
|
||||
|
||||
VM_MAP_RANGE_CHECK(map, start, end);
|
||||
@ -1237,12 +1234,14 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
|
||||
* here -- CHECK THIS XXX
|
||||
*/
|
||||
if (current->protection != old_prot) {
|
||||
mtx_lock(&Giant);
|
||||
#define MASK(entry) (((entry)->eflags & MAP_ENTRY_COW) ? ~VM_PROT_WRITE : \
|
||||
VM_PROT_ALL)
|
||||
pmap_protect(map->pmap, current->start,
|
||||
current->end,
|
||||
current->protection & MASK(current));
|
||||
#undef MASK
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
vm_map_simplify_entry(map, current);
|
||||
current = current->next;
|
||||
|
@ -360,11 +360,10 @@ vm_object_allocate(objtype_t type, vm_size_t size)
|
||||
void
|
||||
vm_object_reference(vm_object_t object)
|
||||
{
|
||||
GIANT_REQUIRED;
|
||||
|
||||
if (object == NULL)
|
||||
return;
|
||||
|
||||
mtx_lock(&Giant);
|
||||
#if 0
|
||||
/* object can be re-referenced during final cleaning */
|
||||
KASSERT(!(object->flags & OBJ_DEAD),
|
||||
@ -377,6 +376,7 @@ vm_object_reference(vm_object_t object)
|
||||
printf("vm_object_reference: delay in getting object\n");
|
||||
}
|
||||
}
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -427,12 +427,12 @@ vm_object_deallocate(vm_object_t object)
|
||||
{
|
||||
vm_object_t temp;
|
||||
|
||||
GIANT_REQUIRED;
|
||||
|
||||
mtx_lock(&Giant);
|
||||
while (object != NULL) {
|
||||
|
||||
if (object->type == OBJT_VNODE) {
|
||||
vm_object_vndeallocate(object);
|
||||
mtx_unlock(&Giant);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -447,6 +447,7 @@ vm_object_deallocate(vm_object_t object)
|
||||
*/
|
||||
object->ref_count--;
|
||||
if (object->ref_count > 1) {
|
||||
mtx_unlock(&Giant);
|
||||
return;
|
||||
} else if (object->ref_count == 1) {
|
||||
if (object->shadow_count == 0) {
|
||||
@ -487,13 +488,10 @@ vm_object_deallocate(vm_object_t object)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
mtx_unlock(&Giant);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
doterm:
|
||||
|
||||
temp = object->backing_object;
|
||||
if (temp) {
|
||||
TAILQ_REMOVE(&temp->shadow_head, object, shadow_list);
|
||||
@ -514,6 +512,7 @@ vm_object_deallocate(vm_object_t object)
|
||||
vm_object_terminate(object);
|
||||
object = temp;
|
||||
}
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user