From 6b9465356dffc3a21819f75f370e97cf00aa750d Mon Sep 17 00:00:00 2001 From: kib Date: Sat, 11 Jun 2011 20:15:19 +0000 Subject: Assert that page is VPO_BUSY or page owner object is locked in vm_page_undirty(). The assert is not precise due to VPO_BUSY owner to tracked, so assertion does not catch the case when VPO_BUSY is owned by other thread. Reviewed by: alc --- sys/vm/vm_page.c | 17 +++++++++++++++++ sys/vm/vm_page.h | 9 +++++++++ 2 files changed, 26 insertions(+) (limited to 'sys/vm') diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index e2758ec..21c7080 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2636,6 +2636,23 @@ vm_page_cowsetup(vm_page_t m) return (0); } +#ifdef INVARIANTS +void +vm_page_object_lock_assert(vm_page_t m) +{ + + /* + * Certain of the page's fields may only be modified by the + * holder of the containing object's lock or the setter of the + * page's VPO_BUSY flag. Unfortunately, the setter of the + * VPO_BUSY flag is not recorded, and thus cannot be checked + * here. + */ + if (m->object != NULL && (m->oflags & VPO_BUSY) == 0) + VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); +} +#endif + #include "opt_ddb.h" #ifdef DDB #include diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index c34d2f0..898857b 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -383,6 +383,13 @@ void vm_page_cowfault (vm_page_t); int vm_page_cowsetup(vm_page_t); void vm_page_cowclear (vm_page_t); +#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) +#else +#define VM_PAGE_OBJECT_LOCK_ASSERT(m) (void)0 +#endif + /* * vm_page_sleep_if_busy: * @@ -412,6 +419,8 @@ vm_page_sleep_if_busy(vm_page_t m, int also_m_busy, const char *msg) static __inline void vm_page_undirty(vm_page_t m) { + + VM_PAGE_OBJECT_LOCK_ASSERT(m); m->dirty = 0; } -- cgit v1.1