svn commit: r292067 - head/sys/vm

Conrad E. Meyer cem at FreeBSD.org
Thu Dec 10 22:57:28 UTC 2015


Author: cem
Date: Thu Dec 10 22:57:27 2015
New Revision: 292067
URL: https://svnweb.freebsd.org/changeset/base/292067

Log:
  vm_page_replace: remove redundant radix lookup
  
  Remove redundant lookup of the old page from vm_page_replace.  Verification
  that the old page exists is already done by vm_radix_replace.
  
  Submitted by:	Ryan Libby <rlibby at gmail.com>
  Reviewed by:	alc, kib
  Sponsored by:	EMC / Isilon Storage Division
  Follow-up to:	https://reviews.freebsd.org/D4326
  Differential Revision:	https://reviews.freebsd.org/D4471

Modified:
  head/sys/vm/vm_page.c

Modified: head/sys/vm/vm_page.c
==============================================================================
--- head/sys/vm/vm_page.c	Thu Dec 10 21:46:21 2015	(r292066)
+++ head/sys/vm/vm_page.c	Thu Dec 10 22:57:27 2015	(r292067)
@@ -1324,22 +1324,17 @@ vm_page_prev(vm_page_t m)
 vm_page_t
 vm_page_replace(vm_page_t mnew, vm_object_t object, vm_pindex_t pindex)
 {
-	vm_page_t mold, mpred;
+	vm_page_t mold;
 
 	VM_OBJECT_ASSERT_WLOCKED(object);
+	KASSERT(mnew->object == NULL,
+	    ("vm_page_replace: page already in object"));
 
 	/*
 	 * This function mostly follows vm_page_insert() and
 	 * vm_page_remove() without the radix, object count and vnode
 	 * dance.  Double check such functions for more comments.
 	 */
-	mpred = vm_radix_lookup(&object->rtree, pindex);
-	KASSERT(mpred != NULL,
-	    ("vm_page_replace: replacing page not present with pindex"));
-	mpred = TAILQ_PREV(mpred, respgs, listq);
-	if (mpred != NULL)
-		KASSERT(mpred->pindex < pindex,
-		    ("vm_page_insert_after: mpred doesn't precede pindex"));
 
 	mnew->object = object;
 	mnew->pindex = pindex;
@@ -1347,17 +1342,17 @@ vm_page_replace(vm_page_t mnew, vm_objec
 	KASSERT(mold->queue == PQ_NONE,
 	    ("vm_page_replace: mold is on a paging queue"));
 
-	/* Detach the old page from the resident tailq. */
+	/* Keep the resident page list in sorted order. */
+	TAILQ_INSERT_AFTER(&object->memq, mold, mnew, listq);
 	TAILQ_REMOVE(&object->memq, mold, listq);
 
 	mold->object = NULL;
 	vm_page_xunbusy(mold);
 
-	/* Insert the new page in the resident tailq. */
-	if (mpred != NULL)
-		TAILQ_INSERT_AFTER(&object->memq, mpred, mnew, listq);
-	else
-		TAILQ_INSERT_HEAD(&object->memq, mnew, listq);
+	/*
+	 * The object's resident_page_count does not change because we have
+	 * swapped one page for another, but OBJ_MIGHTBEDIRTY.
+	 */
 	if (pmap_page_is_write_mapped(mnew))
 		vm_object_set_writeable_dirty(object);
 	return (mold);


More information about the svn-src-head mailing list