summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-07-08 08:37:51 +0000
committerkib <kib@FreeBSD.org>2010-07-08 08:37:51 +0000
commit3cf9fcd59a78bb4ed674857a87e8276caeec2236 (patch)
tree25251bdcfa91476c2aece58dc11e6047d6218a63 /sys
parent10f83cdf0a459ed959605be219efd36ff9183a1e (diff)
downloadFreeBSD-src-3cf9fcd59a78bb4ed674857a87e8276caeec2236.zip
FreeBSD-src-3cf9fcd59a78bb4ed674857a87e8276caeec2236.tar.gz
Make VM_ALLOC_RETRY flag mandatory for vm_page_grab(). Assert that the
flag is always provided, and unconditionally retry after sleep for the busy page or failed allocation. The intent is to remove VM_ALLOC_RETRY eventually. Proposed and reviewed by: alc
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_page.c25
-rw-r--r--sys/vm/vm_page.h2
2 files changed, 13 insertions, 14 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 810338d..61718f4 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2032,6 +2032,9 @@ vm_page_dontneed(vm_page_t m)
* to be in the object. If the page doesn't exist, first allocate it
* and then conditionally zero it.
*
+ * The caller must always specify the VM_ALLOC_RETRY flag. This is intended
+ * to facilitate its eventual removal.
+ *
* This routine may block.
*/
vm_page_t
@@ -2041,22 +2044,20 @@ vm_page_grab(vm_object_t object, vm_pindex_t pindex, int allocflags)
u_int count;
VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
+ KASSERT((allocflags & VM_ALLOC_RETRY) != 0,
+ ("vm_page_grab: VM_ALLOC_RETRY is required"));
retrylookup:
if ((m = vm_page_lookup(object, pindex)) != NULL) {
if ((m->oflags & VPO_BUSY) != 0 ||
((allocflags & VM_ALLOC_IGN_SBUSY) == 0 && m->busy != 0)) {
- if ((allocflags & VM_ALLOC_RETRY) != 0) {
- /*
- * Reference the page before unlocking and
- * sleeping so that the page daemon is less
- * likely to reclaim it.
- */
- vm_page_lock_queues();
- vm_page_flag_set(m, PG_REFERENCED);
- }
+ /*
+ * Reference the page before unlocking and
+ * sleeping so that the page daemon is less
+ * likely to reclaim it.
+ */
+ vm_page_lock_queues();
+ vm_page_flag_set(m, PG_REFERENCED);
vm_page_sleep(m, "pgrbwt");
- if ((allocflags & VM_ALLOC_RETRY) == 0)
- return (NULL);
goto retrylookup;
} else {
if ((allocflags & VM_ALLOC_WIRED) != 0) {
@@ -2078,8 +2079,6 @@ retrylookup:
atomic_add_int(&vm_pageout_deficit, count);
VM_WAIT;
VM_OBJECT_LOCK(object);
- if ((allocflags & VM_ALLOC_RETRY) == 0)
- return (NULL);
goto retrylookup;
} else if (m->valid != 0)
return (m);
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
index 0829025..62868cd 100644
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -312,7 +312,7 @@ extern struct vpglocks vm_page_queue_lock;
/* page allocation flags: */
#define VM_ALLOC_WIRED 0x0020 /* non pageable */
#define VM_ALLOC_ZERO 0x0040 /* Try to obtain a zeroed page */
-#define VM_ALLOC_RETRY 0x0080 /* vm_page_grab() only */
+#define VM_ALLOC_RETRY 0x0080 /* Mandatory with vm_page_grab() */
#define VM_ALLOC_NOOBJ 0x0100 /* No associated object */
#define VM_ALLOC_NOBUSY 0x0200 /* Do not busy the page */
#define VM_ALLOC_IFCACHED 0x0400 /* Fail if the page is not cached */
OpenPOWER on IntegriCloud