]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - share/man/man9/vm_page_alloc.9
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / share / man / man9 / vm_page_alloc.9
1 .\"
2 .\" Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice(s), this list of conditions and the following disclaimer as
9 .\"    the first lines of this file unmodified other than the possible
10 .\"    addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice(s), this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
16 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 .\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
19 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25 .\" DAMAGE.
26 .\"
27 .\" $FreeBSD$
28 .\"
29 .Dd July 3, 2010
30 .Dt VM_PAGE_ALLOC 9
31 .Os
32 .Sh NAME
33 .Nm vm_page_alloc
34 .Nd "allocate a page for a"
35 .Vt vm_object
36 .Sh SYNOPSIS
37 .In sys/param.h
38 .In vm/vm.h
39 .In vm/vm_page.h
40 .Ft vm_page_t
41 .Fn vm_page_alloc "vm_object_t object" "vm_pindex_t pindex" "int req"
42 .Sh DESCRIPTION
43 The
44 .Fn vm_page_alloc
45 function allocates a page at
46 .Fa pindex
47 within
48 .Fa object .
49 It is assumed that a page has not already been allocated at
50 .Fa pindex .
51 The page returned is inserted into the object, unless
52 .Dv VM_ALLOC_NOOBJ
53 is specified in the
54 .Fa req .
55 The page may exist in the vm object cache, in which case it will
56 be reactivated instead, moving from the cache into the object page list.
57 .Pp
58 .Fn vm_page_alloc
59 will not sleep.
60 .Pp
61 Its arguments are:
62 .Bl -tag -width ".Fa object"
63 .It Fa object
64 The VM object to allocate the page for.
65 The
66 .Fa object
67 must be locked if
68 .Dv VM_ALLOC_NOOBJ
69 is not specified.
70 .It Fa pindex
71 The index into the object at which the page should be inserted.
72 .It Fa req
73 The bitwise-inclusive OR of a class and any optional flags indicating
74 how the page should be allocated.
75 .Pp
76 Exactly one of the following classes must be specified:
77 .Bl -tag -width ".Dv VM_ALLOC_INTERRUPT"
78 .It Dv VM_ALLOC_NORMAL
79 The page should be allocated with no special treatment.
80 .It Dv VM_ALLOC_SYSTEM
81 The page can be allocated if the cache is empty and the free
82 page count is above the interrupt reserved water mark.
83 This flag should be used only when the system really needs the page.
84 .It Dv VM_ALLOC_INTERRUPT
85 .Fn vm_page_alloc
86 is being called during an interrupt.
87 A page will be returned successfully if the free page count is greater
88 than zero.
89 .El
90 .Pp
91 The optional flags are:
92 .Bl -tag -width ".Dv VM_ALLOC_IFNOTCACHED"
93 .It Dv VM_ALLOC_ZERO
94 Indicate a preference for a pre-zeroed page.
95 There is no guarantee that the returned page will be zeroed, but it
96 will have the
97 .Dv PG_ZERO
98 flag set if it is zeroed.
99 .It Dv VM_ALLOC_NOOBJ
100 Do not associate the allocated page with a vm object.
101 The
102 .Fa object
103 argument is ignored.
104 .It Dv VM_ALLOC_NOBUSY
105 The returned page will not have the
106 .Dv VPO_BUSY
107 flag set.
108 .It Dv VM_ALLOC_WIRED
109 The returned page will be wired.
110 .It Dv VM_ALLOC_IFCACHED
111 Allocate the page only if it is cached.
112 Otherwise, return
113 .Dv NULL .
114 .It Dv VM_ALLOC_IFNOTCACHED
115 Only allocate the page if it is not cached in the
116 .Fa object .
117 If the page at the specified
118 .Fa pindex
119 is cached, NULL is returned instead.
120 .El
121 .El
122 .Sh RETURN VALUES
123 The
124 .Vt vm_page_t
125 that was allocated is returned if successful; otherwise,
126 .Dv NULL
127 is returned.
128 .Sh NOTES
129 The pager process is always upgraded to
130 .Dv VM_ALLOC_SYSTEM
131 unless
132 .Dv VM_ALLOC_INTERRUPT
133 is set.
134 .Sh AUTHORS
135 This manual page was written by
136 .An Chad David Aq davidc@acns.ab.ca .