Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137871304
D49391.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D49391.diff
View Options
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -462,13 +462,15 @@
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.
+ * vm_page allocation arguments for the functions vm_page_alloc(),
+ * vm_page_alloc_contig(), vm_page_alloc_noobj(), vm_page_grab(), and
+ * vm_page_grab_pages(). Each function supports only a subset of the flags.
+ * 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.
+ * The meaning of VM_ALLOC_ZERO varies: vm_page_alloc_noobj(), vm_page_grab(),
+ * and vm_page_grab_pages() guarantee that the returned pages are zeroed; in
+ * contrast vm_page_alloc() and vm_page_alloc_contig() do not, leaving it to
+ * the caller to test the page's flags for PG_ZERO.
*
* Bits 0 - 1 define class.
* Bits 2 - 15 dedicated for flags.
@@ -476,7 +478,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.
@@ -485,26 +487,26 @@
#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_WAITFAIL 0x0010 /* (acn) Sleep and return error */
+#define VM_ALLOC_WAITOK 0x0008 /* (gnp) Sleep and retry */
+#define VM_ALLOC_WAITFAIL 0x0010 /* (acgnp) Sleep and return error */
#define VM_ALLOC_WIRED 0x0020 /* (acgnp) Allocate a wired page */
#define VM_ALLOC_ZERO 0x0040 /* (acgnp) Allocate a zeroed page */
#define VM_ALLOC_NORECLAIM 0x0080 /* (c) Do not reclaim after failure */
-#define VM_ALLOC_NOFREE 0x0100 /* (an) Page will never be released */
+#define VM_ALLOC_NOFREE 0x0100 /* (agnp) Page will never be freed */
#define VM_ALLOC_NOBUSY 0x0200 /* (acgp) Do not excl busy the page */
-#define VM_ALLOC_NOCREAT 0x0400 /* (gp) Don't create a page */
+#define VM_ALLOC_NOCREAT 0x0400 /* (gp) Do not allocate 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_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy state */
+#define VM_ALLOC_NODUMP 0x2000 /* (acgnp) Do not 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
#define VM_ALLOC_COUNT_SHIFT 16
#define VM_ALLOC_COUNT_MASK (VM_ALLOC_COUNT(VM_ALLOC_COUNT_MAX))
-#define VM_ALLOC_COUNT(count) ({ \
- KASSERT((count) <= VM_ALLOC_COUNT_MAX, \
- ("%s: invalid VM_ALLOC_COUNT value", __func__)); \
- (count) << VM_ALLOC_COUNT_SHIFT; \
+#define VM_ALLOC_COUNT(count) ({ /* (acgn) Additional pages */ \
+ KASSERT((count) <= VM_ALLOC_COUNT_MAX, \
+ ("%s: invalid VM_ALLOC_COUNT value", __func__)); \
+ (count) << VM_ALLOC_COUNT_SHIFT; \
})
#ifdef M_NOWAIT
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -1983,7 +1983,10 @@
* intends to allocate
* VM_ALLOC_NOBUSY do not exclusive busy the page
* VM_ALLOC_NODUMP do not include the page in a kernel core dump
+ * VM_ALLOC_NOFREE page will never be freed
+ * VM_ALLOC_NOWAIT ignored (default behavior)
* VM_ALLOC_SBUSY shared busy the allocated page
+ * VM_ALLOC_WAITFAIL in case of failure, sleep before returning
* VM_ALLOC_WIRED wire the allocated page
* VM_ALLOC_ZERO prefer a zeroed page
*/
@@ -2081,11 +2084,12 @@
vm_page_t m;
int flags;
-#define VPA_FLAGS (VM_ALLOC_CLASS_MASK | VM_ALLOC_WAITFAIL | \
- VM_ALLOC_NOWAIT | VM_ALLOC_NOBUSY | \
- VM_ALLOC_SBUSY | VM_ALLOC_WIRED | \
- VM_ALLOC_NODUMP | VM_ALLOC_ZERO | \
- VM_ALLOC_NOFREE | VM_ALLOC_COUNT_MASK)
+#define VM_ALLOC_COMMON (VM_ALLOC_CLASS_MASK | VM_ALLOC_NODUMP | \
+ VM_ALLOC_NOWAIT | VM_ALLOC_WAITFAIL | \
+ VM_ALLOC_WIRED | VM_ALLOC_ZERO)
+#define VPA_FLAGS (VM_ALLOC_COMMON | VM_ALLOC_COUNT_MASK | \
+ VM_ALLOC_NOBUSY | VM_ALLOC_NOFREE | \
+ VM_ALLOC_SBUSY)
KASSERT((req & ~VPA_FLAGS) == 0,
("invalid request %#x", req));
KASSERT(((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) !=
@@ -2234,15 +2238,18 @@
*
* allocation classes:
* VM_ALLOC_NORMAL normal process request
- * VM_ALLOC_SYSTEM system *really* needs a page
+ * VM_ALLOC_SYSTEM system *really* needs the pages
* VM_ALLOC_INTERRUPT interrupt time request
*
* optional allocation flags:
- * VM_ALLOC_NOBUSY do not exclusive busy the page
- * VM_ALLOC_NODUMP do not include the page in a kernel core dump
- * VM_ALLOC_SBUSY shared busy the allocated page
- * VM_ALLOC_WIRED wire the allocated page
- * VM_ALLOC_ZERO prefer a zeroed page
+ * VM_ALLOC_NOBUSY do not exclusive busy the pages
+ * VM_ALLOC_NODUMP do not include the pages in a kernel core dump
+ * VM_ALLOC_NORECLAIM do not reclaim after initial failure
+ * VM_ALLOC_NOWAIT ignored (default behavior)
+ * VM_ALLOC_SBUSY shared busy the allocated pages
+ * VM_ALLOC_WAITFAIL in case of failure, sleep before returning
+ * VM_ALLOC_WIRED wire the allocated pages
+ * VM_ALLOC_ZERO prefer zeroed pages
*/
vm_page_t
vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req,
@@ -2321,7 +2328,9 @@
vm_page_t m, m_ret, mpred;
u_int busy_lock, flags, oflags;
-#define VPAC_FLAGS (VPA_FLAGS | VM_ALLOC_NORECLAIM)
+#define VPAC_FLAGS (VM_ALLOC_COMMON | VM_ALLOC_COUNT_MASK | \
+ VM_ALLOC_NOBUSY | VM_ALLOC_NORECLAIM | \
+ VM_ALLOC_SBUSY)
KASSERT((req & ~VPAC_FLAGS) == 0,
("invalid request %#x", req));
KASSERT(((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) !=
@@ -2422,11 +2431,8 @@
vm_page_t m;
int flags;
-#define VPAN_FLAGS (VM_ALLOC_CLASS_MASK | VM_ALLOC_WAITFAIL | \
- VM_ALLOC_NOWAIT | VM_ALLOC_WAITOK | \
- VM_ALLOC_NOBUSY | VM_ALLOC_WIRED | \
- VM_ALLOC_NODUMP | VM_ALLOC_ZERO | \
- VM_ALLOC_NOFREE | VM_ALLOC_COUNT_MASK)
+#define VPAN_FLAGS (VM_ALLOC_COMMON | VM_ALLOC_COUNT_MASK | \
+ VM_ALLOC_NOFREE | VM_ALLOC_WAITOK)
KASSERT((req & ~VPAN_FLAGS) == 0,
("invalid request %#x", req));
@@ -2624,15 +2630,13 @@
vm_page_t m, m_ret;
u_int flags;
-#define VPANC_FLAGS (VPAN_FLAGS | VM_ALLOC_NORECLAIM)
+#define VPANC_FLAGS (VM_ALLOC_COMMON | VM_ALLOC_COUNT_MASK | \
+ VM_ALLOC_NORECLAIM | VM_ALLOC_WAITOK)
KASSERT((req & ~VPANC_FLAGS) == 0,
("invalid request %#x", req));
KASSERT((req & (VM_ALLOC_WAITOK | VM_ALLOC_NORECLAIM)) !=
(VM_ALLOC_WAITOK | VM_ALLOC_NORECLAIM),
("invalid request %#x", req));
- KASSERT(((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) !=
- (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)),
- ("invalid request %#x", req));
KASSERT(npages > 0, ("vm_page_alloc_contig: npages is zero"));
while ((m_ret = vm_page_find_contig_domain(domain, req, npages,
@@ -5141,15 +5145,20 @@
* allocation classes:
* VM_ALLOC_NORMAL normal process request
* VM_ALLOC_SYSTEM system *really* needs the pages
+ * VM_ALLOC_INTERRUPT interrupt time request
*
* The caller must always specify that the pages are to be busied and/or
* wired.
*
* optional allocation flags:
* VM_ALLOC_IGN_SBUSY do not sleep on soft busy pages
- * VM_ALLOC_NOBUSY do not exclusive busy the page
+ * VM_ALLOC_NOBUSY do not exclusive busy the pages
+ * VM_ALLOC_NODUMP do not include the pages in a kernel core dump
+ * VM_ALLOC_NOFREE pages will never be freed
* VM_ALLOC_NOWAIT do not sleep
- * VM_ALLOC_SBUSY set page to sbusy state
+ * VM_ALLOC_SBUSY set pages to sbusy state
+ * VM_ALLOC_WAITFAIL in case of failure, sleep before returning
+ * VM_ALLOC_WAITOK ignored (default behavior)
* VM_ALLOC_WIRED wire the pages
* VM_ALLOC_ZERO zero and validate any invalid pages
*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 27, 4:45 PM (15 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26259235
Default Alt Text
D49391.diff (8 KB)
Attached To
Mode
D49391: vm_page: update legend documenting allocation
Attached
Detach File
Event Timeline
Log In to Comment