Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jul 2019 20:17:27 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r349701 - in stable/12/sys: amd64/sgx dev/drm2/ttm vm
Message-ID:  <201907032017.x63KHRpp091453@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Wed Jul  3 20:17:26 2019
New Revision: 349701
URL: https://svnweb.freebsd.org/changeset/base/349701

Log:
  MFC r349432:
  Add a return value to vm_page_remove().

Modified:
  stable/12/sys/amd64/sgx/sgx.c
  stable/12/sys/dev/drm2/ttm/ttm_bo_vm.c
  stable/12/sys/vm/device_pager.c
  stable/12/sys/vm/vm_fault.c
  stable/12/sys/vm/vm_object.c
  stable/12/sys/vm/vm_page.c
  stable/12/sys/vm/vm_page.h

Modified: stable/12/sys/amd64/sgx/sgx.c
==============================================================================
--- stable/12/sys/amd64/sgx/sgx.c	Wed Jul  3 20:15:09 2019	(r349700)
+++ stable/12/sys/amd64/sgx/sgx.c	Wed Jul  3 20:17:26 2019	(r349701)
@@ -358,7 +358,7 @@ sgx_page_remove(struct sgx_softc *sc, vm_page_t p)
 	uint64_t offs;
 
 	vm_page_lock(p);
-	vm_page_remove(p);
+	(void)vm_page_remove(p);
 	vm_page_unlock(p);
 
 	dprintf("%s: p->pidx %ld\n", __func__, p->pindex);

Modified: stable/12/sys/dev/drm2/ttm/ttm_bo_vm.c
==============================================================================
--- stable/12/sys/dev/drm2/ttm/ttm_bo_vm.c	Wed Jul  3 20:15:09 2019	(r349700)
+++ stable/12/sys/dev/drm2/ttm/ttm_bo_vm.c	Wed Jul  3 20:17:26 2019	(r349701)
@@ -115,7 +115,7 @@ ttm_bo_vm_fault(vm_object_t vm_obj, vm_ooffset_t offse
 	vm_object_pip_add(vm_obj, 1);
 	if (*mres != NULL) {
 		vm_page_lock(*mres);
-		vm_page_remove(*mres);
+		(void)vm_page_remove(*mres);
 		vm_page_unlock(*mres);
 	}
 retry:

Modified: stable/12/sys/vm/device_pager.c
==============================================================================
--- stable/12/sys/vm/device_pager.c	Wed Jul  3 20:15:09 2019	(r349700)
+++ stable/12/sys/vm/device_pager.c	Wed Jul  3 20:17:26 2019	(r349701)
@@ -236,7 +236,7 @@ cdev_pager_free_page(vm_object_t object, vm_page_t m)
 		KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("unmanaged %p", m));
 		pmap_remove_all(m);
 		vm_page_lock(m);
-		vm_page_remove(m);
+		(void)vm_page_remove(m);
 		vm_page_unlock(m);
 	} else if (object->type == OBJT_DEVICE)
 		dev_pager_free_page(object, m);

Modified: stable/12/sys/vm/vm_fault.c
==============================================================================
--- stable/12/sys/vm/vm_fault.c	Wed Jul  3 20:15:09 2019	(r349700)
+++ stable/12/sys/vm/vm_fault.c	Wed Jul  3 20:17:26 2019	(r349701)
@@ -1144,7 +1144,7 @@ readrest:
 			    fs.object == fs.first_object->backing_object) {
 				vm_page_lock(fs.m);
 				vm_page_dequeue(fs.m);
-				vm_page_remove(fs.m);
+				(void)vm_page_remove(fs.m);
 				vm_page_unlock(fs.m);
 				vm_page_lock(fs.first_m);
 				vm_page_replace_checked(fs.m, fs.first_object,

Modified: stable/12/sys/vm/vm_object.c
==============================================================================
--- stable/12/sys/vm/vm_object.c	Wed Jul  3 20:15:09 2019	(r349700)
+++ stable/12/sys/vm/vm_object.c	Wed Jul  3 20:17:26 2019	(r349701)
@@ -1595,10 +1595,8 @@ vm_object_collapse_scan(vm_object_t object, int op)
 			vm_page_lock(p);
 			KASSERT(!pmap_page_is_mapped(p),
 			    ("freeing mapped page %p", p));
-			if (!vm_page_wired(p))
+			if (vm_page_remove(p))
 				vm_page_free(p);
-			else
-				vm_page_remove(p);
 			vm_page_unlock(p);
 			continue;
 		}
@@ -1639,10 +1637,8 @@ vm_object_collapse_scan(vm_object_t object, int op)
 			vm_page_lock(p);
 			KASSERT(!pmap_page_is_mapped(p),
 			    ("freeing mapped page %p", p));
-			if (!vm_page_wired(p))
+			if (vm_page_remove(p))
 				vm_page_free(p);
-			else
-				vm_page_remove(p);
 			vm_page_unlock(p);
 			continue;
 		}

