From 1cd5fbd85411a005796bb22fb3eba786d5c6f3ad Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 19 Nov 2003 18:48:45 +0000 Subject: [PATCH] - Avoid a lock-order reversal between Giant and a system map mutex that occurs when kmem_malloc() fails to allocate a sufficient number of vm pages. Specifically, we avoid the lock-order reversal by not grabbing Giant around pmap_remove() if the map is the kmem_map. Approved by: re (jhb) Reported by: Eugene --- sys/vm/vm_map.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index ce192419e3c..671cbacb7e3 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2173,11 +2173,13 @@ vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end) vm_map_entry_unwire(map, entry); } - mtx_lock(&Giant); + if (map != kmem_map) + mtx_lock(&Giant); vm_page_lock_queues(); pmap_remove(map->pmap, entry->start, entry->end); vm_page_unlock_queues(); - mtx_unlock(&Giant); + if (map != kmem_map) + mtx_unlock(&Giant); /* * Delete the entry (which may delete the object) only after