Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
UVM_INIT(9)	       FreeBSD Kernel Developer's Manual	   UVM_INIT(9)

NAME
     uvm_init, uvm_init_limits,	uvm_setpagesize, uvm_swap_init,	uvm_io,
     uvm_pageout, uao_create, uao_detach, uao_reference, uvm_chgkprot,
     uvm_kernacc, uvm_meter, uvm_sysctl, uvm_grow, uvm_coredump	-- virtual
     memory system external interface

SYNOPSIS
     #include <sys/param.h>
     #include <uvm/uvm.h>

DESCRIPTION
     The UVM virtual memory system manages access to the computer's memory re-
     sources.  User processes and the kernel access these resources through
     UVM's external interface.	UVM's external interface includes functions
     that:

     -	 initialise UVM	subsystems
     -	 manage	virtual	address	spaces
     -	 resolve page faults
     -	 memory	map files and devices
     -	 perform uio-based I/O to virtual memory
     -	 allocate and free kernel virtual memory
     -	 allocate and free physical memory

     In	addition to exporting these services, UVM has two kernel-level pro-
     cesses: pagedaemon	and swapper.  The pagedaemon process sleeps until
     physical memory becomes scarce.  When that	happens, pagedaemon is awoken.
     It	scans physical memory, paging out and freeing memory that has not been
     recently used.  The swapper process swaps in runnable processes that are
     currently swapped out, if there is	room.

     UVM has a machine independent and a machine dependent layer.  See pmap(9)
     for the machine dependent layer.

INITIALISATION
     void uvm_init(void) void uvm_init_limits(struct plimit *limit0) void
     uvm_setpagesize(void) void	uvm_swap_init(void)

     The uvm_init() function sets up the UVM system at system boot time, after
     the copyright has been printed.  It initialises global state, the page,
     map, kernel virtual memory	state, machine-dependent physical map, kernel
     memory allocator, pager and anonymous memory subsystems, and then enables
     paging of kernel objects.	uvm_init() must	be called after	machine-depen-
     dent code has registered some free	RAM with the uvm_page_physload() func-
     tion.

     The uvm_init_limits() function initialises	process	limits in the given
     limit structure.  This is for use by the system startup for process zero,
     before any	other processes	are created.

     The uvm_setpagesize() function initialises	the uvmexp members pagesize
     (if not already done by machine-dependent code), pageshift	and pagemask.
     It	should be called by machine-dependent code early in the	pmap_init(9)
     call.

     The uvm_swap_init() function initialises the swap subsystem.

VIRTUAL	MEMORY I/O
     int uvm_io(vm_map_t map, struct uio *uio)

     The uvm_io() function performs the	I/O described in uio on	the memory de-
     scribed in	map.

PROCESSES
     void uvm_pageout(void *arg)

     The uvm_pageout() function	is the main loop for the page daemon.  The arg
     argument is ignored.

