Index: sys/vm/vm_page.c =================================================================== --- sys/vm/vm_page.c (revision 224703) +++ sys/vm/vm_page.c (working copy) @@ -477,7 +477,6 @@ vm_page_flag_set(vm_page_t m, unsigned short bits) { - mtx_assert(&vm_page_queue_mtx, MA_OWNED); /* * The PG_WRITEABLE flag can only be set if the page is managed and * VPO_BUSY. Currently, this flag is only set by pmap_enter(). @@ -485,21 +484,44 @@ KASSERT((bits & PG_WRITEABLE) == 0 || ((m->flags & (PG_UNMANAGED | PG_FICTITIOUS)) == 0 && (m->oflags & VPO_BUSY) != 0), ("PG_WRITEABLE and !VPO_BUSY")); + +#if defined(__amd64__) || defined(__i386__) || defined(__ia64__) + /* + * On the aforementioned architectures, the page queues lock is not + * required by the following read-modify-write operation, an atomic + * operation suffices. + */ + atomic_set_short(&m->flags, bits); +#else + vm_page_lock_queues(); m->flags |= bits; + vm_page_unlock_queues(); +#endif } void vm_page_flag_clear(vm_page_t m, unsigned short bits) { - mtx_assert(&vm_page_queue_mtx, MA_OWNED); /* * The PG_REFERENCED flag can only be cleared if the object * containing the page is locked. */ KASSERT((bits & PG_REFERENCED) == 0 || VM_OBJECT_LOCKED(m->object), ("PG_REFERENCED and !VM_OBJECT_LOCKED")); + +#if defined(__amd64__) || defined(__i386__) || defined(__ia64__) + /* + * On the aforementioned architectures, the page queues lock is not + * required by the following read-modify-write operation, an atomic + * operation suffices. + */ + atomic_clear_short(&m->flags, bits); +#else + vm_page_lock_queues(); m->flags &= ~bits; + vm_page_unlock_queues(); +#endif } void Index: sys/vm/vm_page.h =================================================================== --- sys/vm/vm_page.h (revision 224703) +++ sys/vm/vm_page.h (working copy) @@ -233,9 +233,9 @@ #define PG_FREE 0x0002 /* page is free */ #define PG_WINATCFLS 0x0004 /* flush dirty page on inactive q */ #define PG_FICTITIOUS 0x0008 /* physical page doesn't exist (O) */ -#define PG_WRITEABLE 0x0010 /* page is mapped writeable */ +#define PG_WRITEABLE 0x0010 /* page is mapped writeable (M) */ #define PG_ZERO 0x0040 /* page is zeroed */ -#define PG_REFERENCED 0x0080 /* page has been referenced */ +#define PG_REFERENCED 0x0080 /* page has been referenced (M) */ #define PG_UNMANAGED 0x0800 /* No PV management for page */ #define PG_MARKER 0x1000 /* special queue marker page */ #define PG_SLAB 0x2000 /* object pointer is actually a slab */