Various changes to vm_object_shadow(): (1) update the vm_object locking,
(2) remove a pointless assertion, and (3) make a trivial change to a comment.
This commit is contained in:
parent
32660658b8
commit
570a2f4ac5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114112
@ -1078,26 +1078,29 @@ vm_object_shadow(
|
|||||||
vm_object_t source;
|
vm_object_t source;
|
||||||
vm_object_t result;
|
vm_object_t result;
|
||||||
|
|
||||||
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
source = *object;
|
source = *object;
|
||||||
|
|
||||||
vm_object_lock(source);
|
|
||||||
/*
|
/*
|
||||||
* Don't create the new object if the old object isn't shared.
|
* Don't create the new object if the old object isn't shared.
|
||||||
*/
|
*/
|
||||||
if (source != NULL &&
|
if (source != NULL) {
|
||||||
source->ref_count == 1 &&
|
VM_OBJECT_LOCK(source);
|
||||||
source->handle == NULL &&
|
if (source->ref_count == 1 &&
|
||||||
(source->type == OBJT_DEFAULT ||
|
source->handle == NULL &&
|
||||||
source->type == OBJT_SWAP)) {
|
(source->type == OBJT_DEFAULT ||
|
||||||
vm_object_unlock(source);
|
source->type == OBJT_SWAP)) {
|
||||||
return;
|
VM_OBJECT_UNLOCK(source);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
VM_OBJECT_UNLOCK(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a new object with the given length
|
* Allocate a new object with the given length.
|
||||||
*/
|
*/
|
||||||
result = vm_object_allocate(OBJT_DEFAULT, length);
|
result = vm_object_allocate(OBJT_DEFAULT, length);
|
||||||
KASSERT(result != NULL, ("vm_object_shadow: no object for shadowing"));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The new object shadows the source object, adding a reference to it.
|
* The new object shadows the source object, adding a reference to it.
|
||||||
@ -1110,7 +1113,8 @@ vm_object_shadow(
|
|||||||
* shadowed object.
|
* shadowed object.
|
||||||
*/
|
*/
|
||||||
result->backing_object = source;
|
result->backing_object = source;
|
||||||
if (source) {
|
if (source != NULL) {
|
||||||
|
VM_OBJECT_LOCK(source);
|
||||||
TAILQ_INSERT_TAIL(&source->shadow_head, result, shadow_list);
|
TAILQ_INSERT_TAIL(&source->shadow_head, result, shadow_list);
|
||||||
source->shadow_count++;
|
source->shadow_count++;
|
||||||
source->generation++;
|
source->generation++;
|
||||||
@ -1121,6 +1125,7 @@ vm_object_shadow(
|
|||||||
length = PQ_L2_SIZE / 3 + PQ_PRIME1;
|
length = PQ_L2_SIZE / 3 + PQ_PRIME1;
|
||||||
result->pg_color = (source->pg_color +
|
result->pg_color = (source->pg_color +
|
||||||
length * source->generation) & PQ_L2_MASK;
|
length * source->generation) & PQ_L2_MASK;
|
||||||
|
VM_OBJECT_UNLOCK(source);
|
||||||
next_index = (result->pg_color + PQ_L2_SIZE / 3 + PQ_PRIME1) &
|
next_index = (result->pg_color + PQ_L2_SIZE / 3 + PQ_PRIME1) &
|
||||||
PQ_L2_MASK;
|
PQ_L2_MASK;
|
||||||
}
|
}
|
||||||
@ -1136,8 +1141,6 @@ vm_object_shadow(
|
|||||||
*/
|
*/
|
||||||
*offset = 0;
|
*offset = 0;
|
||||||
*object = result;
|
*object = result;
|
||||||
|
|
||||||
vm_object_unlock(source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user