From efc8daaecb9bd5870c7e5ca9d072a0ed78f31476 Mon Sep 17 00:00:00 2001 From: alc Date: Thu, 22 Mar 2007 07:02:43 +0000 Subject: [PATCH] Change the order of lock reacquisition in vm_object_split() in order to simplify the code slightly. Add a comment concerning lock ordering. --- sys/vm/vm_object.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index c5427ca0cb84..e680a22bbfd1 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1308,6 +1308,10 @@ vm_object_split(vm_map_entry_t entry) */ new_object = vm_object_allocate(OBJT_DEFAULT, size); + /* + * At this point, the new object is still private, so the order in + * which the original and new objects are locked does not matter. + */ VM_OBJECT_LOCK(new_object); VM_OBJECT_LOCK(orig_object); source = orig_object->backing_object; @@ -1350,9 +1354,8 @@ retry: vm_page_unlock_queues(); VM_OBJECT_UNLOCK(new_object); m->oflags |= VPO_WANTED; - msleep(m, VM_OBJECT_MTX(orig_object), PDROP | PVM, "spltwt", 0); + msleep(m, VM_OBJECT_MTX(orig_object), PVM, "spltwt", 0); VM_OBJECT_LOCK(new_object); - VM_OBJECT_LOCK(orig_object); goto retry; } vm_page_rename(m, new_object, idx);