Page MenuHomeFreeBSD

D49391.id152556.diff
No OneTemporary

D49391.id152556.diff

Index: sys/vm/vm_page.h
===================================================================
--- sys/vm/vm_page.h
+++ sys/vm/vm_page.h
@@ -511,10 +511,9 @@
vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
/*
- * Page allocation parameters for vm_page for the functions
- * vm_page_alloc(), vm_page_grab(), vm_page_alloc_contig() and
- * vm_page_alloc_freelist(). Some functions support only a subset
- * of the flags, and ignore others, see the flags legend.
+ * Page allocation parameters for vm_page for the functions vm_page_alloc(),
+ * vm_page_grab() and vm_page_alloc_contig(). Some functions support only a
+ * subset of the flags, and ignore others, see the flags legend.
*
* The meaning of VM_ALLOC_ZERO differs slightly between the vm_page_alloc*()
* and the vm_page_grab*() functions. See these functions for details.
@@ -525,7 +524,7 @@
* (a) - vm_page_alloc() supports the flag.
* (c) - vm_page_alloc_contig() supports the flag.
* (g) - vm_page_grab() supports the flag.
- * (n) - vm_page_alloc_noobj() and vm_page_alloc_freelist() support the flag.
+ * (n) - vm_page_alloc_noobj() supports the flag.
* (p) - vm_page_grab_pages() supports the flag.
* Bits above 15 define the count of additional pages that the caller
* intends to allocate.
@@ -534,7 +533,7 @@
#define VM_ALLOC_INTERRUPT 1
#define VM_ALLOC_SYSTEM 2
#define VM_ALLOC_CLASS_MASK 3
-#define VM_ALLOC_WAITOK 0x0008 /* (acn) Sleep and retry */
+#define VM_ALLOC_WAITOK 0x0008 /* (n) Sleep and retry */
#define VM_ALLOC_WAITFAIL 0x0010 /* (acn) Sleep and return error */
#define VM_ALLOC_WIRED 0x0020 /* (acgnp) Allocate a wired page */
#define VM_ALLOC_ZERO 0x0040 /* (acgnp) Allocate a zeroed page */
@@ -544,7 +543,7 @@
#define VM_ALLOC_NOCREAT 0x0400 /* (gp) Don't create a page */
#define VM_ALLOC_AVAIL1 0x0800
#define VM_ALLOC_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy flag */
-#define VM_ALLOC_NODUMP 0x2000 /* (ag) don't include in dump */
+#define VM_ALLOC_NODUMP 0x2000 /* (acgnp) don't include in dump */
#define VM_ALLOC_SBUSY 0x4000 /* (acgp) Shared busy the page */
#define VM_ALLOC_NOWAIT 0x8000 /* (acgnp) Do not sleep */
#define VM_ALLOC_COUNT_MAX 0xffff
Index: sys/vm/vm_page.c
===================================================================
--- sys/vm/vm_page.c
+++ sys/vm/vm_page.c
@@ -4756,12 +4756,11 @@
/*
* vm_page_grab_sleep
*
- * Sleep for busy according to VM_ALLOC_ parameters. Returns true
- * if the caller should retry and false otherwise.
+ * Sleep for busy according to VM_ALLOC_ parameters. Returns true if
+ * allocflags permits waiting and false otherwise.
*
- * If the object is locked on entry the object will be unlocked with
- * false returns and still locked but possibly having been dropped
- * with true returns.
+ * The object may be locked on entry. If so, its lock will be released and
+ * reacquired if the routine sleeps.
*/
static bool
vm_page_grab_sleep(vm_object_t object, vm_page_t m, vm_pindex_t pindex,
@@ -4781,8 +4780,6 @@
if (_vm_page_busy_sleep(object, m, pindex, wmesg, allocflags, locked) &&
locked)
VM_OBJECT_WLOCK(object);
- if ((allocflags & VM_ALLOC_WAITFAIL) != 0)
- return (false);
return (true);
}
@@ -4791,18 +4788,23 @@
* Assert that the grab flags are valid.
*/
static inline void
-vm_page_grab_check(int allocflags)
+_vm_page_grab_check(int allocflags, const char *func __diagused)
{
KASSERT((allocflags & VM_ALLOC_NOBUSY) == 0 ||
(allocflags & VM_ALLOC_WIRED) != 0,
- ("vm_page_grab*: the pages must be busied or wired"));
+ ("%s: the pages must be busied or wired", func));
KASSERT((allocflags & VM_ALLOC_SBUSY) == 0 ||
(allocflags & VM_ALLOC_IGN_SBUSY) != 0,
- ("vm_page_grab*: VM_ALLOC_SBUSY/VM_ALLOC_IGN_SBUSY mismatch"));
+ ("%s: VM_ALLOC_SBUSY/VM_ALLOC_IGN_SBUSY mismatch", func));
+
+ KASSERT((allocflags & VM_ALLOC_WAITFAIL) == 0,
+ ("%s: Invalid waitfail flag", func));
}
+#define vm_page_grab_check(...) _vm_page_grab_check(__VA_ARGS__, __func__)
+
/*
* Calculate the page allocation flags for grab.
*/
@@ -4812,8 +4814,8 @@
int pflags;
pflags = allocflags &
- ~(VM_ALLOC_NOWAIT | VM_ALLOC_WAITOK | VM_ALLOC_WAITFAIL |
- VM_ALLOC_NOBUSY | VM_ALLOC_IGN_SBUSY);
+ ~(VM_ALLOC_NOWAIT | VM_ALLOC_WAITOK | VM_ALLOC_NOBUSY |
+ VM_ALLOC_IGN_SBUSY);
if ((allocflags & VM_ALLOC_NOWAIT) == 0)
pflags |= VM_ALLOC_WAITFAIL;
if ((allocflags & VM_ALLOC_IGN_SBUSY) != 0)
@@ -4855,7 +4857,7 @@
return (NULL);
m = vm_page_alloc(object, pindex, vm_page_grab_pflags(allocflags));
if (m == NULL) {
- if ((allocflags & (VM_ALLOC_NOWAIT | VM_ALLOC_WAITFAIL)) != 0)
+ if ((allocflags & VM_ALLOC_NOWAIT) != 0)
return (NULL);
goto retrylookup;
}
@@ -4954,11 +4956,8 @@
vm_page_t ma[VM_INITIAL_PAGEIN];
int after, i, pflags, rv;
- KASSERT((allocflags & VM_ALLOC_SBUSY) == 0 ||
- (allocflags & VM_ALLOC_IGN_SBUSY) != 0,
- ("vm_page_grab_valid: VM_ALLOC_SBUSY/VM_ALLOC_IGN_SBUSY mismatch"));
- KASSERT((allocflags &
- (VM_ALLOC_NOWAIT | VM_ALLOC_WAITFAIL | VM_ALLOC_ZERO)) == 0,
+ vm_page_grab_check(allocflags);
+ KASSERT((allocflags & (VM_ALLOC_NOWAIT | VM_ALLOC_ZERO)) == 0,
("vm_page_grab_valid: Invalid flags 0x%X", allocflags));
VM_OBJECT_ASSERT_WLOCKED(object);
pflags = allocflags & ~(VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY |
@@ -5116,12 +5115,8 @@
int flags;
int error;
- KASSERT((allocflags & VM_ALLOC_SBUSY) == 0 ||
- (allocflags & VM_ALLOC_IGN_SBUSY) != 0,
- ("vm_page_grab_valid_unlocked: VM_ALLOC_SBUSY/VM_ALLOC_IGN_SBUSY "
- "mismatch"));
- KASSERT((allocflags &
- (VM_ALLOC_NOWAIT | VM_ALLOC_WAITFAIL | VM_ALLOC_ZERO)) == 0,
+ vm_page_grab_check(allocflags);
+ KASSERT((allocflags & (VM_ALLOC_NOWAIT | VM_ALLOC_ZERO)) == 0,
("vm_page_grab_valid_unlocked: Invalid flags 0x%X", allocflags));
/*
@@ -5218,8 +5213,7 @@
m = vm_page_alloc_after(object, pindex + i,
pflags | VM_ALLOC_COUNT(count - i), mpred);
if (m == NULL) {
- if ((allocflags & (VM_ALLOC_NOWAIT |
- VM_ALLOC_WAITFAIL)) != 0)
+ if ((allocflags & VM_ALLOC_NOWAIT) != 0)
break;
goto retrylookup;
}

File Metadata

Mime Type
text/plain
Expires
Tue, Jan 20, 1:08 AM (18 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27757250
Default Alt Text
D49391.id152556.diff (6 KB)

Event Timeline