Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Sep 2019 16:26:59 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r352253 - in head/sys: kern vm
Message-ID:  <201909121626.x8CGQxCe029348@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Thu Sep 12 16:26:59 2019
New Revision: 352253
URL: https://svnweb.freebsd.org/changeset/base/352253

Log:
  Use REFCOUNT_COUNT() to obtain refcount where appropriate.
  Refcount waiting will set some flag bits in the refcount value.
  Make sure these bits get cleared by using the REFCOUNT_COUNT()
  macro to obtain the actual refcount.
  
  Differential Revision:	https://reviews.freebsd.org/D21620
  Reviewed by:	kib@, markj@
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/kern/vfs_bio.c
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_object.c
  head/sys/vm/vm_swapout.c

Modified: head/sys/kern/vfs_bio.c
==============================================================================
--- head/sys/kern/vfs_bio.c	Thu Sep 12 16:23:22 2019	(r352252)
+++ head/sys/kern/vfs_bio.c	Thu Sep 12 16:26:59 2019	(r352253)
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kthread.h>
 #include <sys/proc.h>
 #include <sys/racct.h>
+#include <sys/refcount.h>
 #include <sys/resourcevar.h>
 #include <sys/rwlock.h>
 #include <sys/smp.h>
@@ -2842,9 +2843,9 @@ vfs_vmio_iodone(struct buf *bp)
 	bool bogus;
 
 	obj = bp->b_bufobj->bo_object;
