xref: /freebsd/share/man/man9/vm_page_alloc.9 (revision bf7f20c2b6525c652039ed567af156fe2fbe19be)
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.\"
296484c361SAlfred Perlstein.Dd July 13, 2001
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 .
512e693d19SChad DavidThe page returned is inserted into the object, but is not inserted
522e693d19SChad Davidinto the pmap.
536484c361SAlfred Perlstein.Pp
546484c361SAlfred Perlstein.Fn vm_page_alloc
552e693d19SChad Davidwill not block.
566484c361SAlfred Perlstein.Pp
576484c361SAlfred PerlsteinIts arguments are:
586484c361SAlfred Perlstein.Bl -tag -width ".Fa page_req"
596484c361SAlfred Perlstein.It Fa object
606484c361SAlfred PerlsteinThe VM object to allocate the page for.
616484c361SAlfred Perlstein.It Fa pindex
622e693d19SChad DavidThe index into the object at which the page should be inserted.
636484c361SAlfred Perlstein.It Fa page_req
646484c361SAlfred PerlsteinA flag indicating how the page should be allocated.
656484c361SAlfred Perlstein.Bl -tag -width ".Dv VM_ALLOC_INTERRUPT"
666484c361SAlfred Perlstein.It Dv VM_ALLOC_NORMAL
676484c361SAlfred PerlsteinThe page should be allocated with no special treatment.
686484c361SAlfred Perlstein.It Dv VM_ALLOC_SYSTEM
692e693d19SChad DavidThe page can be allocated if the cache queue is empty and the free
702e693d19SChad Davidpage count is above the interrupt reserved water mark.
712e693d19SChad DavidIf
722e693d19SChad David.Dv VM_ALLOC_INTERRUPT
7363856f96SRuslan Ermilovis set, the page can be allocated as long as the free page count is
742e693d19SChad Davidgreater than zero.
752e693d19SChad DavidThis flag should be used only when the system really needs the page.
766484c361SAlfred Perlstein.It Dv VM_ALLOC_INTERRUPT
776484c361SAlfred Perlstein.Fn vm_page_alloc
786484c361SAlfred Perlsteinis being called during an interrupt and therefore the cache cannot
796484c361SAlfred Perlsteinbe accessed.
806484c361SAlfred PerlsteinThe page will only be returned successfully if the free count is greater
816484c361SAlfred Perlsteinthan zero.
826484c361SAlfred Perlstein.It Dv VM_ALLOC_ZERO
836bcda17fSBruce M SimpsonIndicate a preference for a pre-zeroed page.
846bcda17fSBruce M SimpsonThere is no guarantee that the page thus returned will be zeroed, but
856bcda17fSBruce M Simpsonit will be marked as such.
866bcda17fSBruce M Simpson.It Dv VM_ALLOC_NOOBJ
876bcda17fSBruce M SimpsonThe page is associated with an unmanaged memory region, that is, there
886bcda17fSBruce M Simpsonis no backing VM object.
896bcda17fSBruce M SimpsonThis is typically used to allocate pages within the kernel virtual
906bcda17fSBruce M Simpsonaddress space.
916484c361SAlfred Perlstein.El
92bf7f20c2SRuslan Ermilov.El
936484c361SAlfred Perlstein.Sh RETURN VALUES
942e693d19SChad DavidThe
956484c361SAlfred Perlstein.Vt vm_page_t
962e693d19SChad Davidthat was allocated is returned if successful; otherwise,
976484c361SAlfred Perlstein.Dv NULL
986484c361SAlfred Perlsteinis returned.
996484c361SAlfred Perlstein.Sh NOTES
1006484c361SAlfred PerlsteinThe pager process is always upgraded to
1016484c361SAlfred Perlstein.Dv VM_ALLOC_SYSTEM
1026484c361SAlfred Perlsteinunless
1036484c361SAlfred Perlstein.Dv VM_ALLOC_INTERRUPT
1046484c361SAlfred Perlsteinis set.
1056484c361SAlfred Perlstein.Sh AUTHORS
1066484c361SAlfred PerlsteinThis man page was written by
1076484c361SAlfred Perlstein.An Chad David Aq davidc@acns.ab.ca .
108