MISCELLANEOUS FUNCTIONS
     struct uvm_object * uao_create(vsize_t size, int flags) void
     uao_detach(struct uvm_object *uobj) void uao_reference(struct uvm_object
     *uobj) boolean_t uvm_chgkprot(caddr_t addr, size_t	len, int rw) void
     uvm_kernacc(caddr_t addr, size_t len, int rw) void	uvm_meter() int
     uvm_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void
     *newp , size_t newlen, struct proc	*p) int	uvm_grow(struct	proc *p,
     vaddr_t sp) int uvm_coredump(struct proc *p, struct vnode *vp, struct
     ucred *cred, struct core *chdr)

     The uao_create(), uao_detach() and	uao_reference()	functions operate on
     anonymous memory objects, such as those used to support System V shared
     memory.  uao_create() returns an object of	size size with flags:

     #define UAO_FLAG_KERNOBJ	     0x1     /*	create kernel object */
     #define UAO_FLAG_KERNSWAP	     0x2     /*	enable kernel swap */

     which can only be used once each at system	boot time.  uao_reference()
     creates an	additional reference to	the named anonymous memory object.
     uao_detach() removes a reference from the named anonymous memory object,
     destroying	it if removing the last	reference.

     The uvm_kernacc() function	checks the access at address addr to addr +
     len for rw	access,	in the kernel address space.

     The uvm_meter() function calculates the load average and wakes up the
     swapper if	necessary.

     The uvm_sysctl() function provides	support	for the	CTL_VM domain of the
     sysctl(2) hierarchy.  uvm_sysctl()	handles	the VM_LOADAVG,	VM_METER and
     VM_UVMEXP calls, which return the current load averages, calculates cur-
     rent VM totals, and returns the uvmexp structure respectively.  The load
     averages are accessed from	userland using the getloadavg(3) function.
     The uvmexp	structure has all global state of the UVM system, and has the
     following members:

     /*	vm_page	constants */
     int pagesize;   /*	size of	a page (PAGE_SIZE): must be power of 2 */
     int pagemask;   /*	page mask */
     int pageshift;  /*	page shift */

     /*	vm_page	counters */
     int npages;     /*	number of pages	we manage */
     int free;	     /*	number of free pages */
     int active;     /*	number of active pages */
     int inactive;   /*	number of pages	that we	free'd but may want back */
     int paging;     /*	number of pages	in the process of being	paged out */
     int wired;	     /*	number of wired	pages */

     int zeropages;	     /*	number of zero'd pages */
     int reserve_pagedaemon; /*	number of pages	reserved for pagedaemon	*/
     int reserve_kernel;     /*	number of pages	reserved for kernel */
     int unused01;	     /*	formerly anonpages */
     int vnodepages;	     /*	XXX # of pages used by vnode page cache	*/
     int vtextpages;	     /*	XXX # of pages used by vtext vnodes */

     /*	pageout	params */
     int freemin;    /*	min number of free pages */
     int freetarg;   /*	target number of free pages */
     int inactarg;   /*	target number of inactive pages	*/
     int wiredmax;   /*	max number of wired pages */
     int anonmin;    /*	min threshold for anon pages */
     int vtextmin;   /*	min threshold for vtext	pages */
     int vnodemin;   /*	min threshold for vnode	pages */
     int anonminpct; /*	min percent anon pages */
     int vtextminpct;/*	min percent vtext pages	*/
     int vnodeminpct;/*	min percent vnode pages	*/

     /*	swap */
     int nswapdev;   /*	number of configured swap devices in system */
     int swpages;    /*	number of PAGE_SIZE'ed swap pages */
     int swpginuse;  /*	number of swap pages in	use */
     int swpgonly;   /*	number of swap pages in	use, not also in RAM */
     int nswget;     /*	number of swap pages moved from	disk to	RAM */
     int nanon;	     /*	XXX number total of anon's in system */
     int unused05;   /*	formerly nanonneeded */
     int unused06;   /*	formerly nfreeanon */

     /*	stat counters */
     int faults;	     /*	page fault count */
     int traps;		     /*	trap count */
     int intrs;		     /*	interrupt count	*/
     int swtch;		     /*	context	switch count */
     int softs;		     /*	software interrupt count */
     int syscalls;	     /*	system calls */
     int pageins;	     /*	pagein operation count */
			     /*	pageouts are in	pdpageouts below */
     int unused07;	     /*	formerly obsolete_swapins */
     int unused08;	     /*	formerly obsolete_swapouts */
     int pgswapin;	     /*	pages swapped in */
     int pgswapout;	     /*	pages swapped out */
     int forks;		     /*	forks */
     int forks_ppwait;	     /*	forks where parent waits */
     int forks_sharevm;	     /*	forks where vmspace is shared */
     int pga_zerohit;	     /*	pagealloc where	zero wanted and	zero
				     was available */
     int pga_zeromiss;	     /*	pagealloc where	zero wanted and	zero
				     not available */
     int unused09;	     /*	formerly zeroaborts */

     /*	fault subcounters */
     int fltnoram;   /*	number of times	fault was out of ram */
     int fltnoanon;  /*	number of times	fault was out of anons */
     int fltnoamap;  /*	number of times	fault was out of amap chunks */
     int fltpgwait;  /*	number of times	fault had to wait on a page */
     int fltpgrele;  /*	number of times	fault found a released page */
     int fltrelck;   /*	number of times	fault relock called */
     int fltrelckok; /*	number of times	fault relock is	a success */
     int fltanget;   /*	number of times	fault gets anon	page */
     int fltanretry; /*	number of times	fault retrys an	anon get */
     int fltamcopy;  /*	number of times	fault clears "needs copy" */
     int fltnamap;   /*	number of times	fault maps a neighbor anon page	*/
     int fltnomap;   /*	number of times	fault maps a neighbor obj page */
     int fltlget;    /*	number of times	fault does a locked pgo_get */
     int fltget;     /*	number of times	fault does an unlocked get */
     int flt_anon;   /*	number of times	fault anon (case 1a) */
     int flt_acow;   /*	number of times	fault anon cow (case 1b) */
     int flt_obj;    /*	number of times	fault is on object page	(2a) */
     int flt_prcopy; /*	number of times	fault promotes with copy (2b) */
     int flt_przero; /*	number of times	fault promotes with zerofill (2b) */

     /*	daemon counters	*/
     int pdwoke;     /*	number of times	daemon woke up */
     int pdrevs;     /*	number of times	daemon rev'd clock hand	*/
     int pdswout;    /*	number of times	daemon called for swapout */
     int pdfreed;    /*	number of pages	daemon freed since boot	*/
     int pdscans;    /*	number of pages	daemon scanned since boot */
     int pdanscan;   /*	number of anonymous pages scanned by daemon */
     int pdobscan;   /*	number of object pages scanned by daemon */
     int pdreact;    /*	number of pages	daemon reactivated since boot */
     int pdbusy;     /*	number of times	daemon found a busy page */
     int pdpageouts; /*	number of times	daemon started a pageout */
     int pdpending;  /*	number of times	daemon got a pending pagout */
     int pddeact;    /*	number of pages	daemon deactivates */
     int unused11;   /*	formerly pdreanon */
     int unused12;   /*	formerly pdrevnode */
     int unused13;   /*	formerly pdrevtext */

     int fpswtch;    /*	FPU context switches */
     int kmapent;    /*	number of kernel map entries */

     The uvm_grow() function increases the stack segment of process p to in-
     clude sp.

     The uvm_coredump()	function generates a coredump on vnode vp for process
     p with credentials	cred and core header description in chdr.

