From owner-svn-src-head@FreeBSD.ORG Sun Nov 25 19:42:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BBDC9152; Sun, 25 Nov 2012 19:42:36 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 818018FC08; Sun, 25 Nov 2012 19:42:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAPJgaiC016685; Sun, 25 Nov 2012 19:42:36 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAPJgaC7016684; Sun, 25 Nov 2012 19:42:36 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201211251942.qAPJgaC7016684@svn.freebsd.org> From: Alan Cox Date: Sun, 25 Nov 2012 19:42:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243529 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Sun, 25 Nov 2012 19:42:37 -0000 Author: alc Date: Sun Nov 25 19:42:36 2012 New Revision: 243529 URL: http://svnweb.freebsd.org/changeset/base/243529 Log: Make a few small changes to vm_map_pmap_enter(): Add detail to the comment describing this function. In particular, describe what MAP_PREFAULT_PARTIAL does. Eliminate the abrupt change in behavior when the specified address range grows from MAX_INIT_PT pages to MAX_INIT_PT plus one pages. Instead of doing nothing, i.e., preloading no mappings whatsoever, map any resident pages that fall within the start of the specified address range, i.e., [addr, addr + ulmin(size, ptoa(MAX_INIT_PT))). Long ago, the vm object's list of resident pages was not ordered, so this function had to choose between probing the global hash table of all resident pages and iterating over the vm object's unordered list of resident pages. Now, the list is ordered, so there is no reason for MAP_PREFAULT_PARTIAL to be concerned with the vm object's count of resident changes. MFC after: 14 days Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Sun Nov 25 19:31:42 2012 (r243528) +++ head/sys/vm/vm_map.c Sun Nov 25 19:42:36 2012 (r243529) @@ -1793,10 +1793,14 @@ vm_map_submap( /* * vm_map_pmap_enter: * - * Preload read-only mappings for the given object's resident pages into - * the given map. This eliminates the soft faults on process startup and - * immediately after an mmap(2). Because these are speculative mappings, - * cached pages are not reactivated and mapped. + * Preload read-only mappings for the specified object's resident pages + * into the target map. If "flags" is MAP_PREFAULT_PARTIAL, then only + * the resident pages within the address range [addr, addr + ulmin(size, + * ptoa(MAX_INIT_PT))) are mapped. Otherwise, all resident pages within + * the specified address range are mapped. This eliminates many soft + * faults on process startup and immediately after an mmap(2). Because + * these are speculative mappings, cached pages are not reactivated and + * mapped. */ void vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, @@ -1815,11 +1819,8 @@ vm_map_pmap_enter(vm_map_t map, vm_offse } psize = atop(size); - - if ((flags & MAP_PREFAULT_PARTIAL) && psize > MAX_INIT_PT && - object->resident_page_count > MAX_INIT_PT) - goto unlock_return; - + if (psize > MAX_INIT_PT && (flags & MAP_PREFAULT_PARTIAL) != 0) + psize = MAX_INIT_PT; if (psize + pindex > object->size) { if (object->size < pindex) goto unlock_return;