Lock the new map in vmspace_fork(). The newly allocated map should not
be accessible outside vmspace_fork() yet, but locking it would satisfy the protocol of the vm_map_entry_link() and other functions called from vmspace_fork(). Use trylock that is supposedly cannot fail, to silence WITNESS warning of the nested acquisition of the sx lock with the same name. Suggested and reviewed by: tegge
This commit is contained in:
parent
0125db5772
commit
2d39ccdd94
@ -2679,6 +2679,7 @@ vmspace_fork(struct vmspace *vm1)
|
||||
vm_map_entry_t old_entry;
|
||||
vm_map_entry_t new_entry;
|
||||
vm_object_t object;
|
||||
int locked;
|
||||
|
||||
vm_map_lock(old_map);
|
||||
|
||||
@ -2689,6 +2690,8 @@ vmspace_fork(struct vmspace *vm1)
|
||||
vm2->vm_daddr = vm1->vm_daddr;
|
||||
vm2->vm_maxsaddr = vm1->vm_maxsaddr;
|
||||
new_map = &vm2->vm_map; /* XXX */
|
||||
locked = vm_map_trylock(new_map); /* trylock to silence WITNESS */
|
||||
KASSERT(locked, ("vmspace_fork: lock failed"));
|
||||
new_map->timestamp = 1;
|
||||
|
||||
old_entry = old_map->header.next;
|
||||
@ -2780,6 +2783,8 @@ vmspace_fork(struct vmspace *vm1)
|
||||
}
|
||||
unlock_and_return:
|
||||
vm_map_unlock(old_map);
|
||||
if (vm2 != NULL)
|
||||
vm_map_unlock(new_map);
|
||||
|
||||
return (vm2);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user