svn commit: r270440 - stable/10/sys/vm
Konstantin Belousov
kib at FreeBSD.org
Sun Aug 24 07:57:51 UTC 2014
Author: kib
Date: Sun Aug 24 07:57:50 2014
New Revision: 270440
URL: http://svnweb.freebsd.org/changeset/base/270440
Log:
MFC r269746:
Adapt vm_page_aflag_set(PGA_WRITEABLE) to the locking of
pmap_enter(PMAP_ENTER_NOSLEEP).
Modified:
stable/10/sys/vm/vm_page.c
stable/10/sys/vm/vm_page.h
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/vm/vm_page.c
==============================================================================
--- stable/10/sys/vm/vm_page.c Sun Aug 24 07:53:15 2014 (r270439)
+++ stable/10/sys/vm/vm_page.c Sun Aug 24 07:57:50 2014 (r270440)
@@ -3145,6 +3145,24 @@ vm_page_object_lock_assert(vm_page_t m)
if (m->object != NULL && !vm_page_xbusied(m))
VM_OBJECT_ASSERT_WLOCKED(m->object);
}
+
+void
+vm_page_assert_pga_writeable(vm_page_t m, uint8_t bits)
+{
+
+ if ((bits & PGA_WRITEABLE) == 0)
+ return;
+
+ /*
+ * The PGA_WRITEABLE flag can only be set if the page is
+ * managed, is exclusively busied or the object is locked.
+ * Currently, this flag is only set by pmap_enter().
+ */
+ KASSERT((m->oflags & VPO_UNMANAGED) == 0,
+ ("PGA_WRITEABLE on unmanaged page"));
+ if (!vm_page_xbusied(m))
+ VM_OBJECT_ASSERT_LOCKED(m->object);
+}
#endif
#include "opt_ddb.h"
Modified: stable/10/sys/vm/vm_page.h
==============================================================================
--- stable/10/sys/vm/vm_page.h Sun Aug 24 07:53:15 2014 (r270439)
+++ stable/10/sys/vm/vm_page.h Sun Aug 24 07:57:50 2014 (r270440)
@@ -305,10 +305,10 @@ extern struct mtx_padalign pa_lock[];
* 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 exclusive busied. The MI VM layer must never
- * access this flag directly. Instead, it should call
- * pmap_page_is_write_mapped().
+ * PGA_WRITEABLE is set exclusively on managed pages by pmap_enter().
+ * When it does so, the object must be locked, or the page must be
+ * exclusive busied. The MI VM layer must never access this flag
+ * directly. Instead, it should call pmap_page_is_write_mapped().
*
* PGA_EXECUTABLE may be set by pmap routines, and indicates that a page has
* at least one executable mapping. It is not consumed by the MI VM layer.
@@ -536,8 +536,12 @@ void vm_page_lock_assert_KBI(vm_page_t m
#ifdef INVARIANTS
void vm_page_object_lock_assert(vm_page_t m);
#define VM_PAGE_OBJECT_LOCK_ASSERT(m) vm_page_object_lock_assert(m)
+void vm_page_assert_pga_writeable(vm_page_t m, uint8_t bits);
+#define VM_PAGE_ASSERT_PGA_WRITEABLE(m, bits) \
+ vm_page_assert_pga_writeable(m, bits)
#else
#define VM_PAGE_OBJECT_LOCK_ASSERT(m) (void)0
+#define VM_PAGE_ASSERT_PGA_WRITEABLE(m, bits) (void)0
#endif
/*
@@ -585,13 +589,7 @@ vm_page_aflag_set(vm_page_t m, uint8_t b
{
uint32_t *addr, val;
- /*
- * The PGA_WRITEABLE flag can only be set if the page is managed and
- * exclusive busied. Currently, this flag is only set by pmap_enter().
- */
- KASSERT((bits & PGA_WRITEABLE) == 0 ||
- ((m->oflags & VPO_UNMANAGED) == 0 && vm_page_xbusied(m)),
- ("vm_page_aflag_set: PGA_WRITEABLE and not exclusive busy"));
+ VM_PAGE_ASSERT_PGA_WRITEABLE(m, bits);
/*
* Access the whole 32-bit word containing the aflags field with an
More information about the svn-src-stable
mailing list