Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Apr 2009 02:59:06 +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: r191478 - head/sys/vm
Message-ID:  <200904250259.n3P2x60g039582@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Sat Apr 25 02:59:06 2009
New Revision: 191478
URL: http://svn.freebsd.org/changeset/base/191478

Log:
  Eliminate unnecessary calls to pmap_clear_modify().  Specifically, calling
  pmap_clear_modify() on a page is pointless if that page is not mapped or
  it is only mapped for read access.  Instead, assert that the page is not
  mapped or not mapped for write access as appropriate.
  
  Eliminate unnecessary clearing of a page's dirty mask.  Instead, assert
  that the page's dirty mask is clear.

Modified:
  head/sys/vm/swap_pager.c
  head/sys/vm/vnode_pager.c

Modified: head/sys/vm/swap_pager.c
==============================================================================
--- head/sys/vm/swap_pager.c	Sat Apr 25 00:04:36 2009	(r191477)
+++ head/sys/vm/swap_pager.c	Sat Apr 25 02:59:06 2009	(r191478)
@@ -1407,10 +1407,6 @@ swp_pager_async_iodone(struct buf *bp)
 			}
 		} else if (bp->b_iocmd == BIO_READ) {
 			/*
-			 * For read success, clear dirty bits.  Nobody should
-			 * have this page mapped but don't take any chances,
-			 * make sure the pmap modify bits are also cleared.
-			 *
 			 * NOTE: for reads, m->dirty will probably be 
 			 * overridden by the original caller of getpages so
 			 * we cannot set them in order to free the underlying
@@ -1427,9 +1423,11 @@ swp_pager_async_iodone(struct buf *bp)
 			 * vm_page_wakeup().  We do not set reqpage's
 			 * valid bits here, it is up to the caller.
 			 */
-			pmap_clear_modify(m);
+			KASSERT(!pmap_page_is_mapped(m),
+			    ("swp_pager_async_iodone: page %p is mapped", m));
 			m->valid = VM_PAGE_BITS_ALL;
-			vm_page_undirty(m);
+			KASSERT(m->dirty == 0,
+			    ("swp_pager_async_iodone: page %p is dirty", m));
 
 			/*
 			 * We have to wake specifically requested pages
@@ -1447,11 +1445,13 @@ swp_pager_async_iodone(struct buf *bp)
 			}
 		} else {
 			/*
-			 * For write success, clear the modify and dirty 
+			 * For write success, clear the dirty
 			 * status, then finish the I/O ( which decrements the 
 			 * busy count and possibly wakes waiter's up ).
 			 */
-			pmap_clear_modify(m);
+			KASSERT((m->flags & PG_WRITEABLE) == 0,
+			    ("swp_pager_async_iodone: page %p is not write"
+			    " protected", m));
 			vm_page_undirty(m);
 			vm_page_io_finish(m);
 			if (vm_page_count_severe())

Modified: head/sys/vm/vnode_pager.c
==============================================================================
--- head/sys/vm/vnode_pager.c	Sat Apr 25 00:04:36 2009	(r191477)
+++ head/sys/vm/vnode_pager.c	Sat Apr 25 02:59:06 2009	(r191478)
@@ -944,8 +944,12 @@ vnode_pager_generic_getpages(vp, m, byte
 			 * Read filled up entire page.
 			 */
 			mt->valid = VM_PAGE_BITS_ALL;
-			vm_page_undirty(mt);	/* should be an assert? XXX */
-			pmap_clear_modify(mt);
+			KASSERT(mt->dirty == 0,
+			    ("vnode_pager_generic_getpages: page %p is dirty",
+			    mt));
+			KASSERT(!pmap_page_is_mapped(mt),
+			    ("vnode_pager_generic_getpages: page %p is mapped",
+			    mt));
 		} else {
 			/*
 			 * Read did not fill up entire page.  Since this



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