Increase the scope of the kmem_object locking in kmem_malloc().

This commit is contained in:
Alan Cox 2002-12-20 18:59:23 +00:00
parent cc7bab9032
commit 671e427ce9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108138

View File

@ -359,7 +359,7 @@ kmem_malloc(map, size, flags)
if (flags & M_ZERO)
pflags |= VM_ALLOC_ZERO;
vm_object_lock(kmem_object);
for (i = 0; i < size; i += PAGE_SIZE) {
retry:
m = vm_page_alloc(kmem_object, OFF_TO_IDX(offset + i), pflags);
@ -371,9 +371,11 @@ kmem_malloc(map, size, flags)
*/
if (m == NULL) {
if ((flags & M_NOWAIT) == 0) {
vm_object_unlock(kmem_object);
vm_map_unlock(map);
VM_WAIT;
vm_map_lock(map);
vm_object_lock(kmem_object);
goto retry;
}
/*
@ -384,14 +386,13 @@ kmem_malloc(map, size, flags)
*/
while (i != 0) {
i -= PAGE_SIZE;
vm_object_lock(kmem_object);
m = vm_page_lookup(kmem_object,
OFF_TO_IDX(offset + i));
vm_page_lock_queues();
vm_page_free(m);
vm_page_unlock_queues();
vm_object_unlock(kmem_object);
}
vm_object_unlock(kmem_object);
vm_map_delete(map, addr, addr + size);
vm_map_unlock(map);
goto bad;
@ -401,6 +402,7 @@ kmem_malloc(map, size, flags)
vm_page_flag_clear(m, PG_ZERO);
m->valid = VM_PAGE_BITS_ALL;
}
vm_object_unlock(kmem_object);
/*
* Mark map entry as non-pageable. Assert: vm_map_insert() will never