summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2002-07-29 19:41:22 +0000
committeralc <alc@FreeBSD.org>2002-07-29 19:41:22 +0000
commit478c0ba990961936269a6d44bccdbf9891a19977 (patch)
tree8770c6b5954a800908c6c0f6611953827b07e706
parentdeb56242100f6e090d1bc5c5e88885d2670f51d0 (diff)
downloadFreeBSD-src-478c0ba990961936269a6d44bccdbf9891a19977.zip
FreeBSD-src-478c0ba990961936269a6d44bccdbf9891a19977.tar.gz
o Introduce vm_page_sleep_if_busy() as an eventual replacement for
vm_page_sleep_busy(). vm_page_sleep_if_busy() uses the page queues lock.
-rw-r--r--sys/vm/vm_page.c22
-rw-r--r--sys/vm/vm_page.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 1674b07..9acd481 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -552,6 +552,28 @@ vm_page_sleep_busy(vm_page_t m, int also_m_busy, const char *msg)
}
return (FALSE);
}
+
+/*
+ * 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.
+ */
+int
+vm_page_sleep_if_busy(vm_page_t m, int also_m_busy, const char *msg)
+{
+
+ mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+ if ((m->flags & PG_BUSY) || (also_m_busy && m->busy)) {
+ vm_page_flag_set(m, PG_WANTED | PG_REFERENCED);
+ msleep(m, &vm_page_queue_mtx, PDROP | PVM, msg, 0);
+ return (TRUE);
+ }
+ return (FALSE);
+}
+
/*
* vm_page_dirty:
*
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
index 42b4410..bd44012 100644
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -332,6 +332,7 @@ void vm_page_copy(vm_page_t src_m, vm_page_t dest_m);
void vm_page_free(vm_page_t m);
void vm_page_free_zero(vm_page_t m);
int vm_page_sleep_busy(vm_page_t m, int also_m_busy, const char *msg);
+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_undirty(vm_page_t m);
void vm_page_wakeup(vm_page_t m);
OpenPOWER on IntegriCloud