summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2008-12-30 19:48:03 +0000
committeralc <alc@FreeBSD.org>2008-12-30 19:48:03 +0000
commit96037be8997a092e53b1d86870f5c2ba02451ecc (patch)
treef74204b76a79a052cd8306de74d6454ed18ec9e7 /sys
parent72636ca358eed7b0186dedaece2047b8be75d6fe (diff)
downloadFreeBSD-src-96037be8997a092e53b1d86870f5c2ba02451ecc.zip
FreeBSD-src-96037be8997a092e53b1d86870f5c2ba02451ecc.tar.gz
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.
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_map.c57
1 files changed, 23 insertions, 34 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index a1f0ef3..f9bc9be 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -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/OUT */
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, /* IN/OUT */
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.
OpenPOWER on IntegriCloud