Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Nov 2017 16:39:24 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326097 - head/sys/vm
Message-ID:  <201711221639.vAMGdOrq070413@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711221639.vAMGdOrq070413>