Modified: stable/12/sys/vm/vm_page.c
==============================================================================
--- stable/12/sys/vm/vm_page.c	Wed Jul  3 20:15:09 2019	(r349700)
+++ stable/12/sys/vm/vm_page.c	Wed Jul  3 20:17:26 2019	(r349701)
@@ -1454,20 +1454,21 @@ vm_page_insert_radixdone(vm_page_t m, vm_object_t obje
  *	vm_page_remove:
  *
  *	Removes the specified page from its containing object, but does not
- *	invalidate any backing storage.
+ *	invalidate any backing storage.  Return true if the page may be safely
+ *	freed and false otherwise.
  *
  *	The object must be locked.  The page must be locked if it is managed.
  */
-void
+bool
 vm_page_remove(vm_page_t m)
 {
 	vm_object_t object;
 	vm_page_t mrem;
 
+	object = m->object;
+
 	if ((m->oflags & VPO_UNMANAGED) == 0)
 		vm_page_assert_locked(m);
-	if ((object = m->object) == NULL)
-		return;
 	VM_OBJECT_ASSERT_WLOCKED(object);
 	if (vm_page_xbusied(m))
 		vm_page_xunbusy_maybelocked(m);
@@ -1491,6 +1492,7 @@ vm_page_remove(vm_page_t m)
 		vdrop(object->handle);
 
 	m->object = NULL;
+	return (!vm_page_wired(m));
 }
 
 /*
@@ -1661,7 +1663,7 @@ vm_page_rename(vm_page_t m, vm_object_t new_object, vm
 	 */
 	m->pindex = opidx;
 	vm_page_lock(m);
-	vm_page_remove(m);
+	(void)vm_page_remove(m);
 
 	/* Return back to the new pindex to complete vm_page_insert(). */
 	m->pindex = new_pindex;
@@ -3434,7 +3436,8 @@ vm_page_free_prep(vm_page_t m)
 	if (vm_page_sbusied(m))
 		panic("vm_page_free_prep: freeing busy page %p", m);
 
-	vm_page_remove(m);
+	if (m->object != NULL)
+		(void)vm_page_remove(m);
 
 	/*
 	 * If fictitious remove object association and

Modified: stable/12/sys/vm/vm_page.h
==============================================================================
--- stable/12/sys/vm/vm_page.h	Wed Jul  3 20:15:09 2019	(r349700)
+++ stable/12/sys/vm/vm_page.h	Wed Jul  3 20:17:26 2019	(r349701)
@@ -559,7 +559,7 @@ bool vm_page_reclaim_contig(int req, u_long npages, vm
 bool vm_page_reclaim_contig_domain(int domain, int req, u_long npages,
     vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary);
 void vm_page_reference(vm_page_t m);
-void vm_page_remove (vm_page_t);
+bool vm_page_remove(vm_page_t);
 int vm_page_rename (vm_page_t, vm_object_t, vm_pindex_t);
 vm_page_t vm_page_replace(vm_page_t mnew, vm_object_t object,
     vm_pindex_t pindex);



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