xref: /freebsd/share/man/man9/vm_page_alloc.9 (revision c46221d700b9acf486eba10d0f68cf73f6ad46c8)
16484c361SAlfred Perlstein.\"
26484c361SAlfred Perlstein.\" Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved.
36484c361SAlfred Perlstein.\"
46484c361SAlfred Perlstein.\" Redistribution and use in source and binary forms, with or without
56484c361SAlfred Perlstein.\" modification, are permitted provided that the following conditions
66484c361SAlfred Perlstein.\" are met:
76484c361SAlfred Perlstein.\" 1. Redistributions of source code must retain the above copyright
86484c361SAlfred Perlstein.\"    notice(s), this list of conditions and the following disclaimer as
96484c361SAlfred Perlstein.\"    the first lines of this file unmodified other than the possible
106484c361SAlfred Perlstein.\"    addition of one or more copyright notices.
116484c361SAlfred Perlstein.\" 2. Redistributions in binary form must reproduce the above copyright
126484c361SAlfred Perlstein.\"    notice(s), this list of conditions and the following disclaimer in the
136484c361SAlfred Perlstein.\"    documentation and/or other materials provided with the distribution.
146484c361SAlfred Perlstein.\"
156484c361SAlfred Perlstein.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
166484c361SAlfred Perlstein.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
176484c361SAlfred Perlstein.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
186484c361SAlfred Perlstein.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
196484c361SAlfred Perlstein.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
206484c361SAlfred Perlstein.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
216484c361SAlfred Perlstein.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
226484c361SAlfred Perlstein.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
236484c361SAlfred Perlstein.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
246484c361SAlfred Perlstein.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
256484c361SAlfred Perlstein.\" DAMAGE.
266484c361SAlfred Perlstein.\"
276484c361SAlfred Perlstein.\" $FreeBSD$
286484c361SAlfred Perlstein.\"
29c46221d7SKonstantin Belousov.Dd February 27, 2010
306484c361SAlfred Perlstein.Dt VM_PAGE_ALLOC 9
316484c361SAlfred Perlstein.Os
326484c361SAlfred Perlstein.Sh NAME
336484c361SAlfred Perlstein.Nm vm_page_alloc
3463856f96SRuslan Ermilov.Nd "allocate a page for a"
3563856f96SRuslan Ermilov.Vt vm_object
366484c361SAlfred Perlstein.Sh SYNOPSIS
376484c361SAlfred Perlstein.In sys/param.h
386484c361SAlfred Perlstein.In vm/vm.h
396484c361SAlfred Perlstein.In vm/vm_page.h
406484c361SAlfred Perlstein.Ft vm_page_t
416484c361SAlfred Perlstein.Fn vm_page_alloc "vm_object_t object" "vm_pindex_t pindex" "int page_req"
426484c361SAlfred Perlstein.Sh DESCRIPTION
436484c361SAlfred PerlsteinThe
446484c361SAlfred Perlstein.Fn vm_page_alloc
452e693d19SChad Davidfunction allocates a page at
466484c361SAlfred Perlstein.Fa pindex
472e693d19SChad Davidwithin
486484c361SAlfred Perlstein.Fa object .
492e693d19SChad DavidIt is assumed that a page has not already been allocated at
502e693d19SChad David.Fa pindex .
51c46221d7SKonstantin BelousovThe page returned is inserted into the object, unless
52c46221d7SKonstantin Belousov.Dv VM_ALLOC_NOOBJ
53c46221d7SKonstantin Belousovis specified in the
54c46221d7SKonstantin Belousov.Fa page_req ,
55c46221d7SKonstantin Belousovbut is not inserted into a pmap.
56c46221d7SKonstantin BelousovThe page may exists in the vm object cache, in which case it will
57c46221d7SKonstantin Belousovbe reactivated instead, moving from the cache into the object page list.
586484c361SAlfred Perlstein.Pp
596484c361SAlfred Perlstein.Fn vm_page_alloc
60c46221d7SKonstantin Belousovwill not sleep.
616484c361SAlfred Perlstein.Pp
626484c361SAlfred PerlsteinIts arguments are:
636484c361SAlfred Perlstein.Bl -tag -width ".Fa page_req"
646484c361SAlfred Perlstein.It Fa object
656484c361SAlfred PerlsteinThe VM object to allocate the page for.
66c46221d7SKonstantin BelousovThe
67c46221d7SKonstantin Belousov.Fa object
68c46221d7SKonstantin Belousovmust be locked if
69c46221d7SKonstantin Belousov.Dv VM_ALLOC_NOOBJ
70c46221d7SKonstantin Belousovis not specified.
716484c361SAlfred Perlstein.It Fa pindex
722e693d19SChad DavidThe index into the object at which the page should be inserted.
736484c361SAlfred Perlstein.It Fa page_req
746484c361SAlfred PerlsteinA flag indicating how the page should be allocated.
756484c361SAlfred Perlstein.Bl -tag -width ".Dv VM_ALLOC_INTERRUPT"
766484c361SAlfred Perlstein.It Dv VM_ALLOC_NORMAL
776484c361SAlfred PerlsteinThe page should be allocated with no special treatment.
786484c361SAlfred Perlstein.It Dv VM_ALLOC_SYSTEM
792e693d19SChad DavidThe page can be allocated if the cache queue is empty and the free
802e693d19SChad Davidpage count is above the interrupt reserved water mark.
812e693d19SChad DavidIf
822e693d19SChad David.Dv VM_ALLOC_INTERRUPT
8363856f96SRuslan Ermilovis set, the page can be allocated as long as the free page count is
842e693d19SChad Davidgreater than zero.
852e693d19SChad DavidThis flag should be used only when the system really needs the page.
866484c361SAlfred Perlstein.It Dv VM_ALLOC_INTERRUPT
876484c361SAlfred Perlstein.Fn vm_page_alloc
886484c361SAlfred Perlsteinis being called during an interrupt and therefore the cache cannot
896484c361SAlfred Perlsteinbe accessed.
906484c361SAlfred PerlsteinThe page will only be returned successfully if the free count is greater
916484c361SAlfred Perlsteinthan zero.
926484c361SAlfred Perlstein.It Dv VM_ALLOC_ZERO
936bcda17fSBruce M SimpsonIndicate a preference for a pre-zeroed page.
946bcda17fSBruce M SimpsonThere is no guarantee that the page thus returned will be zeroed, but
95c46221d7SKonstantin Belousovit will be marked by
96c46221d7SKonstantin Belousov.Dv PG_ZERO
97c46221d7SKonstantin Belousovflag if it is zeroed.
986bcda17fSBruce M Simpson.It Dv VM_ALLOC_NOOBJ
99c46221d7SKonstantin BelousovDo not associate the allocated page with a vm object.
100c46221d7SKonstantin BelousovThe
101c46221d7SKonstantin Belousov.Fa object
102c46221d7SKonstantin Belousovargument is ignored.
103c46221d7SKonstantin Belousov.It Dv VM_ALLOC_NOBUSY
104c46221d7SKonstantin BelousovThe page returned will not be busied.
105c46221d7SKonstantin Belousov.It Dv VM_ALLOC_WIRED
106c46221d7SKonstantin BelousovThe returned page is wired.
107c46221d7SKonstantin Belousov.It Dv VM_ALLOC_IFNOTCACHED
108c46221d7SKonstantin BelousovOnly allocate the page if it is not cached in the
109c46221d7SKonstantin Belousov.Fa object .
110c46221d7SKonstantin BelousovIf the page at the specified
111c46221d7SKonstantin Belousov.Fa pindex
112c46221d7SKonstantin Belousovis cached, NULL is returned instead.
1136484c361SAlfred Perlstein.El
114bf7f20c2SRuslan Ermilov.El
1156484c361SAlfred Perlstein.Sh RETURN VALUES
1162e693d19SChad DavidThe
1176484c361SAlfred Perlstein.Vt vm_page_t
1182e693d19SChad Davidthat was allocated is returned if successful; otherwise,
1196484c361SAlfred Perlstein.Dv NULL
1206484c361SAlfred Perlsteinis returned.
1216484c361SAlfred Perlstein.Sh NOTES
1226484c361SAlfred PerlsteinThe pager process is always upgraded to
1236484c361SAlfred Perlstein.Dv VM_ALLOC_SYSTEM
1246484c361SAlfred Perlsteinunless
1256484c361SAlfred Perlstein.Dv VM_ALLOC_INTERRUPT
1266484c361SAlfred Perlsteinis set.
1276484c361SAlfred Perlstein.Sh AUTHORS
128571dba6eSHiten PandyaThis manual page was written by
1296484c361SAlfred Perlstein.An Chad David Aq davidc@acns.ab.ca .
130