Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jun 2019 01:00:17 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348502 - head/sys/vm
Message-ID:  <201906020100.x5210Iwr053778@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Sun Jun  2 01:00:17 2019
New Revision: 348502
URL: https://svnweb.freebsd.org/changeset/base/348502

Log:
  Add a vm_page_wired() predicate.
  
  Use it instead of accessing the wire_count field directly.  No
  functional change intended.
  
  Reviewed by:	alc, kib
  MFC after:	1 week
  Sponsored by:	Netflix
  Differential Revision:	https://reviews.freebsd.org/D20485

Modified:
  head/sys/vm/memguard.c
  head/sys/vm/swap_pager.c
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_object.c
  head/sys/vm/vm_page.c
  head/sys/vm/vm_page.h
  head/sys/vm/vm_pageout.c

Modified: head/sys/vm/memguard.c
==============================================================================
--- head/sys/vm/memguard.c	Sun Jun  2 00:08:24 2019	(r348501)
+++ head/sys/vm/memguard.c	Sun Jun  2 01:00:17 2019	(r348502)
@@ -262,7 +262,7 @@ v2sizep(vm_offset_t va)
 	if (pa == 0)
 		panic("MemGuard detected double-free of %p", (void *)va);
 	p = PHYS_TO_VM_PAGE(pa);
-	KASSERT(p->wire_count != 0 && p->queue == PQ_NONE,
+	KASSERT(vm_page_wired(p) && p->queue == PQ_NONE,
 	    ("MEMGUARD: Expected wired page %p in vtomgfifo!", p));
 	return (&p->plinks.memguard.p);
 }
@@ -277,7 +277,7 @@ v2sizev(vm_offset_t va)
 	if (pa == 0)
 		panic("MemGuard detected double-free of %p", (void *)va);
 	p = PHYS_TO_VM_PAGE(pa);
-	KASSERT(p->wire_count != 0 && p->queue == PQ_NONE,
+	KASSERT(vm_page_wired(p) && p->queue == PQ_NONE,
 	    ("MEMGUARD: Expected wired page %p in vtomgfifo!", p));
 	return (&p->plinks.memguard.v);
 }