NOTES
     The structure and types whose names begin with "vm_" were named so	UVM
     could coexist with	BSD VM during the early	development stages.

SEE ALSO
     sysctl(2),	getloadavg(3), kvm(3), ddb(4), options(4), pmap(9)

     Charles D.	Cranor,	Design and Implementation of the UVM Virtual Memory
     System, D.Sc. dissertation, Department of Computer	Science, Sever
     Institute of Technology, Washington University, St. Louis,	Missouri,
     August 1998.

HISTORY
     The UVM virtual memory system was developed at Washington University in
     St. Louis.	 UVM's roots lie partly	in the Mach-based 4.4BSD VM system,
     the FreeBSD VM system, and	the SunOS4 VM system.  UVM's basic structure
     is	based on the 4.4BSD VM system.	UVM's new anonymous memory system is
     based on the anonymous memory system found	in the SunOS4 VM (as described
     in	papers published by Sun	Microsystems, Inc.).  UVM also includes	a num-
     ber of features new to BSD	including page loanout,	map entry passing,
     simplified	copy-on-write, and clustered anonymous memory pageout.

     UVM appeared in OpenBSD 2.9.

AUTHORS
     Charles D.	Cranor <chuck@ccrc.wustl.edu> designed and implemented UVM.

     Matthew Green <mrg@eterna.com.au> wrote the swap-space management code.

     Chuck Silvers <chuq@chuq.com> implemented the aobj	pager, thus allowing
     UVM to support System V shared memory and process swapping.

     Artur Grabowski <art@openbsd.org> handled the logistical issues involved
     with merging UVM into the OpenBSD source tree.

FreeBSD	13.0			April 23, 2020			  FreeBSD 13.0

NAME | SYNOPSIS | DESCRIPTION | INITIALISATION | VIRTUAL MEMORY I/O | PROCESSES | MISCELLANEOUS FUNCTIONS | NOTES | SEE ALSO | HISTORY | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=uvm_init&sektion=9&manpath=OpenBSD+6.9>

home | help