UVM_PAGEALLOC(9)

NAME
uvm_pagealloc, uvm_pagerealloc, uvm_pagefree, uvm_pglistalloc, uvm_pglistfree, uvm_page_physload - physical memory allocator

SYNOPSIS
#include <sys/param.h>
#include <uvm/uvm.h>
struct vm_page *
uvm_pagealloc(struct uvm_object *uobj, voff_t off, struct vm_anon *anon, int flags);
void
uvm_pagerealloc(struct vm_page *pg, struct uvm_object *newobj, voff_t newoff);
void
uvm_pagefree(struct vm_page *pg);
int
uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, paddr_t boundary, struct pglist *rlist, int nsegs, int flags);
void
uvm_pglistfree(struct pglist *list);
void
uvm_page_physload(paddr_t start, paddr_t end, paddr_t avail_start, paddr_t avail_end, int free_list);

DESCRIPTION
The uvm_pagealloc() function allocates a page of memory at virtual address off in either the object uobj or the anonymous memory anon, or returns NULL if no pages are free. Only one of anon and uobj can be non NULL. The flags can be any of:

    #define UVM_PGA_USERESERVE      0x0001  /* ok to use reserve pages */
    #define UVM_PGA_ZERO            0x0002  /* returned page must be zeroed */

The UVM_PGA_USERESERVE flag means to allocate a page even if that will result in the number of free pages being lower than uvmexp.reserve_pagedaemon (if the current thread is the pagedaemon) or uvmexp.reserve_kernel (if the current thread is not the pagedaemon). The UVM_PGA_ZERO flag causes the returned page to be filled with zeroes, either by allocating it from a pool of pre-zeroed pages or by zeroing it in-line as necessary.

The uvm_pagerealloc() function reallocates page pg to a new object newobj, at a new offset newoff.

The uvm_pagefree() function frees the physical page pg.

The uvm_pglistalloc() function allocates a list of pages for size size byte under various constraints. low and high describe the lowest and highest addresses acceptable for the list. If alignment is non-zero, it describes the required alignment of the list, in power-of-two notation. If boundary is non-zero, no segment of the list may cross this power-of-two boundary, relative to zero. nsegs is the maximum number of physically contiguous segments. The allocated memory is returned in the rlist list. The flags can be any of:

    #define UVM_PLA_WAITOK	0x0001	/* may sleep */
    #define UVM_PLA_NOWAIT	0x0002	/* can't sleep */
    #define UVM_PLA_ZERO	0x0004	/* zero all pages before returning */

The UVM_PLA_WAITOK flag means that the function may sleep while trying to allocate the list of pages (this is currently ignored). Conversely, the UVM_PLA_NOWAIT flag signifies that the function may not sleep while allocating. It is an error not to provide one of the above flags. Optionally, one may also specify the UVM_PLA_ZERO flag to receive zeroed memory in the page list.

The uvm_pglistfree() function frees the list of pages pointed to by list.

The uvm_page_physload() function loads physical memory segments into VM space on the specified free_list. uvm_page_physload() must be called at system boot time to set up physical memory management pages. The arguments describe the start and end of the physical addresses of the segment, and the available start and end addresses of pages not already in use.