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_map_entry_t next, prev;
|
||||||
vm_size_t prevsize, esize;
|
vm_size_t prevsize, esize;
|
||||||
|
|
||||||
GIANT_REQUIRED;
|
|
||||||
|
|
||||||
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
|
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
|
||||||
return;
|
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 current;
|
||||||
vm_map_entry_t entry;
|
vm_map_entry_t entry;
|
||||||
|
|
||||||
GIANT_REQUIRED;
|
|
||||||
vm_map_lock(map);
|
vm_map_lock(map);
|
||||||
|
|
||||||
VM_MAP_RANGE_CHECK(map, start, end);
|
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
|
* here -- CHECK THIS XXX
|
||||||
*/
|
*/
|
||||||
if (current->protection != old_prot) {
|
if (current->protection != old_prot) {
|
||||||
|
mtx_lock(&Giant);
|
||||||
#define MASK(entry) (((entry)->eflags & MAP_ENTRY_COW) ? ~VM_PROT_WRITE : \
|
#define MASK(entry) (((entry)->eflags & MAP_ENTRY_COW) ? ~VM_PROT_WRITE : \
|
||||||
VM_PROT_ALL)
|
VM_PROT_ALL)
|
||||||
pmap_protect(map->pmap, current->start,
|
pmap_protect(map->pmap, current->start,
|
||||||
current->end,
|
current->end,
|
||||||
current->protection & MASK(current));
|
current->protection & MASK(current));
|
||||||
#undef MASK
|
#undef MASK
|
||||||
|
mtx_unlock(&Giant);
|
||||||
}
|
}
|
||||||
vm_map_simplify_entry(map, current);
|
vm_map_simplify_entry(map, current);
|
||||||
current = current->next;
|
current = current->next;
|
||||||
|
@ -360,11 +360,10 @@ vm_object_allocate(objtype_t type, vm_size_t size)
|
|||||||
void
|
void
|
||||||
vm_object_reference(vm_object_t object)
|
vm_object_reference(vm_object_t object)
|
||||||
{
|
{
|
||||||
GIANT_REQUIRED;
|
|
||||||
|
|
||||||
if (object == NULL)
|
if (object == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
#if 0
|
#if 0
|
||||||
/* object can be re-referenced during final cleaning */
|
/* object can be re-referenced during final cleaning */
|
||||||
KASSERT(!(object->flags & OBJ_DEAD),
|
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");
|
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;
|
vm_object_t temp;
|
||||||
|
|
||||||
GIANT_REQUIRED;
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
while (object != NULL) {
|
while (object != NULL) {
|
||||||
|
|
||||||
if (object->type == OBJT_VNODE) {
|
if (object->type == OBJT_VNODE) {
|
||||||
vm_object_vndeallocate(object);
|
vm_object_vndeallocate(object);
|
||||||
|
mtx_unlock(&Giant);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,6 +447,7 @@ vm_object_deallocate(vm_object_t object)
|
|||||||
*/
|
*/
|
||||||
object->ref_count--;
|
object->ref_count--;
|
||||||
if (object->ref_count > 1) {
|
if (object->ref_count > 1) {
|
||||||
|
mtx_unlock(&Giant);
|
||||||
return;
|
return;
|
||||||
} else if (object->ref_count == 1) {
|
} else if (object->ref_count == 1) {
|
||||||
if (object->shadow_count == 0) {
|
if (object->shadow_count == 0) {
|
||||||
@ -487,13 +488,10 @@ vm_object_deallocate(vm_object_t object)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mtx_unlock(&Giant);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doterm:
|
doterm:
|
||||||
|
|
||||||
temp = object->backing_object;
|
temp = object->backing_object;
|
||||||
if (temp) {
|
if (temp) {
|
||||||
TAILQ_REMOVE(&temp->shadow_head, object, shadow_list);
|
TAILQ_REMOVE(&temp->shadow_head, object, shadow_list);
|
||||||
@ -514,6 +512,7 @@ vm_object_deallocate(vm_object_t object)
|
|||||||
vm_object_terminate(object);
|
vm_object_terminate(object);
|
||||||
object = temp;
|
object = temp;
|
||||||
}
|
}
|
||||||
|
mtx_unlock(&Giant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user