Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Jul 2015 18:29:07 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285878 - head/sys/vm
Message-ID:  <201507251829.t6PIT7sI071357@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Jul 25 18:29:06 2015
New Revision: 285878
URL: https://svnweb.freebsd.org/changeset/base/285878

Log:
  Revert r173708's modifications to vm_object_page_remove().
  
  Assume that a vnode is mapped shared and mlocked(), and then the vnode
  is truncated, or truncated and then again extended past the mapping
  point EOF.  Truncation removes the pages past the truncation point,
  and if pages are later created at this range, they are not properly
  mapped into the mlocked region, and their wiring count is wrong.
  
  The revert leaves the invalidated but wired pages on the object queue,
  which means that the pages are found by vm_object_unwire() when the
  mapped range is munlock()ed, and reused by the buffer cache when the
  vnode is extended again.
  
  The changes in r173708 were required since then vm_map_unwire() looked
  at the page tables to find the page to unwire.  This is no longer
  needed with the vm_object_unwire() introduction, which follows the
  objects shadow chain.
  
  Also eliminate OBJPR_NOTWIRED flag for vm_object_page_remove(), which
  is now redundand, we do not remove wired pages.
  
  Reported by:	trasz, Dmitry Sivachenko <trtrmitya@gmail.com>
  Suggested and reviewed by:	alc
  Tested by:	pho
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/vm/vm_object.c
  head/sys/vm/vm_object.h

Modified: head/sys/vm/vm_object.c
==============================================================================
--- head/sys/vm/vm_object.c	Sat Jul 25 18:26:09 2015	(r285877)
+++ head/sys/vm/vm_object.c	Sat Jul 25 18:29:06 2015	(r285878)
@@ -1063,9 +1063,9 @@ vm_object_sync(vm_object_t object, vm_oo
 			 */
 			flags = OBJPR_NOTMAPPED;
 		else if (old_msync)
-			flags = OBJPR_NOTWIRED;
+			flags = 0;
 		else
-			flags = OBJPR_CLEANONLY | OBJPR_NOTWIRED;
+			flags = OBJPR_CLEANONLY;
 		vm_object_page_remove(object, OFF_TO_IDX(offset),
 		    OFF_TO_IDX(offset + size + PAGE_MASK), flags);
 	}
@@ -1894,7 +1894,6 @@ vm_object_page_remove(vm_object_t object
     int options)
 {
 	vm_page_t p, next;
-	int wirings;
 
 	VM_OBJECT_ASSERT_WLOCKED(object);
 	KASSERT((object->flags & OBJ_UNMANAGED) == 0 ||
@@ -1928,15 +1927,9 @@ again:
 			VM_OBJECT_WLOCK(object);
 			goto again;
 		}
-		if ((wirings = p->wire_count) != 0 &&
-		    (wirings = pmap_page_wired_mappings(p)) != p->wire_count) {
-			if ((options & (OBJPR_NOTWIRED | OBJPR_NOTMAPPED)) ==
-			    0) {
+		if (p->wire_count != 0) {
+			if ((options & OBJPR_NOTMAPPED) == 0)
 				pmap_remove_all(p);
-				/* Account for removal of wired mappings. */
-				if (wirings != 0)
-					p->wire_count -= wirings;
-			}
 			if ((options & OBJPR_CLEANONLY) == 0) {
 				p->valid = 0;
 				vm_page_undirty(p);
@@ -1957,19 +1950,8 @@ again:
 			if (p->dirty)
 				goto next;
 		}
-		if ((options & OBJPR_NOTMAPPED) == 0) {
-			if ((options & OBJPR_NOTWIRED) != 0 && wirings != 0)
-				goto next;
+		if ((options & OBJPR_NOTMAPPED) == 0)
 			pmap_remove_all(p);
-			/* Account for removal of wired mappings. */
-			if (wirings != 0) {
-				KASSERT(p->wire_count == wirings,
-				    ("inconsistent wire count %d %d %p",
-				    p->wire_count, wirings, p));
-				p->wire_count = 0;
-				atomic_subtract_int(&vm_cnt.v_wire_count, 1);
-			}
-		}
 		vm_page_free(p);
 next:
 		vm_page_unlock(p);

Modified: head/sys/vm/vm_object.h
==============================================================================
--- head/sys/vm/vm_object.h	Sat Jul 25 18:26:09 2015	(r285877)
+++ head/sys/vm/vm_object.h	Sat Jul 25 18:29:06 2015	(r285878)
@@ -207,7 +207,6 @@ struct vm_object {
  */
 #define	OBJPR_CLEANONLY	0x1		/* Don't remove dirty pages. */
 #define	OBJPR_NOTMAPPED	0x2		/* Don't unmap pages. */
-#define	OBJPR_NOTWIRED	0x4		/* Don't remove wired pages. */
 
 TAILQ_HEAD(object_q, vm_object);
 



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