-	KASSERT(obj->paging_in_progress >= bp->b_npages,
+	KASSERT(REFCOUNT_COUNT(obj->paging_in_progress) >= bp->b_npages,
 	    ("vfs_vmio_iodone: paging in progress(%d) < b_npages(%d)",
-	    obj->paging_in_progress, bp->b_npages));
+	    REFCOUNT_COUNT(obj->paging_in_progress), bp->b_npages));
 
 	vp = bp->b_vp;
 	KASSERT(vp->v_holdcnt > 0,

Modified: head/sys/vm/vm_fault.c
==============================================================================
--- head/sys/vm/vm_fault.c	Thu Sep 12 16:23:22 2019	(r352252)
+++ head/sys/vm/vm_fault.c	Thu Sep 12 16:26:59 2019	(r352253)
@@ -87,6 +87,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/proc.h>
 #include <sys/racct.h>
+#include <sys/refcount.h>
 #include <sys/resourcevar.h>
 #include <sys/rwlock.h>
 #include <sys/sysctl.h>
@@ -339,7 +340,7 @@ vm_fault_restore_map_lock(struct faultstate *fs)
 {
 
 	VM_OBJECT_ASSERT_WLOCKED(fs->first_object);
-	MPASS(fs->first_object->paging_in_progress > 0);
+	MPASS(REFCOUNT_COUNT(fs->first_object->paging_in_progress) > 0);
 
 	if (!vm_map_trylock_read(fs->map)) {
 		VM_OBJECT_WUNLOCK(fs->first_object);
@@ -394,7 +395,7 @@ vm_fault_populate(struct faultstate *fs, vm_prot_t pro
 
 	MPASS(fs->object == fs->first_object);
 	VM_OBJECT_ASSERT_WLOCKED(fs->first_object);
-	MPASS(fs->first_object->paging_in_progress > 0);
+	MPASS(REFCOUNT_COUNT(fs->first_object->paging_in_progress) > 0);
 	MPASS(fs->first_object->backing_object == NULL);
 	MPASS(fs->lookup_still_valid);
 

Modified: head/sys/vm/vm_object.c
==============================================================================
--- head/sys/vm/vm_object.c	Thu Sep 12 16:23:22 2019	(r352252)
+++ head/sys/vm/vm_object.c	Thu Sep 12 16:26:59 2019	(r352253)
@@ -195,9 +195,9 @@ vm_object_zdtor(void *mem, int size, void *arg)
 	    ("object %p has reservations",
 	    object));
 #endif
-	KASSERT(object->paging_in_progress == 0,
+	KASSERT(REFCOUNT_COUNT(object->paging_in_progress) == 0,
 	    ("object %p paging_in_progress = %d",
-	    object, object->paging_in_progress));
+	    object, REFCOUNT_COUNT(object->paging_in_progress)));
 	KASSERT(object->resident_page_count == 0,
 	    ("object %p resident_page_count = %d",
 	    object, object->resident_page_count));
@@ -395,7 +395,7 @@ vm_object_pip_wait(vm_object_t object, char *waitid)
 
 	VM_OBJECT_ASSERT_WLOCKED(object);
 
-	while (object->paging_in_progress) {
+	while (REFCOUNT_COUNT(object->paging_in_progress) > 0) {
 		VM_OBJECT_WUNLOCK(object);
 		refcount_wait(&object->paging_in_progress, waitid, PVM);
 		VM_OBJECT_WLOCK(object);
@@ -408,7 +408,7 @@ vm_object_pip_wait_unlocked(vm_object_t object, char *
 
 	VM_OBJECT_ASSERT_UNLOCKED(object);
 
-	while (object->paging_in_progress)
+	while (REFCOUNT_COUNT(object->paging_in_progress) > 0)
 		refcount_wait(&object->paging_in_progress, waitid, PVM);
 }
 
@@ -577,7 +577,7 @@ vm_object_deallocate(vm_object_t object)
 
 					robject->ref_count++;
 retry:
-					if (robject->paging_in_progress) {
+					if (REFCOUNT_COUNT(robject->paging_in_progress) > 0) {
 						VM_OBJECT_WUNLOCK(object);
 						vm_object_pip_wait(robject,
 						    "objde1");
@@ -586,7 +586,7 @@ retry:
 							VM_OBJECT_WLOCK(object);
 							goto retry;
 						}
-					} else if (object->paging_in_progress) {
+					} else if (REFCOUNT_COUNT(object->paging_in_progress) > 0) {
 						VM_OBJECT_WUNLOCK(robject);
 						VM_OBJECT_WUNLOCK(object);
 						refcount_wait(
@@ -729,7 +729,7 @@ vm_object_terminate(vm_object_t object)
 	 */
 	vm_object_pip_wait(object, "objtrm");
 
-	KASSERT(!object->paging_in_progress,
+	KASSERT(!REFCOUNT_COUNT(object->paging_in_progress),
 		("vm_object_terminate: pageout in progress"));
 
 	KASSERT(object->ref_count == 0, 
@@ -1660,8 +1660,8 @@ vm_object_collapse(vm_object_t object)
 			break;
 		}
 
-		if (object->paging_in_progress != 0 ||
-		    backing_object->paging_in_progress != 0) {
+		if (REFCOUNT_COUNT(object->paging_in_progress) > 0 ||
+		    REFCOUNT_COUNT(backing_object->paging_in_progress) > 0) {
 			vm_object_qcollapse(object);
 			VM_OBJECT_WUNLOCK(backing_object);
 			break;

Modified: head/sys/vm/vm_swapout.c
==============================================================================
--- head/sys/vm/vm_swapout.c	Thu Sep 12 16:23:22 2019	(r352252)
+++ head/sys/vm/vm_swapout.c	Thu Sep 12 16:26:59 2019	(r352253)
@@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mount.h>
 #include <sys/racct.h>
 #include <sys/resourcevar.h>
+#include <sys/refcount.h>
 #include <sys/sched.h>
 #include <sys/sdt.h>
 #include <sys/signalvar.h>
@@ -193,7 +194,7 @@ vm_swapout_object_deactivate_pages(pmap_t pmap, vm_obj
 			goto unlock_return;
 		VM_OBJECT_ASSERT_LOCKED(object);
 		if ((object->flags & OBJ_UNMANAGED) != 0 ||
-		    object->paging_in_progress != 0)
+		    REFCOUNT_COUNT(object->paging_in_progress) > 0)
 			goto unlock_return;
 
 		remove_mode = 0;



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