From owner-svn-src-head@FreeBSD.ORG Tue Dec 30 19:48:03 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79D2C1065673; Tue, 30 Dec 2008 19:48:03 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 660828FC16; Tue, 30 Dec 2008 19:48:03 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBUJm33K003318; Tue, 30 Dec 2008 19:48:03 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBUJm3Jd003317; Tue, 30 Dec 2008 19:48:03 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200812301948.mBUJm3Jd003317@svn.freebsd.org> From: Alan Cox Date: Tue, 30 Dec 2008 19:48:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186609 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Dec 2008 19:48:03 -0000 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.