Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Dec 2008 19:48:03 +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: r186609 - head/sys/vm
Message-ID:  <200812301948.mBUJm3Jd003317@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Tue Dec 30 19:48:03 2008
New Revision: 186609
URL: http://svn.freebsd.org/changeset/base/186609

Log:
  Move the implementation of the vm map's fast path on address lookup from
  vm_map_lookup{,_locked}() to vm_map_lookup_entry().  Having the fast path
  in vm_map_lookup{,_locked}() limits its benefits to page faults.  Moving
  it to vm_map_lookup_entry() extends its benefits to other operations on
  the vm map.

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==============================================================================
--- head/sys/vm/vm_map.c	Tue Dec 30 19:46:06 2008	(r186608)
+++ head/sys/vm/vm_map.c	Tue Dec 30 19:48:03 2008	(r186609)
@@ -901,12 +901,24 @@ vm_map_lookup_entry(
 {
 	vm_map_entry_t cur;
 
-	cur = vm_map_entry_splay(address, map->root);
+	/*
+	 * If the map is empty, then the map entry immediately preceding
+	 * "address" is the map's header.
+	 */
+	cur = map->root;
 	if (cur == NULL)
 		*entry = &map->header;
-	else {
-		map->root = cur;
+	else if (address >= cur->start && cur->end > address) {
+		*entry = cur;
+		return (TRUE);
+	} else {
+		map->root = cur = vm_map_entry_splay(address, cur);
 
+		/*
+		 * If "address" is contained within a map entry, the new root
+		 * is that map entry.  Otherwise, the new root is a map entry
+		 * immediately before or after "address".
+		 */
 		if (address >= cur->start) {
 			*entry = cur;
 			if (cur->end > address)
@@ -3108,9 +3120,6 @@ vm_map_lookup(vm_map_t *var_map,		/* IN/
 	vm_prot_t fault_type = fault_typea;
 
 RetryLookup:;
-	/*
-	 * Lookup the faulting address.
-	 */
 
 	vm_map_lock_read(map);
 #define	RETURN(why) \
@@ -3120,22 +3129,12 @@ RetryLookup:;
 		}
 
 	/*
-	 * If the map has an interesting hint, try it before calling full
-	 * blown lookup routine.
+	 * Lookup the faulting address.
 	 */
-	entry = map->root;
-	*out_entry = entry;
-	if (entry == NULL ||
-	    (vaddr < entry->start) || (vaddr >= entry->end)) {
-		/*
-		 * Entry was either not a valid hint, or the vaddr was not
-		 * contained in the entry, so do a full lookup.
-		 */
-		if (!vm_map_lookup_entry(map, vaddr, out_entry))
-			RETURN(KERN_INVALID_ADDRESS);
+	if (!vm_map_lookup_entry(map, vaddr, out_entry))
+		RETURN(KERN_INVALID_ADDRESS);
 
-		entry = *out_entry;
-	}
+	entry = *out_entry;
 
 	/*
 	 * Handle submaps.
@@ -3262,22 +3261,12 @@ vm_map_lookup_locked(vm_map_t *var_map,	
 	vm_prot_t fault_type = fault_typea;
 
 	/*
-	 * If the map has an interesting hint, try it before calling full
-	 * blown lookup routine.
+	 * Lookup the faulting address.
 	 */
-	entry = map->root;
-	*out_entry = entry;
-	if (entry == NULL ||
-	    (vaddr < entry->start) || (vaddr >= entry->end)) {
-		/*
-		 * Entry was either not a valid hint, or the vaddr was not
-		 * contained in the entry, so do a full lookup.
-		 */
-		if (!vm_map_lookup_entry(map, vaddr, out_entry))
-			return (KERN_INVALID_ADDRESS);
+	if (!vm_map_lookup_entry(map, vaddr, out_entry))
+		return (KERN_INVALID_ADDRESS);
 
-		entry = *out_entry;
-	}
+	entry = *out_entry;
 
 	/*
 	 * Fail if the entry refers to a submap.



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