Delay the call to crhold() in vm_map_insert() until we know that we won't
have to undo it by calling crfree(). This reduces the total number of calls by vm_map_insert() to crhold() and crfree() by 45% in my tests. Eliminate an unnecessary variable from vm_map_insert(). Reviewed by: kib Tested by: pho
This commit is contained in:
parent
3f3d544005
commit
50c074c333
@ -1127,7 +1127,6 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
|
||||
vm_eflags_t protoeflags;
|
||||
struct ucred *cred;
|
||||
vm_inherit_t inheritance;
|
||||
boolean_t charge_prev_obj;
|
||||
|
||||
VM_MAP_ASSERT_LOCKED(map);
|
||||
KASSERT((object != kmem_object && object != kernel_object) ||
|
||||
@ -1180,7 +1179,6 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
|
||||
inheritance = VM_INHERIT_DEFAULT;
|
||||
|
||||
cred = NULL;
|
||||
charge_prev_obj = FALSE;
|
||||
if (cow & (MAP_ACC_NO_CHARGE | MAP_NOFAULT))
|
||||
goto charged;
|
||||
if ((cow & MAP_ACC_CHARGED) || ((prot & VM_PROT_WRITE) &&
|
||||
@ -1191,9 +1189,6 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
|
||||
object->cred == NULL,
|
||||
("OVERCOMMIT: vm_map_insert o %p", object));
|
||||
cred = curthread->td_ucred;
|
||||
crhold(cred);
|
||||
if (object == NULL && !(protoeflags & MAP_ENTRY_NEEDS_COPY))
|
||||
charge_prev_obj = TRUE;
|
||||
}
|
||||
|
||||
charged:
|
||||
@ -1224,7 +1219,8 @@ charged:
|
||||
vm_object_coalesce(prev_entry->object.vm_object,
|
||||
prev_entry->offset,
|
||||
(vm_size_t)(prev_entry->end - prev_entry->start),
|
||||
(vm_size_t)(end - prev_entry->end), charge_prev_obj)) {
|
||||
(vm_size_t)(end - prev_entry->end), cred != NULL &&
|
||||
(protoeflags & MAP_ENTRY_NEEDS_COPY) == 0)) {
|
||||
/*
|
||||
* We were able to extend the object. Determine if we
|
||||
* can extend the previous map entry to include the
|
||||
@ -1237,8 +1233,6 @@ charged:
|
||||
prev_entry->end = end;
|
||||
vm_map_entry_resize_free(map, prev_entry);
|
||||
vm_map_simplify_entry(map, prev_entry);
|
||||
if (cred != NULL)
|
||||
crfree(cred);
|
||||
return (KERN_SUCCESS);
|
||||
}
|
||||
|
||||
@ -1255,10 +1249,11 @@ charged:
|
||||
if (cred != NULL && object != NULL && object->cred != NULL &&
|
||||
!(prev_entry->eflags & MAP_ENTRY_NEEDS_COPY)) {
|
||||
/* Object already accounts for this uid. */
|
||||
crfree(cred);
|
||||
cred = NULL;
|
||||
}
|
||||
}
|
||||
if (cred != NULL)
|
||||
crhold(cred);
|
||||
|
||||
/*
|
||||
* Create a new entry
|
||||
|
Loading…
x
Reference in New Issue
Block a user