kernel: reorganize new holds in vm_fault_copy_entry
authorChris Turner <c.turner@199technologies.com>
Fri, 9 Mar 2012 20:57:42 +0000 (20:57 +0000)
committerChris Turner <c.turner@199technologies.com>
Fri, 9 Mar 2012 20:57:42 +0000 (20:57 +0000)
Move holds outside of the pagecopy loop to reduce locking overhead.

Suggested-by: dillon
sys/vm/vm_fault.c

index 91f80c7..b56ab7f 100644 (file)
@@ -1932,6 +1932,8 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map,
         * one from the source object (it should be there) to the destination
         * object.
         */
+       vm_object_hold(src_object);
+       vm_object_hold(dst_object);
        for (vaddr = dst_entry->start, dst_offset = 0;
            vaddr < dst_entry->end;
            vaddr += PAGE_SIZE, dst_offset += PAGE_SIZE) {
@@ -1940,11 +1942,9 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map,
                 * Allocate a page in the destination object
                 */
                do {
-                       vm_object_hold(dst_object);
                        dst_m = vm_page_alloc(dst_object,
                                              OFF_TO_IDX(dst_offset),
                                              VM_ALLOC_NORMAL);
-                       vm_object_drop(dst_object);
                        if (dst_m == NULL) {
                                vm_wait(0);
                        }
@@ -1955,10 +1955,8 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map,
                 * (Because the source is wired down, the page will be in
                 * memory.)
                 */
-               vm_object_hold(src_object);
                src_m = vm_page_lookup(src_object,
                                       OFF_TO_IDX(dst_offset + src_offset));
-               vm_object_drop(src_object);
 
                if (src_m == NULL)
                        panic("vm_fault_copy_wired: page missing");
@@ -1979,6 +1977,8 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map,
                vm_page_activate(dst_m);
                vm_page_wakeup(dst_m);
        }
+       vm_object_drop(dst_object);
+       vm_object_drop(src_object);
 }
 
 #if 0