diff options
author | alc <alc@FreeBSD.org> | 2006-08-27 19:50:13 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2006-08-27 19:50:13 +0000 |
commit | f2ccfe95252579f4a77ff68a316f2f07850f0277 (patch) | |
tree | 16f1a3f994a161f8d4c780cb443fa89ddd1030b6 /sys/vm/vm_page.c | |
parent | c1c941b5f55fad34accb7005a7f57157947a29dc (diff) | |
download | FreeBSD-src-f2ccfe95252579f4a77ff68a316f2f07850f0277.zip FreeBSD-src-f2ccfe95252579f4a77ff68a316f2f07850f0277.tar.gz |
Refactor vm_page_sleep_if_busy() so that the test for a busy page is
inlined and a procedure call is made in the rare case, i.e., when it is
necessary to sleep. In this case, inlining the test actually makes the
kernel smaller.
Diffstat (limited to 'sys/vm/vm_page.c')
-rw-r--r-- | sys/vm/vm_page.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index ba9e37d..34a84cf 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); } /* |