mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-17 15:27:36 +00:00
o Introduce and use vm_map_trylock() to replace several direct uses
of lockmgr(). o Add missing synchronization to vmspace_swap_count(): Obtain a read lock on the vm_map before traversing it.
This commit is contained in:
parent
67a2a28fe4
commit
d974f03c69
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95610
@ -663,9 +663,7 @@ RetryFault:;
|
||||
/*
|
||||
* grab the lock if we need to
|
||||
*/
|
||||
(fs.lookup_still_valid ||
|
||||
lockmgr(&fs.map->lock, LK_EXCLUSIVE|LK_NOWAIT, (void *)0, curthread) == 0)
|
||||
) {
|
||||
(fs.lookup_still_valid || vm_map_trylock(fs.map))) {
|
||||
|
||||
fs.lookup_still_valid = 1;
|
||||
/*
|
||||
|
@ -560,9 +560,7 @@ int action;
|
||||
* data structures there is a
|
||||
* possible deadlock.
|
||||
*/
|
||||
if (lockmgr(&vm->vm_map.lock,
|
||||
LK_EXCLUSIVE | LK_NOWAIT,
|
||||
NULL, curthread)) {
|
||||
if (!vm_map_trylock(&vm->vm_map)) {
|
||||
vmspace_free(vm);
|
||||
PROC_UNLOCK(p);
|
||||
goto nextproc;
|
||||
|
@ -336,6 +336,7 @@ vmspace_swap_count(struct vmspace *vmspace)
|
||||
vm_map_entry_t cur;
|
||||
int count = 0;
|
||||
|
||||
vm_map_lock_read(map);
|
||||
for (cur = map->header.next; cur != &map->header; cur = cur->next) {
|
||||
vm_object_t object;
|
||||
|
||||
@ -351,6 +352,7 @@ vmspace_swap_count(struct vmspace *vmspace)
|
||||
}
|
||||
}
|
||||
}
|
||||
vm_map_unlock_read(map);
|
||||
return (count);
|
||||
}
|
||||
|
||||
@ -397,6 +399,14 @@ vm_map_unlock_read(vm_map_t map)
|
||||
lockmgr(&(map)->lock, LK_RELEASE, NULL, curthread);
|
||||
}
|
||||
|
||||
int
|
||||
vm_map_trylock(vm_map_t map)
|
||||
{
|
||||
|
||||
return (lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, NULL,
|
||||
curthread) == 0);
|
||||
}
|
||||
|
||||
static __inline__ int
|
||||
_vm_map_lock_upgrade(vm_map_t map, struct thread *td) {
|
||||
int error;
|
||||
|
@ -241,6 +241,7 @@ void vm_map_lock(vm_map_t map);
|
||||
void vm_map_unlock(vm_map_t map);
|
||||
void vm_map_lock_read(vm_map_t map);
|
||||
void vm_map_unlock_read(vm_map_t map);
|
||||
int vm_map_trylock(vm_map_t map);
|
||||
int vm_map_lock_upgrade(vm_map_t map);
|
||||
void vm_map_lock_downgrade(vm_map_t map);
|
||||
void vm_map_set_recursive(vm_map_t map);
|
||||
|
@ -547,9 +547,8 @@ vm_pageout_map_deactivate_pages(map, desired)
|
||||
int nothingwired;
|
||||
|
||||
GIANT_REQUIRED;
|
||||
if (lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, (void *)0, curthread)) {
|
||||
if (!vm_map_trylock(map))
|
||||
return;
|
||||
}
|
||||
|
||||
bigobj = NULL;
|
||||
nothingwired = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user