Modified: head/sys/vm/swap_pager.c
==============================================================================
--- head/sys/vm/swap_pager.c	Sun Jun  2 00:08:24 2019	(r348501)
+++ head/sys/vm/swap_pager.c	Sun Jun  2 01:00:17 2019	(r348502)
@@ -1679,7 +1679,7 @@ swp_pager_force_pagein(vm_object_t object, vm_pindex_t
 		vm_page_dirty(m);
 #ifdef INVARIANTS
 		vm_page_lock(m);
-		if (m->wire_count == 0 && m->queue == PQ_NONE)
+		if (!vm_page_wired(m) && m->queue == PQ_NONE)
 			panic("page %p is neither wired nor queued", m);
 		vm_page_unlock(m);
 #endif

Modified: head/sys/vm/vm_fault.c
==============================================================================
--- head/sys/vm/vm_fault.c	Sun Jun  2 00:08:24 2019	(r348501)
+++ head/sys/vm/vm_fault.c	Sun Jun  2 01:00:17 2019	(r348502)
@@ -1004,7 +1004,7 @@ readrest:
 			 */
 			if (rv == VM_PAGER_ERROR || rv == VM_PAGER_BAD) {
 				vm_page_lock(fs.m);
-				if (fs.m->wire_count == 0)
+				if (!vm_page_wired(fs.m))
 					vm_page_free(fs.m);
 				else
 					vm_page_xunbusy_maybelocked(fs.m);
@@ -1027,7 +1027,7 @@ readrest:
 			 */
 			if (fs.object != fs.first_object) {
 				vm_page_lock(fs.m);
-				if (fs.m->wire_count == 0)
+				if (!vm_page_wired(fs.m))
 					vm_page_free(fs.m);
 				else
 					vm_page_xunbusy_maybelocked(fs.m);
@@ -1805,7 +1805,7 @@ again:
 				vm_page_wire(dst_m);
 				vm_page_unlock(dst_m);
 			} else {
-				KASSERT(dst_m->wire_count > 0,
+				KASSERT(vm_page_wired(dst_m),
 				    ("dst_m %p is not wired", dst_m));
 			}
 		} else {

Modified: head/sys/vm/vm_object.c
==============================================================================
--- head/sys/vm/vm_object.c	Sun Jun  2 00:08:24 2019	(r348501)
+++ head/sys/vm/vm_object.c	Sun Jun  2 01:00:17 2019	(r348502)
@@ -720,7 +720,7 @@ vm_object_terminate_pages(vm_object_t object)
 			 */
 			vm_page_change_lock(p, &mtx);
 		p->object = NULL;
-		if (p->wire_count != 0)
+		if (vm_page_wired(p))
 			continue;
 		VM_CNT_INC(v_pfree);
 		vm_page_free(p);
@@ -1595,7 +1595,7 @@ 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 (p->wire_count == 0)
+			if (!vm_page_wired(p))
 				vm_page_free(p);
 			else
 				vm_page_remove(p);
@@ -1639,7 +1639,7 @@ 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 (p->wire_count == 0)
+			if (!vm_page_wired(p))
 				vm_page_free(p);
 			else
 				vm_page_remove(p);
@@ -1944,7 +1944,7 @@ again:
 			VM_OBJECT_WLOCK(object);
 			goto again;
 		}
-		if (p->wire_count != 0) {
+		if (vm_page_wired(p)) {
 			if ((options & OBJPR_NOTMAPPED) == 0 &&
 			    object->ref_count != 0)
 				pmap_remove_all(p);

Modified: head/sys/vm/vm_page.c
==============================================================================
--- head/sys/vm/vm_page.c	Sun Jun  2 00:08:24 2019	(r348501)
+++ head/sys/vm/vm_page.c	Sun Jun  2 01:00:17 2019	(r348502)
@@ -2608,7 +2608,7 @@ retry:
 						error = ENOMEM;
 						goto unlock;
 					}
-					KASSERT(m_new->wire_count == 0,
+					KASSERT(!vm_page_wired(m_new),
 					    ("page %p is wired", m_new));
 
 					/*
@@ -3434,7 +3434,7 @@ vm_page_activate(vm_page_t m)
 
 	vm_page_assert_locked(m);
 
-	if (m->wire_count > 0 || (m->oflags & VPO_UNMANAGED) != 0)
+	if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
 		return;
 	if (vm_page_queue(m) == PQ_ACTIVE) {
 		if (m->act_count < ACT_INIT)
@@ -3509,7 +3509,7 @@ vm_page_free_prep(vm_page_t m)
 	m->valid = 0;
 	vm_page_undirty(m);
 
-	if (m->wire_count != 0)
+	if (vm_page_wired(m) != 0)
 		panic("vm_page_free_prep: freeing wired page %p", m);
 	if (m->hold_count != 0) {
 		m->flags &= ~PG_ZERO;
@@ -3610,7 +3610,7 @@ vm_page_wire(vm_page_t m)
 		    m));
 		return;
 	}
-	if (m->wire_count == 0) {
+	if (!vm_page_wired(m)) {
 		KASSERT((m->oflags & VPO_UNMANAGED) == 0 ||
 		    m->queue == PQ_NONE,
 		    ("vm_page_wire: unmanaged page %p is queued", m));
@@ -3688,7 +3688,7 @@ vm_page_unwire_noq(vm_page_t m)
 	    ("vm_page_unwire: fictitious page %p's wire count isn't one", m));
 		return (false);
 	}
-	if (m->wire_count == 0)
+	if (!vm_page_wired(m))
 		panic("vm_page_unwire: page %p's wire count is zero", m);
 	m->wire_count--;
 	if (m->wire_count == 0) {
@@ -3710,7 +3710,7 @@ vm_page_deactivate(vm_page_t m)
 
 	vm_page_assert_locked(m);
 
-	if (m->wire_count > 0 || (m->oflags & VPO_UNMANAGED) != 0)
+	if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
 		return;
 
 	if (!vm_page_inactive(m)) {
@@ -3734,7 +3734,7 @@ vm_page_deactivate_noreuse(vm_page_t m)
 
 	vm_page_assert_locked(m);
 
-	if (m->wire_count > 0 || (m->oflags & VPO_UNMANAGED) != 0)
+	if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
 		return;
 
 	if (!vm_page_inactive(m)) {
@@ -3756,7 +3756,7 @@ vm_page_launder(vm_page_t m)
 {
 
 	vm_page_assert_locked(m);
-	if (m->wire_count > 0 || (m->oflags & VPO_UNMANAGED) != 0)
+	if (vm_page_wired(m) || (m->oflags & VPO_UNMANAGED) != 0)
 		return;
 
 	if (vm_page_in_laundry(m))
@@ -3777,7 +3777,7 @@ vm_page_unswappable(vm_page_t m)
 {
 
 	vm_page_assert_locked(m);
-	KASSERT(m->wire_count == 0 && (m->oflags & VPO_UNMANAGED) == 0,
+	KASSERT(!vm_page_wired(m) && (m->oflags & VPO_UNMANAGED) == 0,
 	    ("page %p already unswappable", m));
 
 	vm_page_dequeue(m);

Modified: head/sys/vm/vm_page.h
==============================================================================
--- head/sys/vm/vm_page.h	Sun Jun  2 00:08:24 2019	(r348501)
+++ head/sys/vm/vm_page.h	Sun Jun  2 01:00:17 2019	(r348502)
@@ -822,5 +822,12 @@ vm_page_held(vm_page_t m)
 	return (m->hold_count > 0 || m->wire_count > 0);
 }
 
+static inline bool
+vm_page_wired(vm_page_t m)
+{
+
+	return (m->wire_count > 0);
+}
+
 #endif				/* _KERNEL */
 #endif				/* !_VM_PAGE_ */

Modified: head/sys/vm/vm_pageout.c
==============================================================================
--- head/sys/vm/vm_pageout.c	Sun Jun  2 00:08:24 2019	(r348501)
+++ head/sys/vm/vm_pageout.c	Sun Jun  2 01:00:17 2019	(r348502)
@@ -754,7 +754,7 @@ recheck:
 		 */
 		if (m->hold_count != 0)
 			continue;
-		if (m->wire_count != 0) {
+		if (vm_page_wired(m)) {
 			vm_page_dequeue_deferred(m);
 			continue;
 		}
@@ -1203,7 +1203,7 @@ act_scan:
 		/*
 		 * Wired pages are dequeued lazily.
 		 */
-		if (m->wire_count != 0) {
+		if (vm_page_wired(m)) {
 			vm_page_dequeue_deferred(m);
 			continue;
 		}
@@ -1430,7 +1430,7 @@ recheck:
 			addl_page_shortage++;
 			goto reinsert;
 		}
-		if (m->wire_count != 0) {
+		if (vm_page_wired(m)) {
 			vm_page_dequeue_deferred(m);
 			continue;
 		}



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