Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Mar 2017 19:52:47 +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: r315580 - head/sys/vm
Message-ID:  <201703191952.v2JJqlQl001385@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Sun Mar 19 19:52:47 2017
New Revision: 315580
URL: https://svnweb.freebsd.org/changeset/base/315580

Log:
  Two changes to vm_fault_populate():
  
  Simplify the logic for clipping the range returned by the pager to fit
  within the map entry.
  
  Use atop() rather than OFF_TO_IDX() on addresses.
  
  Reviewed by:	kib
  MFC after:	1 week

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==============================================================================
--- head/sys/vm/vm_fault.c	Sun Mar 19 19:11:40 2017	(r315579)
+++ head/sys/vm/vm_fault.c	Sun Mar 19 19:52:47 2017	(r315580)
@@ -352,8 +352,7 @@ vm_fault_populate(struct faultstate *fs,
 	MPASS(fs->lookup_still_valid);
 
 	pager_first = OFF_TO_IDX(fs->entry->offset);
-	pager_last = OFF_TO_IDX(fs->entry->offset + fs->entry->end -
-	    fs->entry->start) - 1;
+	pager_last = pager_first + atop(fs->entry->end - fs->entry->start) - 1;
 	unlock_map(fs);
 	unlock_vp(fs);
 
@@ -404,18 +403,20 @@ vm_fault_populate(struct faultstate *fs,
 	 * In case the pager expanded the range, clip it to fit into
 	 * the map entry.
 	 */
-	map_first = MAX(OFF_TO_IDX(fs->entry->offset), pager_first);
-	if (map_first > pager_first)
+	map_first = OFF_TO_IDX(fs->entry->offset);
+	if (map_first > pager_first) {
 		vm_fault_populate_cleanup(fs->first_object, pager_first,
 		    map_first - 1);
-	map_last = MIN(OFF_TO_IDX(fs->entry->end - fs->entry->start +
-	    fs->entry->offset) - 1, pager_last);
-	if (map_last < pager_last)
+		pager_first = map_first;
+	}
+	map_last = map_first + atop(fs->entry->end - fs->entry->start) - 1;
+	if (map_last < pager_last) {
 		vm_fault_populate_cleanup(fs->first_object, map_last + 1,
 		    pager_last);
-
-	for (pidx = map_first, m = vm_page_lookup(fs->first_object, pidx);
-	    pidx <= map_last; pidx++, m = vm_page_next(m)) {
+		pager_last = map_last;
+	}
+	for (pidx = pager_first, m = vm_page_lookup(fs->first_object, pidx);
+	    pidx <= pager_last; pidx++, m = vm_page_next(m)) {
 		vm_fault_populate_check_page(m);
 		vm_fault_dirty(fs->entry, m, prot, fault_type, fault_flags,
 		    true);



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