svn commit: r243529 - head/sys/vm

Alan Cox alc at FreeBSD.org
Sun Nov 25 19:42:37 UTC 2012


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;


More information about the svn-src-head mailing list