xref: /freebsd/sys/vm/vm_page.h (revision b86ec922be51324fdc6e7d847d6784cf1b526baa)
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) */
113e3975643SJake Burkholder 	TAILQ_ENTRY(vm_page) listq;	/* pages in same object (O) 	*/
114b86ec922SMatthew Dillon 	struct vm_page *left;		/* splay tree link (O)		*/
115b86ec922SMatthew Dillon 	struct vm_page *right;		/* splay tree link (O)		*/
116df8bae1dSRodney W. Grimes 
117df8bae1dSRodney W. Grimes 	vm_object_t object;		/* which object am I in (O,P)*/
118a316d390SJohn Dyson 	vm_pindex_t pindex;		/* offset into object (O,P) */
1190d94caffSDavid Greenman 	vm_offset_t phys_addr;		/* physical address of page */
1200385347cSPeter Wemm 	struct md_page md;		/* machine dependant stuff */
1215070c7f8SJohn Dyson 	u_short	queue;			/* page queue index */
1225070c7f8SJohn Dyson 	u_short	flags,			/* see below */
1235070c7f8SJohn Dyson 		pc;			/* page color */
124df8bae1dSRodney W. Grimes 	u_short wire_count;		/* wired down maps refs (P) */
12526f9a767SRodney W. Grimes 	short hold_count;		/* page hold count */
126bd7e5f99SJohn Dyson 	u_char	act_count;		/* page usage count */
127bd7e5f99SJohn Dyson 	u_char	busy;			/* page busy count */
128bd7e5f99SJohn Dyson 	/* NOTE that these must support one bit per DEV_BSIZE in a page!!! */
129bd7e5f99SJohn Dyson 	/* so, on normal X86 kernels, they must be at least 8 bits wide */
130ecbb00a2SDoug Rabson #if PAGE_SIZE == 4096
131bd7e5f99SJohn Dyson 	u_char	valid;			/* map of valid DEV_BSIZE chunks */
132bd7e5f99SJohn Dyson 	u_char	dirty;			/* map of dirty DEV_BSIZE chunks */
133ecbb00a2SDoug Rabson #elif PAGE_SIZE == 8192
134ecbb00a2SDoug Rabson 	u_short	valid;			/* map of valid DEV_BSIZE chunks */
135ecbb00a2SDoug Rabson 	u_short	dirty;			/* map of dirty DEV_BSIZE chunks */
136ecbb00a2SDoug Rabson #endif
13798cb733cSKenneth D. Merry 	u_int cow;			/* page cow mapping count */
138df8bae1dSRodney W. Grimes };
139df8bae1dSRodney W. Grimes 
1405070c7f8SJohn Dyson /*
14190ecac61SMatthew Dillon  * note: currently use SWAPBLK_NONE as an absolute value rather then
14290ecac61SMatthew Dillon  * a flag bit.
1431c7c3c6aSMatthew Dillon  */
1441c7c3c6aSMatthew Dillon 
1451c7c3c6aSMatthew Dillon #define SWAPBLK_MASK	((daddr_t)((u_daddr_t)-1 >> 1))		/* mask */
1461c7c3c6aSMatthew Dillon #define SWAPBLK_NONE	((daddr_t)((u_daddr_t)SWAPBLK_MASK + 1))/* flag */
1471c7c3c6aSMatthew Dillon 
1480237469fSJulian Elischer #if !defined(KLD_MODULE)
1496d03d577SMatthew Dillon /*
1505070c7f8SJohn Dyson  * Page coloring parameters
1515070c7f8SJohn Dyson  */
152faa273d5SMatthew Dillon /* Each of PQ_FREE, and PQ_CACHE have PQ_HASH_SIZE entries */
1535070c7f8SJohn Dyson 
1549a20f99aSJohn Baldwin /* Backward compatibility for existing PQ_*CACHE config options. */
1559a20f99aSJohn Baldwin #if !defined(PQ_CACHESIZE)
156b9cefc08SJohn Dyson #if defined(PQ_HUGECACHE)
1579a20f99aSJohn Baldwin #define PQ_CACHESIZE 1024
1584c8545c1SAlfred Perlstein #elif defined(PQ_LARGECACHE)
1599a20f99aSJohn Baldwin #define PQ_CACHESIZE 512
1604c8545c1SAlfred Perlstein #elif defined(PQ_MEDIUMCACHE)
1619a20f99aSJohn Baldwin #define PQ_CACHESIZE 256
1624c8545c1SAlfred Perlstein #elif defined(PQ_NORMALCACHE)
1639a20f99aSJohn Baldwin #define PQ_CACHESIZE 64
1644c8545c1SAlfred Perlstein #elif defined(PQ_NOOPT)
1659a20f99aSJohn Baldwin #define PQ_CACHESIZE 0
1669a20f99aSJohn Baldwin #else
1679a20f99aSJohn Baldwin #define PQ_CACHESIZE 128
1689a20f99aSJohn Baldwin #endif
169a1287949SEivind Eklund #endif			/* !defined(PQ_CACHESIZE) */
1709a20f99aSJohn Baldwin 
1719a20f99aSJohn Baldwin #if PQ_CACHESIZE >= 1024
172b9cefc08SJohn Dyson #define PQ_PRIME1 31	/* Prime number somewhat less than PQ_HASH_SIZE */
173b9cefc08SJohn Dyson #define PQ_PRIME2 23	/* Prime number somewhat less than PQ_HASH_SIZE */
174b9cefc08SJohn Dyson #define PQ_L2_SIZE 256	/* A number of colors opt for 1M cache */
175b9cefc08SJohn Dyson 
1764c8545c1SAlfred Perlstein #elif PQ_CACHESIZE >= 512
1775070c7f8SJohn Dyson #define PQ_PRIME1 31	/* Prime number somewhat less than PQ_HASH_SIZE */
1785070c7f8SJohn Dyson #define PQ_PRIME2 23	/* Prime number somewhat less than PQ_HASH_SIZE */
1795070c7f8SJohn Dyson #define PQ_L2_SIZE 128	/* A number of colors opt for 512K cache */
1805070c7f8SJohn Dyson 
1814c8545c1SAlfred Perlstein #elif PQ_CACHESIZE >= 256
182853a7bc8SJohn Dyson #define PQ_PRIME1 13	/* Prime number somewhat less than PQ_HASH_SIZE */
183853a7bc8SJohn Dyson #define PQ_PRIME2 7	/* Prime number somewhat less than PQ_HASH_SIZE */
184853a7bc8SJohn Dyson #define PQ_L2_SIZE 64	/* A number of colors opt for 256K cache */
185853a7bc8SJohn Dyson 
1864c8545c1SAlfred Perlstein #elif PQ_CACHESIZE >= 128
1871aefb1d9SAlan Cox #define PQ_PRIME1 9	/* Produces a good PQ_L2_SIZE/3 + PQ_PRIME1 */
1881aefb1d9SAlan Cox #define PQ_PRIME2 5	/* Prime number somewhat less than PQ_HASH_SIZE */
1899a20f99aSJohn Baldwin #define PQ_L2_SIZE 32	/* A number of colors opt for 128k cache */
1909a20f99aSJohn Baldwin 
1914c8545c1SAlfred Perlstein #elif PQ_CACHESIZE >= 64
1929a20f99aSJohn Baldwin #define PQ_PRIME1 5	/* Prime number somewhat less than PQ_HASH_SIZE */
1939a20f99aSJohn Baldwin #define PQ_PRIME2 3	/* Prime number somewhat less than PQ_HASH_SIZE */
1949a20f99aSJohn Baldwin #define PQ_L2_SIZE 16	/* A reasonable number of colors (opt for 64K cache) */
1959a20f99aSJohn Baldwin 
1969a20f99aSJohn Baldwin #else
1979a20f99aSJohn Baldwin #define PQ_PRIME1 1	/* Disable page coloring. */
1989a20f99aSJohn Baldwin #define PQ_PRIME2 1
1999a20f99aSJohn Baldwin #define PQ_L2_SIZE 1
2009a20f99aSJohn Baldwin 
2011aefb1d9SAlan Cox #endif
2021aefb1d9SAlan Cox 
2035070c7f8SJohn Dyson #define PQ_L2_MASK (PQ_L2_SIZE - 1)
2045070c7f8SJohn Dyson 
2053739d7daSMatt Jacob #define PQ_NONE 0
2063739d7daSMatt Jacob #define PQ_FREE	1
2073739d7daSMatt Jacob #define PQ_INACTIVE (1 + 1*PQ_L2_SIZE)
2083739d7daSMatt Jacob #define PQ_ACTIVE (2 + 1*PQ_L2_SIZE)
2093739d7daSMatt Jacob #define PQ_CACHE (3 + 1*PQ_L2_SIZE)
210d2760948STor Egge #define PQ_HOLD  (3 + 2*PQ_L2_SIZE)
211d2760948STor Egge #define PQ_COUNT (4 + 2*PQ_L2_SIZE)
2125070c7f8SJohn Dyson 
213be72f788SAlan Cox struct vpgqueues {
214be72f788SAlan Cox 	struct pglist pl;
2155070c7f8SJohn Dyson 	int	*cnt;
2165d2aec89SAlan Cox 	int	lcnt;
217be72f788SAlan Cox };
218be72f788SAlan Cox 
219be72f788SAlan Cox extern struct vpgqueues vm_page_queues[PQ_COUNT];
22070c17636SAlan Cox extern struct mtx vm_page_queue_free_mtx;
22170c17636SAlan Cox 
222a1287949SEivind Eklund #endif			/* !defined(KLD_MODULE) */
2230237469fSJulian Elischer 
224df8bae1dSRodney W. Grimes /*
225df8bae1dSRodney W. Grimes  * These are the flags defined for vm_page.
226df8bae1dSRodney W. Grimes  *
227df8bae1dSRodney W. Grimes  * Note: PG_FILLED and PG_DIRTY are added for the filesystems.
2288b03c8edSMatthew Dillon  *
2298b03c8edSMatthew Dillon  * Note: PG_UNMANAGED (used by OBJT_PHYS) indicates that the page is
2308b03c8edSMatthew Dillon  * 	 not under PV management but otherwise should be treated as a
2318b03c8edSMatthew Dillon  *	 normal page.  Pages not under PV management cannot be paged out
2328b03c8edSMatthew Dillon  *	 via the object/vm_page_t because there is no knowledge of their
2338b03c8edSMatthew Dillon  *	 pte mappings, nor can they be removed from their objects via
2348b03c8edSMatthew Dillon  *	 the object, and such pages are also not on any PQ queue.
235df8bae1dSRodney W. Grimes  */
2361c7c3c6aSMatthew Dillon #define	PG_BUSY		0x0001		/* page is in transit (O) */
2371c7c3c6aSMatthew Dillon #define	PG_WANTED	0x0002		/* someone is waiting for page (O) */
2382b6b0df7SMatthew Dillon #define PG_WINATCFLS	0x0004		/* flush dirty page on inactive q */
2391c7c3c6aSMatthew Dillon #define	PG_FICTITIOUS	0x0008		/* physical page doesn't exist (O) */
2401c7c3c6aSMatthew Dillon #define	PG_WRITEABLE	0x0010		/* page is mapped writeable */
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 */
24899571dc3SJeff Roberson #define	PG_SLAB		0x2000		/* object pointer is actually a slab */
249df8bae1dSRodney W. Grimes 
25024a1cce3SDavid Greenman /*
25124a1cce3SDavid Greenman  * Misc constants.
25224a1cce3SDavid Greenman  */
25324a1cce3SDavid Greenman #define ACT_DECLINE		1
25424a1cce3SDavid Greenman #define ACT_ADVANCE		3
25538efa82bSJohn Dyson #define ACT_INIT		5
2565070c7f8SJohn Dyson #define ACT_MAX			64
25724a1cce3SDavid Greenman #define PFCLUSTER_BEHIND	3
25824a1cce3SDavid Greenman #define PFCLUSTER_AHEAD		3
259df8bae1dSRodney W. Grimes 
260c4473420SPeter Wemm #ifdef _KERNEL
261df8bae1dSRodney W. Grimes /*
26224a1cce3SDavid Greenman  * Each pageable resident page falls into one of four lists:
263df8bae1dSRodney W. Grimes  *
264df8bae1dSRodney W. Grimes  *	free
265df8bae1dSRodney W. Grimes  *		Available for allocation now.
26624a1cce3SDavid Greenman  *
26724a1cce3SDavid Greenman  * The following are all LRU sorted:
26824a1cce3SDavid Greenman  *
26924a1cce3SDavid Greenman  *	cache
27024a1cce3SDavid Greenman  *		Almost available for allocation. Still in an
27124a1cce3SDavid Greenman  *		object, but clean and immediately freeable at
27224a1cce3SDavid Greenman  *		non-interrupt times.
27324a1cce3SDavid Greenman  *
274df8bae1dSRodney W. Grimes  *	inactive
2756c5e9bbdSMike Pritchard  *		Low activity, candidates for reclamation.
276df8bae1dSRodney W. Grimes  *		This is the list of pages that should be
277df8bae1dSRodney W. Grimes  *		paged out next.
27824a1cce3SDavid Greenman  *
279df8bae1dSRodney W. Grimes  *	active
28024a1cce3SDavid Greenman  *		Pages that are "active" i.e. they have been
28124a1cce3SDavid Greenman  *		recently referenced.
28210ad4d48SJohn Dyson  *
28310ad4d48SJohn Dyson  *	zero
28410ad4d48SJohn Dyson  *		Pages that are really free and have been pre-zeroed
28510ad4d48SJohn Dyson  *
286df8bae1dSRodney W. Grimes  */
287df8bae1dSRodney W. Grimes 
288a316d390SJohn Dyson extern int vm_page_zero_count;
289a316d390SJohn Dyson 
2900d94caffSDavid Greenman extern vm_page_t vm_page_array;		/* First resident page in table */
2910385347cSPeter Wemm extern int vm_page_array_size;		/* number of vm_page_t's */
2920d94caffSDavid Greenman extern long first_page;			/* first physical page number */
2930d94caffSDavid Greenman 
294df8bae1dSRodney W. Grimes #define VM_PAGE_TO_PHYS(entry)	((entry)->phys_addr)
295df8bae1dSRodney W. Grimes 
296df8bae1dSRodney W. Grimes #define PHYS_TO_VM_PAGE(pa) \
297df8bae1dSRodney W. Grimes 		(&vm_page_array[atop(pa) - first_page ])
298df8bae1dSRodney W. Grimes 
2991f545269SAlan Cox extern struct mtx vm_page_queue_mtx;
3001f545269SAlan Cox #define vm_page_lock_queues()   mtx_lock(&vm_page_queue_mtx)
3011f545269SAlan Cox #define vm_page_unlock_queues() mtx_unlock(&vm_page_queue_mtx)
3028f9110f6SJohn Dyson 
3030d94caffSDavid Greenman #if PAGE_SIZE == 4096
3040d94caffSDavid Greenman #define VM_PAGE_BITS_ALL 0xff
3050d94caffSDavid Greenman #endif
3060d94caffSDavid Greenman 
3070d94caffSDavid Greenman #if PAGE_SIZE == 8192
3080d94caffSDavid Greenman #define VM_PAGE_BITS_ALL 0xffff
3090d94caffSDavid Greenman #endif
3100d94caffSDavid Greenman 
311827b2fa0SAlan Cox /* page allocation classes: */
3126d40c3d3SDavid Greenman #define VM_ALLOC_NORMAL		0
3136d40c3d3SDavid Greenman #define VM_ALLOC_INTERRUPT	1
3146d40c3d3SDavid Greenman #define VM_ALLOC_SYSTEM		2
315827b2fa0SAlan Cox #define	VM_ALLOC_CLASS_MASK	3
316827b2fa0SAlan Cox /* page allocation flags: */
3172c071f61SAlan Cox #define	VM_ALLOC_WIRED		0x20
318e78f35b3SJeff Roberson #define	VM_ALLOC_ZERO		0x40
319827b2fa0SAlan Cox #define	VM_ALLOC_RETRY		0x80	/* vm_page_grab() only */
3200d94caffSDavid Greenman 
3211b40f8c0SMatthew Dillon void vm_page_flag_set(vm_page_t m, unsigned short bits);
3221b40f8c0SMatthew Dillon void vm_page_flag_clear(vm_page_t m, unsigned short bits);
3231b40f8c0SMatthew Dillon void vm_page_busy(vm_page_t m);
3241b40f8c0SMatthew Dillon void vm_page_flash(vm_page_t m);
3251b40f8c0SMatthew Dillon void vm_page_io_start(vm_page_t m);
3261b40f8c0SMatthew Dillon void vm_page_io_finish(vm_page_t m);
3271b40f8c0SMatthew Dillon void vm_page_hold(vm_page_t mem);
3281b40f8c0SMatthew Dillon void vm_page_unhold(vm_page_t mem);
3291b40f8c0SMatthew Dillon void vm_page_protect(vm_page_t mem, int prot);
3301b40f8c0SMatthew Dillon void vm_page_copy(vm_page_t src_m, vm_page_t dest_m);
3311b40f8c0SMatthew Dillon void vm_page_free(vm_page_t m);
3321b40f8c0SMatthew Dillon void vm_page_free_zero(vm_page_t m);
3331b40f8c0SMatthew Dillon int vm_page_sleep_busy(vm_page_t m, int also_m_busy, const char *msg);
334e5f8bd94SAlan Cox int vm_page_sleep_if_busy(vm_page_t m, int also_m_busy, const char *msg);
3351b40f8c0SMatthew Dillon void vm_page_dirty(vm_page_t m);
3361b40f8c0SMatthew Dillon void vm_page_undirty(vm_page_t m);
3371b40f8c0SMatthew Dillon void vm_page_wakeup(vm_page_t m);
3381b40f8c0SMatthew Dillon 
3396d03d577SMatthew Dillon void vm_pageq_init(void);
3406d03d577SMatthew Dillon vm_page_t vm_pageq_add_new_page(vm_offset_t pa);
3412be21c5eSAlan Cox void vm_pageq_enqueue(int queue, vm_page_t m);
3426d03d577SMatthew Dillon void vm_pageq_remove_nowakeup(vm_page_t m);
3436d03d577SMatthew Dillon void vm_pageq_remove(vm_page_t m);
3446d03d577SMatthew Dillon vm_page_t vm_pageq_find(int basequeue, int index, boolean_t prefer_zero);
3456d03d577SMatthew Dillon void vm_pageq_requeue(vm_page_t m);
3466d03d577SMatthew Dillon 
3471b40f8c0SMatthew Dillon void vm_page_activate (vm_page_t);
3481b40f8c0SMatthew Dillon vm_page_t vm_page_alloc (vm_object_t, vm_pindex_t, int);
3491b40f8c0SMatthew Dillon vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int);
3501b40f8c0SMatthew Dillon void vm_page_cache (register vm_page_t);
3511b40f8c0SMatthew Dillon int vm_page_try_to_cache (vm_page_t);
3521b40f8c0SMatthew Dillon int vm_page_try_to_free (vm_page_t);
3531b40f8c0SMatthew Dillon void vm_page_dontneed (register vm_page_t);
3541b40f8c0SMatthew Dillon void vm_page_deactivate (vm_page_t);
3551b40f8c0SMatthew Dillon void vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t);
3561b40f8c0SMatthew Dillon vm_page_t vm_page_lookup (vm_object_t, vm_pindex_t);
3571b40f8c0SMatthew Dillon void vm_page_remove (vm_page_t);
3581b40f8c0SMatthew Dillon void vm_page_rename (vm_page_t, vm_object_t, vm_pindex_t);
3591b40f8c0SMatthew Dillon vm_offset_t vm_page_startup (vm_offset_t, vm_offset_t, vm_offset_t);
3601b40f8c0SMatthew Dillon void vm_page_unmanage (vm_page_t);
3611b40f8c0SMatthew Dillon void vm_page_unwire (vm_page_t, int);
3621b40f8c0SMatthew Dillon void vm_page_wire (vm_page_t);
3631b40f8c0SMatthew Dillon void vm_page_set_validclean (vm_page_t, int, int);
3641b40f8c0SMatthew Dillon void vm_page_set_dirty (vm_page_t, int, int);
3651b40f8c0SMatthew Dillon void vm_page_clear_dirty (vm_page_t, int, int);
3661b40f8c0SMatthew Dillon void vm_page_set_invalid (vm_page_t, int, int);
3671b40f8c0SMatthew Dillon int vm_page_is_valid (vm_page_t, int, int);
3681b40f8c0SMatthew Dillon void vm_page_test_dirty (vm_page_t);
3691b40f8c0SMatthew Dillon int vm_page_bits (int, int);
3708d17e694SJulian Elischer void vm_page_zero_invalid(vm_page_t m, boolean_t setvalid);
371faa273d5SMatthew Dillon void vm_page_free_toq(vm_page_t m);
3723516c025SPeter Wemm void vm_page_zero_idle_wakeup(void);
37398cb733cSKenneth D. Merry void vm_page_cowfault (vm_page_t);
37498cb733cSKenneth D. Merry void vm_page_cowsetup (vm_page_t);
37598cb733cSKenneth D. Merry void vm_page_cowclear (vm_page_t);
37698cb733cSKenneth D. Merry 
377c4473420SPeter Wemm #endif				/* _KERNEL */
378df8bae1dSRodney W. Grimes #endif				/* !_VM_PAGE_ */
379