Author: alc
Date: Wed Nov 22 16:39:24 2017
New Revision: 326097
URL: https://svnweb.freebsd.org/changeset/base/326097

Log:
  When vm_map_find(find_space = VMFS_OPTIMAL_SPACE) fails to find space, a
  second scan of the address space with find_space = VMFS_ANY_SPACE is
  performed.  Previously, vm_map_find() released and reacquired the map lock
  between the first and second scans.  However, there is no compelling
  reason to do so.  This revision modifies vm_map_find() to retain the map
  lock.
  
  Reviewed by:  jhb, kib, markj
  MFC after:    1 week
  X-Differential Revision:      https://reviews.freebsd.org/D13155

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c        Wed Nov 22 15:54:52 2017        (r326096)
+++ head/sys/vm/vm_map.c        Wed Nov 22 16:39:24 2017        (r326097)
@@ -1513,18 +1513,18 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffs
        } else
                alignment = 0;
        initial_addr = *addr;
+       vm_map_lock(map);
 again:
        start = initial_addr;
-       vm_map_lock(map);
        do {
                if (find_space != VMFS_NO_SPACE) {
                        if (vm_map_findspace(map, start, length, addr) ||
                            (max_addr != 0 && *addr + length > max_addr)) {
-                               vm_map_unlock(map);
                                if (find_space == VMFS_OPTIMAL_SPACE) {
                                        find_space = VMFS_ANY_SPACE;
                                        goto again;
                                }
+                               vm_map_unlock(map);
                                return (KERN_NO_SPACE);
                        }
                        switch (find_space) {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to