xref: /freebsd/sys/vm/vm_page.h (revision 1f545269529494c71ac10258cd3de0d5bcfdea2c)
1df8bae1dSRodney W. Grimes /*
2df8bae1dSRodney W. Grimes  * Copyright (c) 1991, 1993
3df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
4df8bae1dSRodney W. Grimes  *
5df8bae1dSRodney W. Grimes  * This code is derived from software contributed to Berkeley by
6df8bae1dSRodney W. Grimes  * The Mach Operating System project at Carnegie-Mellon University.
7df8bae1dSRodney W. Grimes  *
8df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
9df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
10df8bae1dSRodney W. Grimes  * are met:
11df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
12df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
13df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
14df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
15df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
16df8bae1dSRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
17df8bae1dSRodney W. Grimes  *    must display the following acknowledgement:
18df8bae1dSRodney W. Grimes  *	This product includes software developed by the University of
19df8bae1dSRodney W. Grimes  *	California, Berkeley and its contributors.
20df8bae1dSRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
21df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
22df8bae1dSRodney W. Grimes  *    without specific prior written permission.
23df8bae1dSRodney W. Grimes  *
24df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
35df8bae1dSRodney W. Grimes  *
363c4dd356SDavid Greenman  *	from: @(#)vm_page.h	8.2 (Berkeley) 12/13/93
37df8bae1dSRodney W. Grimes  *
38df8bae1dSRodney W. Grimes  *
39df8bae1dSRodney W. Grimes  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
40df8bae1dSRodney W. Grimes  * All rights reserved.
41df8bae1dSRodney W. Grimes  *
42df8bae1dSRodney W. Grimes  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
43df8bae1dSRodney W. Grimes  *
44df8bae1dSRodney W. Grimes  * Permission to use, copy, modify and distribute this software and
45df8bae1dSRodney W. Grimes  * its documentation is hereby granted, provided that both the copyright
46df8bae1dSRodney W. Grimes  * notice and this permission notice appear in all copies of the
47df8bae1dSRodney W. Grimes  * software, derivative works or modified versions, and any portions
48df8bae1dSRodney W. Grimes  * thereof, and that both notices appear in supporting documentation.
49df8bae1dSRodney W. Grimes  *
50df8bae1dSRodney W. Grimes  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
51df8bae1dSRodney W. Grimes  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
52df8bae1dSRodney W. Grimes  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
53df8bae1dSRodney W. Grimes  *
54df8bae1dSRodney W. Grimes  * Carnegie Mellon requests users of this software to return to
55df8bae1dSRodney W. Grimes  *
56df8bae1dSRodney W. Grimes  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
57df8bae1dSRodney W. Grimes  *  School of Computer Science
58df8bae1dSRodney W. Grimes  *  Carnegie Mellon University
59df8bae1dSRodney W. Grimes  *  Pittsburgh PA 15213-3890
60df8bae1dSRodney W. Grimes  *
61df8bae1dSRodney W. Grimes  * any improvements or extensions that they make and grant Carnegie the
62df8bae1dSRodney W. Grimes  * rights to redistribute these changes.
633c4dd356SDavid Greenman  *
64c3aac50fSPeter Wemm  * $FreeBSD$
65df8bae1dSRodney W. Grimes  */
66df8bae1dSRodney W. Grimes 
67df8bae1dSRodney W. Grimes /*
68df8bae1dSRodney W. Grimes  *	Resident memory system definitions.
69df8bae1dSRodney W. Grimes  */
70df8bae1dSRodney W. Grimes 
71df8bae1dSRodney W. Grimes #ifndef	_VM_PAGE_
72df8bae1dSRodney W. Grimes #define	_VM_PAGE_
73df8bae1dSRodney W. Grimes 
740237469fSJulian Elischer #if !defined(KLD_MODULE)
7520f71813SJohn-Mark Gurney #include "opt_vmpage.h"
760237469fSJulian Elischer #endif
7720f71813SJohn-Mark Gurney 
78f919ebdeSDavid Greenman #include <vm/pmap.h>
79069e9bc1SDoug Rabson 
80df8bae1dSRodney W. Grimes /*
81df8bae1dSRodney W. Grimes  *	Management of resident (logical) pages.
82df8bae1dSRodney W. Grimes  *
83df8bae1dSRodney W. Grimes  *	A small structure is kept for each resident
84df8bae1dSRodney W. Grimes  *	page, indexed by page number.  Each structure
85df8bae1dSRodney W. Grimes  *	is an element of several lists:
86df8bae1dSRodney W. Grimes  *
87df8bae1dSRodney W. Grimes  *		A hash table bucket used to quickly
88df8bae1dSRodney W. Grimes  *		perform object/offset lookups
89df8bae1dSRodney W. Grimes  *
90df8bae1dSRodney W. Grimes  *		A list of all pages for a given object,
91df8bae1dSRodney W. Grimes  *		so they can be quickly deactivated at
92df8bae1dSRodney W. Grimes  *		time of deallocation.
93df8bae1dSRodney W. Grimes  *
94df8bae1dSRodney W. Grimes  *		An ordered list of pages due for pageout.
95df8bae1dSRodney W. Grimes  *
96df8bae1dSRodney W. Grimes  *	In addition, the structure contains the object
97df8bae1dSRodney W. Grimes  *	and offset to which this page belongs (for pageout),
98df8bae1dSRodney W. Grimes  *	and sundry status bits.
99df8bae1dSRodney W. Grimes  *
100df8bae1dSRodney W. Grimes  *	Fields in this structure are locked either by the lock on the
101df8bae1dSRodney W. Grimes  *	object that the page belongs to (O) or by the lock on the page
102df8bae1dSRodney W. Grimes  *	queues (P).
1034221e284SAlan Cox  *
1044221e284SAlan Cox  *	The 'valid' and 'dirty' fields are distinct.  A page may have dirty
1054221e284SAlan Cox  *	bits set without having associated valid bits set.  This is used by
1064221e284SAlan Cox  *	NFS to implement piecemeal writes.
107df8bae1dSRodney W. Grimes  */
108df8bae1dSRodney W. Grimes 
109e3975643SJake Burkholder TAILQ_HEAD(pglist, vm_page);
110df8bae1dSRodney W. Grimes 
111df8bae1dSRodney W. Grimes struct vm_page {
112e3975643SJake Burkholder 	TAILQ_ENTRY(vm_page) pageq;	/* queue info for FIFO queue or free list (P) */
1131c7c3c6aSMatthew Dillon 	struct vm_page	*hnext;		/* hash table link (O,P)	*/
114e3975643SJake Burkholder 	TAILQ_ENTRY(vm_page) listq;	/* pages in same object (O) 	*/
115df8bae1dSRodney W. Grimes 
116df8bae1dSRodney W. Grimes 	vm_object_t object;		/* which object am I in (O,P)*/
117a316d390SJohn Dyson 	vm_pindex_t pindex;		/* offset into object (O,P) */
1180d94caffSDavid Greenman 	vm_offset_t phys_addr;		/* physical address of page */
1190385347cSPeter Wemm 	struct md_page md;		/* machine dependant stuff */
1205070c7f8SJohn Dyson 	u_short	queue;			/* page queue index */
1215070c7f8SJohn Dyson 	u_short	flags,			/* see below */
1225070c7f8SJohn Dyson 		pc;			/* page color */
123df8bae1dSRodney W. Grimes 	u_short wire_count;		/* wired down maps refs (P) */
12426f9a767SRodney W. Grimes 	short hold_count;		/* page hold count */
125bd7e5f99SJohn Dyson 	u_char	act_count;		/* page usage count */
126bd7e5f99SJohn Dyson 	u_char	busy;			/* page busy count */
127bd7e5f99SJohn Dyson 	/* NOTE that these must support one bit per DEV_BSIZE in a page!!! */
128bd7e5f99SJohn Dyson 	/* so, on normal X86 kernels, they must be at least 8 bits wide */
129ecbb00a2SDoug Rabson #if PAGE_SIZE == 4096
130bd7e5f99SJohn Dyson 	u_char	valid;			/* map of valid DEV_BSIZE chunks */
131bd7e5f99SJohn Dyson 	u_char	dirty;			/* map of dirty DEV_BSIZE chunks */
132ecbb00a2SDoug Rabson #elif PAGE_SIZE == 8192
133ecbb00a2SDoug Rabson 	u_short	valid;			/* map of valid DEV_BSIZE chunks */
134ecbb00a2SDoug Rabson 	u_short	dirty;			/* map of dirty DEV_BSIZE chunks */
135ecbb00a2SDoug Rabson #endif
13698cb733cSKenneth D. Merry 	u_int cow;			/* page cow mapping count */
137df8bae1dSRodney W. Grimes };
138df8bae1dSRodney W. Grimes 
1395070c7f8SJohn Dyson /*
14090ecac61SMatthew Dillon  * note: currently use SWAPBLK_NONE as an absolute value rather then
14190ecac61SMatthew Dillon  * a flag bit.
1421c7c3c6aSMatthew Dillon  */
1431c7c3c6aSMatthew Dillon 
1441c7c3c6aSMatthew Dillon #define SWAPBLK_MASK	((daddr_t)((u_daddr_t)-1 >> 1))		/* mask */
1451c7c3c6aSMatthew Dillon #define SWAPBLK_NONE	((daddr_t)((u_daddr_t)SWAPBLK_MASK + 1))/* flag */
1461c7c3c6aSMatthew Dillon 
1470237469fSJulian Elischer #if !defined(KLD_MODULE)
1486d03d577SMatthew Dillon /*
1495070c7f8SJohn Dyson  * Page coloring parameters
1505070c7f8SJohn Dyson  */
151faa273d5SMatthew Dillon /* Each of PQ_FREE, and PQ_CACHE have PQ_HASH_SIZE entries */
1525070c7f8SJohn Dyson 
1539a20f99aSJohn Baldwin /* Backward compatibility for existing PQ_*CACHE config options. */
1549a20f99aSJohn Baldwin #if !defined(PQ_CACHESIZE)
155b9cefc08SJohn Dyson #if defined(PQ_HUGECACHE)
1569a20f99aSJohn Baldwin #define PQ_CACHESIZE 1024
1574c8545c1SAlfred Perlstein #elif defined(PQ_LARGECACHE)
1589a20f99aSJohn Baldwin #define PQ_CACHESIZE 512
1594c8545c1SAlfred Perlstein #elif defined(PQ_MEDIUMCACHE)
1609a20f99aSJohn Baldwin #define PQ_CACHESIZE 256
1614c8545c1SAlfred Perlstein #elif defined(PQ_NORMALCACHE)
1629a20f99aSJohn Baldwin #define PQ_CACHESIZE 64
1634c8545c1SAlfred Perlstein #elif defined(PQ_NOOPT)
1649a20f99aSJohn Baldwin #define PQ_CACHESIZE 0
1659a20f99aSJohn Baldwin #else
1669a20f99aSJohn Baldwin #define PQ_CACHESIZE 128
1679a20f99aSJohn Baldwin #endif
168a1287949SEivind Eklund #endif			/* !defined(PQ_CACHESIZE) */
1699a20f99aSJohn Baldwin 
1709a20f99aSJohn Baldwin #if PQ_CACHESIZE >= 1024
171b9cefc08SJohn Dyson #define PQ_PRIME1 31	/* Prime number somewhat less than PQ_HASH_SIZE */
172b9cefc08SJohn Dyson #define PQ_PRIME2 23	/* Prime number somewhat less than PQ_HASH_SIZE */
173b9cefc08SJohn Dyson #define PQ_L2_SIZE 256	/* A number of colors opt for 1M cache */
174b9cefc08SJohn Dyson 
1754c8545c1SAlfred Perlstein #elif PQ_CACHESIZE >= 512
1765070c7f8SJohn Dyson #define PQ_PRIME1 31	/* Prime number somewhat less than PQ_HASH_SIZE */
1775070c7f8SJohn Dyson #define PQ_PRIME2 23	/* Prime number somewhat less than PQ_HASH_SIZE */
1785070c7f8SJohn Dyson #define PQ_L2_SIZE 128	/* A number of colors opt for 512K cache */
1795070c7f8SJohn Dyson 
1804c8545c1SAlfred Perlstein #elif PQ_CACHESIZE >= 256
181853a7bc8SJohn Dyson #define PQ_PRIME1 13	/* Prime number somewhat less than PQ_HASH_SIZE */
182853a7bc8SJohn Dyson #define PQ_PRIME2 7	/* Prime number somewhat less than PQ_HASH_SIZE */
183853a7bc8SJohn Dyson #define PQ_L2_SIZE 64	/* A number of colors opt for 256K cache */
184853a7bc8SJohn Dyson 
1854c8545c1SAlfred Perlstein #elif PQ_CACHESIZE >= 128
1861aefb1d9SAlan Cox #define PQ_PRIME1 9	/* Produces a good PQ_L2_SIZE/3 + PQ_PRIME1 */
1871aefb1d9SAlan Cox #define PQ_PRIME2 5	/* Prime number somewhat less than PQ_HASH_SIZE */
1889a20f99aSJohn Baldwin #define PQ_L2_SIZE 32	/* A number of colors opt for 128k cache */
1899a20f99aSJohn Baldwin 
1904c8545c1SAlfred Perlstein #elif PQ_CACHESIZE >= 64
1919a20f99aSJohn Baldwin #define PQ_PRIME1 5	/* Prime number somewhat less than PQ_HASH_SIZE */
1929a20f99aSJohn Baldwin #define PQ_PRIME2 3	/* Prime number somewhat less than PQ_HASH_SIZE */
1939a20f99aSJohn Baldwin #define PQ_L2_SIZE 16	/* A reasonable number of colors (opt for 64K cache) */
1949a20f99aSJohn Baldwin 
1959a20f99aSJohn Baldwin #else
1969a20f99aSJohn Baldwin #define PQ_PRIME1 1	/* Disable page coloring. */
1979a20f99aSJohn Baldwin #define PQ_PRIME2 1
1989a20f99aSJohn Baldwin #define PQ_L2_SIZE 1
1999a20f99aSJohn Baldwin 
2001aefb1d9SAlan Cox #endif
2011aefb1d9SAlan Cox 
2025070c7f8SJohn Dyson #define PQ_L2_MASK (PQ_L2_SIZE - 1)
2035070c7f8SJohn Dyson 
2043739d7daSMatt Jacob #define PQ_NONE 0
2053739d7daSMatt Jacob #define PQ_FREE	1
2063739d7daSMatt Jacob #define PQ_INACTIVE (1 + 1*PQ_L2_SIZE)
2073739d7daSMatt Jacob #define PQ_ACTIVE (2 + 1*PQ_L2_SIZE)
2083739d7daSMatt Jacob #define PQ_CACHE (3 + 1*PQ_L2_SIZE)
209d2760948STor Egge #define PQ_HOLD  (3 + 2*PQ_L2_SIZE)
210d2760948STor Egge #define PQ_COUNT (4 + 2*PQ_L2_SIZE)
2115070c7f8SJohn Dyson 
212be72f788SAlan Cox struct vpgqueues {
213be72f788SAlan Cox 	struct pglist pl;
2145070c7f8SJohn Dyson 	int	*cnt;
2155d2aec89SAlan Cox 	int	lcnt;
216be72f788SAlan Cox };
217be72f788SAlan Cox 
218be72f788SAlan Cox extern struct vpgqueues vm_page_queues[PQ_COUNT];
21970c17636SAlan Cox extern struct mtx vm_page_queue_free_mtx;
22070c17636SAlan Cox 
221a1287949SEivind Eklund #endif			/* !defined(KLD_MODULE) */
2220237469fSJulian Elischer 
223df8bae1dSRodney W. Grimes /*
224df8bae1dSRodney W. Grimes  * These are the flags defined for vm_page.
225df8bae1dSRodney W. Grimes  *
226df8bae1dSRodney W. Grimes  * Note: PG_FILLED and PG_DIRTY are added for the filesystems.
2278b03c8edSMatthew Dillon  *
2288b03c8edSMatthew Dillon  * Note: PG_UNMANAGED (used by OBJT_PHYS) indicates that the page is
2298b03c8edSMatthew Dillon  * 	 not under PV management but otherwise should be treated as a
2308b03c8edSMatthew Dillon  *	 normal page.  Pages not under PV management cannot be paged out
2318b03c8edSMatthew Dillon  *	 via the object/vm_page_t because there is no knowledge of their
2328b03c8edSMatthew Dillon  *	 pte mappings, nor can they be removed from their objects via
2338b03c8edSMatthew Dillon  *	 the object, and such pages are also not on any PQ queue.
234df8bae1dSRodney W. Grimes  */
2351c7c3c6aSMatthew Dillon #define	PG_BUSY		0x0001		/* page is in transit (O) */
2361c7c3c6aSMatthew Dillon #define	PG_WANTED	0x0002		/* someone is waiting for page (O) */
2372b6b0df7SMatthew Dillon #define PG_WINATCFLS	0x0004		/* flush dirty page on inactive q */
2381c7c3c6aSMatthew Dillon #define	PG_FICTITIOUS	0x0008		/* physical page doesn't exist (O) */
2391c7c3c6aSMatthew Dillon #define	PG_WRITEABLE	0x0010		/* page is mapped writeable */
2401c7c3c6aSMatthew Dillon #define PG_MAPPED	0x0020		/* page is mapped */
2411c7c3c6aSMatthew Dillon #define	PG_ZERO		0x0040		/* page is zeroed */
2421c7c3c6aSMatthew Dillon #define PG_REFERENCED	0x0080		/* page has been referenced */
2431c7c3c6aSMatthew Dillon #define PG_CLEANCHK	0x0100		/* page will be checked for cleaning */
2441c7c3c6aSMatthew Dillon #define PG_SWAPINPROG	0x0200		/* swap I/O in progress on page	     */
2454f79d873SMatthew Dillon #define PG_NOSYNC	0x0400		/* do not collect for syncer */
2468b03c8edSMatthew Dillon #define PG_UNMANAGED	0x0800		/* No PV management for page */
247936524aaSMatthew Dillon #define PG_MARKER	0x1000		/* special queue marker page */
248df8bae1dSRodney W. Grimes 
24924a1cce3SDavid Greenman /*
25024a1cce3SDavid Greenman  * Misc constants.
25124a1cce3SDavid Greenman  */
25224a1cce3SDavid Greenman #define ACT_DECLINE		1
25324a1cce3SDavid Greenman #define ACT_ADVANCE		3
25438efa82bSJohn Dyson #define ACT_INIT		5
2555070c7f8SJohn Dyson #define ACT_MAX			64
25624a1cce3SDavid Greenman #define PFCLUSTER_BEHIND	3
25724a1cce3SDavid Greenman #define PFCLUSTER_AHEAD		3
258df8bae1dSRodney W. Grimes 
259c4473420SPeter Wemm #ifdef _KERNEL
260df8bae1dSRodney W. Grimes /*
26124a1cce3SDavid Greenman  * Each pageable resident page falls into one of four lists:
262df8bae1dSRodney W. Grimes  *
263df8bae1dSRodney W. Grimes  *	free
264df8bae1dSRodney W. Grimes  *		Available for allocation now.
26524a1cce3SDavid Greenman  *
26624a1cce3SDavid Greenman  * The following are all LRU sorted:
26724a1cce3SDavid Greenman  *
26824a1cce3SDavid Greenman  *	cache
26924a1cce3SDavid Greenman  *		Almost available for allocation. Still in an
27024a1cce3SDavid Greenman  *		object, but clean and immediately freeable at
27124a1cce3SDavid Greenman  *		non-interrupt times.
27224a1cce3SDavid Greenman  *
273df8bae1dSRodney W. Grimes  *	inactive
2746c5e9bbdSMike Pritchard  *		Low activity, candidates for reclamation.
275df8bae1dSRodney W. Grimes  *		This is the list of pages that should be
276df8bae1dSRodney W. Grimes  *		paged out next.
27724a1cce3SDavid Greenman  *
278df8bae1dSRodney W. Grimes  *	active
27924a1cce3SDavid Greenman  *		Pages that are "active" i.e. they have been
28024a1cce3SDavid Greenman  *		recently referenced.
28110ad4d48SJohn Dyson  *
28210ad4d48SJohn Dyson  *	zero
28310ad4d48SJohn Dyson  *		Pages that are really free and have been pre-zeroed
28410ad4d48SJohn Dyson  *
285df8bae1dSRodney W. Grimes  */
286df8bae1dSRodney W. Grimes 
287a316d390SJohn Dyson extern int vm_page_zero_count;
288a316d390SJohn Dyson 
2890d94caffSDavid Greenman extern vm_page_t vm_page_array;		/* First resident page in table */
2900385347cSPeter Wemm extern int vm_page_array_size;		/* number of vm_page_t's */
2910d94caffSDavid Greenman extern long first_page;			/* first physical page number */
2920d94caffSDavid Greenman 
293df8bae1dSRodney W. Grimes #define VM_PAGE_TO_PHYS(entry)	((entry)->phys_addr)
294df8bae1dSRodney W. Grimes 
295df8bae1dSRodney W. Grimes #define PHYS_TO_VM_PAGE(pa) \
296df8bae1dSRodney W. Grimes 		(&vm_page_array[atop(pa) - first_page ])
297df8bae1dSRodney W. Grimes 
2981f545269SAlan Cox extern struct mtx vm_page_queue_mtx;
2991f545269SAlan Cox #define vm_page_lock_queues()   mtx_lock(&vm_page_queue_mtx)
3001f545269SAlan Cox #define vm_page_unlock_queues() mtx_unlock(&vm_page_queue_mtx)
3018f9110f6SJohn Dyson 
3020d94caffSDavid Greenman #if PAGE_SIZE == 4096
3030d94caffSDavid Greenman #define VM_PAGE_BITS_ALL 0xff
3040d94caffSDavid Greenman #endif
3050d94caffSDavid Greenman 
3060d94caffSDavid Greenman #if PAGE_SIZE == 8192
3070d94caffSDavid Greenman #define VM_PAGE_BITS_ALL 0xffff
3080d94caffSDavid Greenman #endif
3090d94caffSDavid Greenman 
3106d40c3d3SDavid Greenman #define VM_ALLOC_NORMAL		0
3116d40c3d3SDavid Greenman #define VM_ALLOC_INTERRUPT	1
3126d40c3d3SDavid Greenman #define VM_ALLOC_SYSTEM		2
313e78f35b3SJeff Roberson #define	VM_ALLOC_ZERO		0x40
31495461b45SJohn Dyson #define	VM_ALLOC_RETRY		0x80
3150d94caffSDavid Greenman 
3161b40f8c0SMatthew Dillon void vm_page_flag_set(vm_page_t m, unsigned short bits);
3171b40f8c0SMatthew Dillon void vm_page_flag_clear(vm_page_t m, unsigned short bits);
3181b40f8c0SMatthew Dillon void vm_page_busy(vm_page_t m);
3191b40f8c0SMatthew Dillon void vm_page_flash(vm_page_t m);
3201b40f8c0SMatthew Dillon void vm_page_io_start(vm_page_t m);
3211b40f8c0SMatthew Dillon void vm_page_io_finish(vm_page_t m);
3221b40f8c0SMatthew Dillon void vm_page_hold(vm_page_t mem);
3231b40f8c0SMatthew Dillon void vm_page_unhold(vm_page_t mem);
3241b40f8c0SMatthew Dillon void vm_page_protect(vm_page_t mem, int prot);
3251b40f8c0SMatthew Dillon boolean_t vm_page_zero_fill(vm_page_t m);
32644e74ba6SPeter Wemm boolean_t vm_page_zero_fill_area(vm_page_t m, int off, int len);
3271b40f8c0SMatthew Dillon void vm_page_copy(vm_page_t src_m, vm_page_t dest_m);
3281b40f8c0SMatthew Dillon void vm_page_free(vm_page_t m);
3291b40f8c0SMatthew Dillon void vm_page_free_zero(vm_page_t m);
3301b40f8c0SMatthew Dillon int vm_page_sleep_busy(vm_page_t m, int also_m_busy, const char *msg);
3311b40f8c0SMatthew Dillon void vm_page_dirty(vm_page_t m);
3321b40f8c0SMatthew Dillon void vm_page_undirty(vm_page_t m);
3331b40f8c0SMatthew Dillon void vm_page_wakeup(vm_page_t m);
3341b40f8c0SMatthew Dillon 
3356d03d577SMatthew Dillon void vm_pageq_init(void);
3366d03d577SMatthew Dillon struct vpgqueues *vm_pageq_aquire(int queue);
3376d03d577SMatthew Dillon void vm_pageq_release(struct vpgqueues *vpq);
3386d03d577SMatthew Dillon vm_page_t vm_pageq_add_new_page(vm_offset_t pa);
3392be21c5eSAlan Cox void vm_pageq_enqueue(int queue, vm_page_t m);
3406d03d577SMatthew Dillon void vm_pageq_remove_nowakeup(vm_page_t m);
3416d03d577SMatthew Dillon void vm_pageq_remove(vm_page_t m);
3426d03d577SMatthew Dillon vm_page_t vm_pageq_find(int basequeue, int index, boolean_t prefer_zero);
3436d03d577SMatthew Dillon void vm_pageq_requeue(vm_page_t m);
3446d03d577SMatthew Dillon 
3451b40f8c0SMatthew Dillon void vm_page_activate (vm_page_t);
3461b40f8c0SMatthew Dillon vm_page_t vm_page_alloc (vm_object_t, vm_pindex_t, int);
3471b40f8c0SMatthew Dillon vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int);
3481b40f8c0SMatthew Dillon void vm_page_cache (register vm_page_t);
3491b40f8c0SMatthew Dillon int vm_page_try_to_cache (vm_page_t);
3501b40f8c0SMatthew Dillon int vm_page_try_to_free (vm_page_t);
3511b40f8c0SMatthew Dillon void vm_page_dontneed (register vm_page_t);
3521b40f8c0SMatthew Dillon void vm_page_deactivate (vm_page_t);
3531b40f8c0SMatthew Dillon void vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t);
3541b40f8c0SMatthew Dillon vm_page_t vm_page_lookup (vm_object_t, vm_pindex_t);
3551b40f8c0SMatthew Dillon void vm_page_remove (vm_page_t);
3561b40f8c0SMatthew Dillon void vm_page_rename (vm_page_t, vm_object_t, vm_pindex_t);
3571b40f8c0SMatthew Dillon vm_offset_t vm_page_startup (vm_offset_t, vm_offset_t, vm_offset_t);
3581b40f8c0SMatthew Dillon void vm_page_unmanage (vm_page_t);
3591b40f8c0SMatthew Dillon void vm_page_unwire (vm_page_t, int);
3601b40f8c0SMatthew Dillon void vm_page_wire (vm_page_t);
3611b40f8c0SMatthew Dillon void vm_page_set_validclean (vm_page_t, int, int);
3621b40f8c0SMatthew Dillon void vm_page_set_dirty (vm_page_t, int, int);
3631b40f8c0SMatthew Dillon void vm_page_clear_dirty (vm_page_t, int, int);
3641b40f8c0SMatthew Dillon void vm_page_set_invalid (vm_page_t, int, int);
3651b40f8c0SMatthew Dillon int vm_page_is_valid (vm_page_t, int, int);
3661b40f8c0SMatthew Dillon void vm_page_test_dirty (vm_page_t);
3671b40f8c0SMatthew Dillon int vm_page_bits (int, int);
3688d17e694SJulian Elischer void vm_page_zero_invalid(vm_page_t m, boolean_t setvalid);
369faa273d5SMatthew Dillon void vm_page_free_toq(vm_page_t m);
3703516c025SPeter Wemm void vm_page_zero_idle_wakeup(void);
37198cb733cSKenneth D. Merry void vm_page_cowfault (vm_page_t);
37298cb733cSKenneth D. Merry void vm_page_cowsetup (vm_page_t);
37398cb733cSKenneth D. Merry void vm_page_cowclear (vm_page_t);
37498cb733cSKenneth D. Merry 
375c4473420SPeter Wemm #endif				/* _KERNEL */
376df8bae1dSRodney W. Grimes #endif				/* !_VM_PAGE_ */
377