svn commit: r251280 - head/sys/vm

Alan Cox alc at FreeBSD.org
Mon Jun 3 01:22:55 UTC 2013


Author: alc
Date: Mon Jun  3 01:22:54 2013
New Revision: 251280
URL: http://svnweb.freebsd.org/changeset/base/251280

Log:
  Require that the page lock is held, instead of the object lock, when
  clearing the page's PGA_REFERENCED flag.  Since we are typically
  manipulating the page's act_count field when we are clearing its
  PGA_REFERENCED flag, the page lock is already held everywhere that we clear
  the PGA_REFERENCED flag.  So, in fact, this revision only changes some
  comments and an assertion.  Nonetheless, it will enable later changes to
  object locking in the pageout code.
  
  Introduce vm_page_assert_locked(), which completely hides the implementation
  details of the page lock from the caller, and use it in
  vm_page_aflag_clear().  (The existing vm_page_lock_assert() could not be
  used in vm_page_aflag_clear().)  Over the coming weeks, I expect that we'll
  either eliminate or replace the various uses of vm_page_lock_assert() with
  vm_page_assert_locked().
  
  Reviewed by:	attilio
  Sponsored by:	EMC / Isilon Storage Division

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

Modified: head/sys/vm/vm_page.c
==============================================================================
--- head/sys/vm/vm_page.c	Sun Jun  2 23:56:38 2013	(r251279)
+++ head/sys/vm/vm_page.c	Mon Jun  3 01:22:54 2013	(r251280)
@@ -2725,6 +2725,13 @@ vm_page_trylock_KBI(vm_page_t m, const c
 
 #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
 void
+vm_page_assert_locked_KBI(vm_page_t m, const char *file, int line)
+{
+
+	vm_page_lock_assert_KBI(m, MA_OWNED, file, line);
+}
+
+void
 vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line)
 {
 

Modified: head/sys/vm/vm_page.h
==============================================================================
--- head/sys/vm/vm_page.h	Sun Jun  2 23:56:38 2013	(r251279)
+++ head/sys/vm/vm_page.h	Mon Jun  3 01:22:54 2013	(r251280)
@@ -229,9 +229,12 @@ extern struct mtx_padalign pa_lock[];
 #define	vm_page_trylock(m)	mtx_trylock(vm_page_lockptr((m)))
 #endif
 #if defined(INVARIANTS)
+#define	vm_page_assert_locked(m)		\
+    vm_page_assert_locked_KBI((m), __FILE__, __LINE__)
 #define	vm_page_lock_assert(m, a)		\
     vm_page_lock_assert_KBI((m), (a), __FILE__, __LINE__)
 #else
+#define	vm_page_assert_locked(m)
 #define	vm_page_lock_assert(m, a)
 #endif
 
@@ -240,10 +243,9 @@ extern struct mtx_padalign pa_lock[];
  * these flags, the functions vm_page_aflag_set() and vm_page_aflag_clear()
  * must be used.  Neither these flags nor these functions are part of the KBI.
  *
- * PGA_REFERENCED may be cleared only if the object containing the page is
- * locked.  It is set by both the MI and MD VM layers.  However, kernel
- * loadable modules should not directly set this flag.  They should call
- * vm_page_reference() instead.
+ * PGA_REFERENCED may be cleared only if the page is locked.  It is set by
+ * both the MI and MD VM layers.  However, kernel loadable modules should not
+ * directly set this flag.  They should call vm_page_reference() instead.
  *
  * PGA_WRITEABLE is set exclusively on managed pages by pmap_enter().  When it
  * does so, the page must be VPO_BUSY.  The MI VM layer must never access this
@@ -424,6 +426,7 @@ void vm_page_lock_KBI(vm_page_t m, const
 void vm_page_unlock_KBI(vm_page_t m, const char *file, int line);
 int vm_page_trylock_KBI(vm_page_t m, const char *file, int line);
 #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+void vm_page_assert_locked_KBI(vm_page_t m, const char *file, int line);
 void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line);
 #endif
 
@@ -451,11 +454,10 @@ vm_page_aflag_clear(vm_page_t m, uint8_t
 	uint32_t *addr, val;
 
 	/*
-	 * The PGA_REFERENCED flag can only be cleared if the object
-	 * containing the page is locked.
+	 * The PGA_REFERENCED flag can only be cleared if the page is locked.
 	 */
 	if ((bits & PGA_REFERENCED) != 0)
-		VM_PAGE_OBJECT_LOCK_ASSERT(m);
+		vm_page_assert_locked(m);
 
 	/*
 	 * Access the whole 32-bit word containing the aflags field with an


More information about the svn-src-head mailing list