Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Oct 2019 16:59:55 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354083 - head/sys/vm
Message-ID:  <201910251659.x9PGxtLX076416@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Fri Oct 25 16:59:54 2019
New Revision: 354083
URL: https://svnweb.freebsd.org/changeset/base/354083

Log:
  Add couple more assertions to vm_pager_assert_in().  The bogus page is
  not allowed at ends of the request, and all non-bogus pages must be
  consecutive.
  
  Reviewed by:	kib

Modified:
  head/sys/vm/vm_pager.c

Modified: head/sys/vm/vm_pager.c
==============================================================================
--- head/sys/vm/vm_pager.c	Fri Oct 25 16:30:24 2019	(r354082)
+++ head/sys/vm/vm_pager.c	Fri Oct 25 16:59:54 2019	(r354083)
@@ -257,15 +257,20 @@ vm_pager_assert_in(vm_object_t object, vm_page_t *m, i
 {
 #ifdef INVARIANTS
 
-	VM_OBJECT_ASSERT_WLOCKED(object);
-	KASSERT(count > 0, ("%s: 0 count", __func__));
 	/*
-	 * All pages must be busied, not mapped, not fully valid,
-	 * not dirty and belong to the proper object.
+	 * All pages must be consecutive, busied, not mapped, not fully valid,
+	 * not dirty and belong to the proper object.  Some pages may be the
+	 * bogus page, but the first and last pages must be a real ones.
 	 */
+
+	VM_OBJECT_ASSERT_WLOCKED(object);
+	KASSERT(count > 0, ("%s: 0 count", __func__));
 	for (int i = 0 ; i < count; i++) {
-		if (m[i] == bogus_page)
+		if (m[i] == bogus_page) {
+			KASSERT(i != 0 && i != count - 1,
+			    ("%s: page %d is the bogus page", __func__, i));
 			continue;
+		}
 		vm_page_assert_xbusied(m[i]);
 		KASSERT(!pmap_page_is_mapped(m[i]),
 		    ("%s: page %p is mapped", __func__, m[i]));
@@ -275,6 +280,8 @@ vm_pager_assert_in(vm_object_t object, vm_page_t *m, i
 		    ("%s: page %p is dirty", __func__, m[i]));
 		KASSERT(m[i]->object == object,
 		    ("%s: wrong object %p/%p", __func__, object, m[i]->object));
+		KASSERT(m[i]->pindex == m[0]->pindex + i,
+		    ("%s: page %p isn't consecutive", __func__, m[i]));
 	}
 #endif
 }



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