xref: /dragonfly/share/man/man9/vm_page_alloc.9 (revision e98bdfd3)
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: src/share/man/man9/vm_page_alloc.9,v 1.6 2005/06/28 20:15:18 hmp Exp $
28.\"
29.Dd December 19, 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 page_req"
42.Sh DESCRIPTION
43The
44.Fn vm_page_alloc
45function allocates a page at
46.Fa pindex
47within
48.Fa object .
49It is assumed that a page has not already been allocated at
50.Fa pindex .
51The page returned is inserted into the object, but is not inserted
52into the pmap.
53The vm_object must be locked on entry.
54.Pp
55.Fn vm_page_alloc
56will not block.
57.Pp
58Its arguments are:
59.Bl -tag -width ".Fa page_req"
60.It Fa object
61The VM object to allocate the page for.
62.It Fa pindex
63The index into the object at which the page should be inserted.
64.It Fa page_req
65A flag indicating how the page should be allocated.
66.Bl -tag -width ".Dv VM_ALLOC_INTERRUPT"
67.It Dv VM_ALLOC_NORMAL
68The page should be allocated with no special treatment.
69.It Dv VM_ALLOC_QUICK
70The page should only be allocated from the free queue.
71.It Dv VM_ALLOC_SYSTEM
72The page can be allocated if the cache queue is empty and the free
73page count is above the interrupt reserved water mark.
74If
75.Dv VM_ALLOC_INTERRUPT
76is set, the page can be allocated as long as the free page count is
77greater than zero.
78This flag should be used only when the system really needs the page.
79.It Dv VM_ALLOC_INTERRUPT
80.Fn vm_page_alloc
81is being called during an interrupt and therefore the cache cannot
82be accessed.
83The page will only be returned successfully if the free count is greater
84than zero.
85.It Dv VM_ALLOC_ZERO
86Indicate a preference for a pre-zeroed page.
87There is no guarantee that the page thus returned will be zeroed, but
88it will be marked as such.
89.El
90.El
91.Sh RETURN VALUES
92The
93.Vt vm_page_t
94that was allocated is returned if successful; otherwise,
95.Dv NULL
96is returned.
97The returned page will be marked
98.Dv PG_BUSY .
99.Sh AUTHORS
100This manual page was written by
101.An Chad David Aq Mt davidc@acns.ab.ca .
102