diff options
| -rw-r--r-- | sys/vm/vm_page.c | 43 | ||||
| -rw-r--r-- | sys/vm/vm_page.h | 23 |
2 files changed, 41 insertions, 25 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index ba9e37ddd4b3..34a84cf51d0c 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -484,36 +484,31 @@ vm_page_free_zero(vm_page_t m) } /* - * vm_page_sleep_if_busy: + * vm_page_sleep: * - * Sleep and release the page queues lock if PG_BUSY is set or, - * if also_m_busy is TRUE, busy is non-zero. Returns TRUE if the - * thread slept and the page queues lock was released. - * Otherwise, retains the page queues lock and returns FALSE. + * Sleep and release the page queues lock. + * + * The object containing the given page must be locked. */ -int -vm_page_sleep_if_busy(vm_page_t m, int also_m_busy, const char *msg) +void +vm_page_sleep(vm_page_t m, const char *msg) { VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); - if ((m->flags & PG_BUSY) || (also_m_busy && m->busy)) { - if (!mtx_owned(&vm_page_queue_mtx)) - vm_page_lock_queues(); - vm_page_flag_set(m, PG_REFERENCED); - vm_page_unlock_queues(); + if (!mtx_owned(&vm_page_queue_mtx)) + vm_page_lock_queues(); + vm_page_flag_set(m, PG_REFERENCED); + vm_page_unlock_queues(); - /* - * It's possible that while we sleep, the page will get - * unbusied and freed. If we are holding the object - * lock, we will assume we hold a reference to the object - * such that even if m->object changes, we can re-lock - * it. - */ - m->oflags |= VPO_WANTED; - msleep(m, VM_OBJECT_MTX(m->object), PVM, msg, 0); - return (TRUE); - } - return (FALSE); + /* + * It's possible that while we sleep, the page will get + * unbusied and freed. If we are holding the object + * lock, we will assume we hold a reference to the object + * such that even if m->object changes, we can re-lock + * it. + */ + m->oflags |= VPO_WANTED; + msleep(m, VM_OBJECT_MTX(m->object), PVM, msg, 0); } /* diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index 0752d0d9128b..415d88cd4e6c 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -314,7 +314,6 @@ void vm_page_hold(vm_page_t mem); void vm_page_unhold(vm_page_t mem); void vm_page_free(vm_page_t m); void vm_page_free_zero(vm_page_t m); -int vm_page_sleep_if_busy(vm_page_t m, int also_m_busy, const char *msg); void vm_page_dirty(vm_page_t m); void vm_page_wakeup(vm_page_t m); @@ -342,6 +341,7 @@ vm_page_t vm_page_lookup (vm_object_t, vm_pindex_t); void vm_page_remove (vm_page_t); void vm_page_rename (vm_page_t, vm_object_t, vm_pindex_t); vm_page_t vm_page_select_cache(int); +void vm_page_sleep(vm_page_t m, const char *msg); vm_page_t vm_page_splay(vm_pindex_t, vm_page_t); vm_offset_t vm_page_startup(vm_offset_t vaddr); void vm_page_unmanage (vm_page_t); @@ -361,6 +361,27 @@ void vm_page_cowsetup (vm_page_t); void vm_page_cowclear (vm_page_t); /* + * vm_page_sleep_if_busy: + * + * Sleep and release the page queues lock if PG_BUSY is set or, + * if also_m_busy is TRUE, busy is non-zero. Returns TRUE if the + * thread slept and the page queues lock was released. + * Otherwise, retains the page queues lock and returns FALSE. + * + * The object containing the given page must be locked. + */ +static __inline int +vm_page_sleep_if_busy(vm_page_t m, int also_m_busy, const char *msg) +{ + + if ((m->flags & PG_BUSY) || (also_m_busy && m->busy)) { + vm_page_sleep(m, msg); + return (TRUE); + } + return (FALSE); +} + +/* * vm_page_undirty: * * Set page to not be dirty. Note: does not clear pmap modify bits |
