xref: /freebsd/sys/vm/vm_page.h (revision b146f9e5d29e6b1045d8e7612875884338297a38)
160727d8bSWarner Losh /*-
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  * 4. Neither the name of the University nor the names of its contributors
17df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
18df8bae1dSRodney W. Grimes  *    without specific prior written permission.
19df8bae1dSRodney W. Grimes  *
20df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
31df8bae1dSRodney W. Grimes  *
323c4dd356SDavid Greenman  *	from: @(#)vm_page.h	8.2 (Berkeley) 12/13/93
33df8bae1dSRodney W. Grimes  *
34df8bae1dSRodney W. Grimes  *
35df8bae1dSRodney W. Grimes  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
36df8bae1dSRodney W. Grimes  * All rights reserved.
37df8bae1dSRodney W. Grimes  *
38df8bae1dSRodney W. Grimes  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
39df8bae1dSRodney W. Grimes  *
40df8bae1dSRodney W. Grimes  * Permission to use, copy, modify and distribute this software and
41df8bae1dSRodney W. Grimes  * its documentation is hereby granted, provided that both the copyright
42df8bae1dSRodney W. Grimes  * notice and this permission notice appear in all copies of the
43df8bae1dSRodney W. Grimes  * software, derivative works or modified versions, and any portions
44df8bae1dSRodney W. Grimes  * thereof, and that both notices appear in supporting documentation.
45df8bae1dSRodney W. Grimes  *
46df8bae1dSRodney W. Grimes  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
47df8bae1dSRodney W. Grimes  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
48df8bae1dSRodney W. Grimes  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
49df8bae1dSRodney W. Grimes  *
50df8bae1dSRodney W. Grimes  * Carnegie Mellon requests users of this software to return to
51df8bae1dSRodney W. Grimes  *
52df8bae1dSRodney W. Grimes  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
53df8bae1dSRodney W. Grimes  *  School of Computer Science
54df8bae1dSRodney W. Grimes  *  Carnegie Mellon University
55df8bae1dSRodney W. Grimes  *  Pittsburgh PA 15213-3890
56df8bae1dSRodney W. Grimes  *
57df8bae1dSRodney W. Grimes  * any improvements or extensions that they make and grant Carnegie the
58df8bae1dSRodney W. Grimes  * rights to redistribute these changes.
593c4dd356SDavid Greenman  *
60c3aac50fSPeter Wemm  * $FreeBSD$
61df8bae1dSRodney W. Grimes  */
62df8bae1dSRodney W. Grimes 
63df8bae1dSRodney W. Grimes /*
64df8bae1dSRodney W. Grimes  *	Resident memory system definitions.
65df8bae1dSRodney W. Grimes  */
66df8bae1dSRodney W. Grimes 
67df8bae1dSRodney W. Grimes #ifndef	_VM_PAGE_
68df8bae1dSRodney W. Grimes #define	_VM_PAGE_
69df8bae1dSRodney W. Grimes 
70f919ebdeSDavid Greenman #include <vm/pmap.h>
71069e9bc1SDoug Rabson 
72df8bae1dSRodney W. Grimes /*
73df8bae1dSRodney W. Grimes  *	Management of resident (logical) pages.
74df8bae1dSRodney W. Grimes  *
75df8bae1dSRodney W. Grimes  *	A small structure is kept for each resident
76df8bae1dSRodney W. Grimes  *	page, indexed by page number.  Each structure
77df8bae1dSRodney W. Grimes  *	is an element of several lists:
78df8bae1dSRodney W. Grimes  *
79df8bae1dSRodney W. Grimes  *		A hash table bucket used to quickly
80df8bae1dSRodney W. Grimes  *		perform object/offset lookups
81df8bae1dSRodney W. Grimes  *
82df8bae1dSRodney W. Grimes  *		A list of all pages for a given object,
83df8bae1dSRodney W. Grimes  *		so they can be quickly deactivated at
84df8bae1dSRodney W. Grimes  *		time of deallocation.
85df8bae1dSRodney W. Grimes  *
86df8bae1dSRodney W. Grimes  *		An ordered list of pages due for pageout.
87df8bae1dSRodney W. Grimes  *
88df8bae1dSRodney W. Grimes  *	In addition, the structure contains the object
89df8bae1dSRodney W. Grimes  *	and offset to which this page belongs (for pageout),
90df8bae1dSRodney W. Grimes  *	and sundry status bits.
91df8bae1dSRodney W. Grimes  *
92df8bae1dSRodney W. Grimes  *	Fields in this structure are locked either by the lock on the
93df8bae1dSRodney W. Grimes  *	object that the page belongs to (O) or by the lock on the page
94df8bae1dSRodney W. Grimes  *	queues (P).
954221e284SAlan Cox  *
964221e284SAlan Cox  *	The 'valid' and 'dirty' fields are distinct.  A page may have dirty
974221e284SAlan Cox  *	bits set without having associated valid bits set.  This is used by
984221e284SAlan Cox  *	NFS to implement piecemeal writes.
99df8bae1dSRodney W. Grimes  */
100df8bae1dSRodney W. Grimes 
101e3975643SJake Burkholder TAILQ_HEAD(pglist, vm_page);
102df8bae1dSRodney W. Grimes 
103df8bae1dSRodney W. Grimes struct vm_page {
104e3975643SJake Burkholder 	TAILQ_ENTRY(vm_page) pageq;	/* queue info for FIFO queue or free list (P) */
105e3975643SJake Burkholder 	TAILQ_ENTRY(vm_page) listq;	/* pages in same object (O) 	*/
106b86ec922SMatthew Dillon 	struct vm_page *left;		/* splay tree link (O)		*/
107b86ec922SMatthew Dillon 	struct vm_page *right;		/* splay tree link (O)		*/
108df8bae1dSRodney W. Grimes 
109df8bae1dSRodney W. Grimes 	vm_object_t object;		/* which object am I in (O,P)*/
110a316d390SJohn Dyson 	vm_pindex_t pindex;		/* offset into object (O,P) */
111227f9a1cSJake Burkholder 	vm_paddr_t phys_addr;		/* physical address of page */
1120385347cSPeter Wemm 	struct md_page md;		/* machine dependant stuff */
1135070c7f8SJohn Dyson 	u_short	queue;			/* page queue index */
1145070c7f8SJohn Dyson 	u_short	flags,			/* see below */
1155070c7f8SJohn Dyson 		pc;			/* page color */
116df8bae1dSRodney W. Grimes 	u_short wire_count;		/* wired down maps refs (P) */
1172bbb534bSMarcel Moolenaar 	u_int cow;			/* page cow mapping count */
11826f9a767SRodney W. Grimes 	short hold_count;		/* page hold count */
1195786be7cSAlan Cox 	u_short oflags;			/* page flags (O) */
120bd7e5f99SJohn Dyson 	u_char	act_count;		/* page usage count */
12191f7a860SAlan Cox 	u_char	busy;			/* page busy count (O) */
122bd7e5f99SJohn Dyson 	/* NOTE that these must support one bit per DEV_BSIZE in a page!!! */
123bd7e5f99SJohn Dyson 	/* so, on normal X86 kernels, they must be at least 8 bits wide */
124ecbb00a2SDoug Rabson #if PAGE_SIZE == 4096
12593dbd071SAlan Cox 	u_char	valid;			/* map of valid DEV_BSIZE chunks (O) */
126bd7e5f99SJohn Dyson 	u_char	dirty;			/* map of dirty DEV_BSIZE chunks */
127ecbb00a2SDoug Rabson #elif PAGE_SIZE == 8192
12893dbd071SAlan Cox 	u_short	valid;			/* map of valid DEV_BSIZE chunks (O) */
129ecbb00a2SDoug Rabson 	u_short	dirty;			/* map of dirty DEV_BSIZE chunks */
1301fa057c6SMarcel Moolenaar #elif PAGE_SIZE == 16384
13193dbd071SAlan Cox 	u_int valid;			/* map of valid DEV_BSIZE chunks (O) */
1321fa057c6SMarcel Moolenaar 	u_int dirty;			/* map of dirty DEV_BSIZE chunks */
1331fa057c6SMarcel Moolenaar #elif PAGE_SIZE == 32768
13493dbd071SAlan Cox 	u_long valid;			/* map of valid DEV_BSIZE chunks (O) */
1351fa057c6SMarcel Moolenaar 	u_long dirty;			/* map of dirty DEV_BSIZE chunks */
136ecbb00a2SDoug Rabson #endif
137df8bae1dSRodney W. Grimes };
138df8bae1dSRodney W. Grimes 
1395786be7cSAlan Cox /*
1405786be7cSAlan Cox  * Page flags stored in oflags:
1415786be7cSAlan Cox  *
1425786be7cSAlan Cox  * Access to these page flags is synchronized by the lock on the object
1435786be7cSAlan Cox  * containing the page (O).
1445786be7cSAlan Cox  */
1455786be7cSAlan Cox #define	VPO_WANTED	0x0002	/* someone is waiting for page */
1465786be7cSAlan Cox #define	VPO_SWAPINPROG	0x0200	/* swap I/O in progress on page */
147b146f9e5SAlan Cox #define	VPO_NOSYNC	0x0400	/* do not collect for syncer */
1485786be7cSAlan Cox 
14916bc6ff3SMarcel Moolenaar /* Make sure that u_long is at least 64 bits when PAGE_SIZE is 32K. */
15016bc6ff3SMarcel Moolenaar #if PAGE_SIZE == 32768
15116bc6ff3SMarcel Moolenaar #ifdef CTASSERT
15216bc6ff3SMarcel Moolenaar CTASSERT(sizeof(u_long) >= 8);
15316bc6ff3SMarcel Moolenaar #endif
15416bc6ff3SMarcel Moolenaar #endif
15516bc6ff3SMarcel Moolenaar 
156ef39c05bSAlexander Leidinger /* PQ_CACHE and PQ_FREE represents a PQ_NUMCOLORS consecutive queue. */
1573739d7daSMatt Jacob #define PQ_NONE		0
1583739d7daSMatt Jacob #define PQ_FREE		1
159ef39c05bSAlexander Leidinger #define PQ_INACTIVE	(page_queue_coloring.inactive)
160ef39c05bSAlexander Leidinger #define PQ_ACTIVE	(page_queue_coloring.active)
161ef39c05bSAlexander Leidinger #define PQ_CACHE	(page_queue_coloring.cache)
162ef39c05bSAlexander Leidinger #define PQ_HOLD		(page_queue_coloring.hold)
163ef39c05bSAlexander Leidinger #define PQ_COUNT	(page_queue_coloring.count)
164ef39c05bSAlexander Leidinger #define PQ_MAXCOLORS	1024
165ef39c05bSAlexander Leidinger #define PQ_MAXCOUNT	(4 + 2 * PQ_MAXCOLORS)
166ef39c05bSAlexander Leidinger #define PQ_NUMCOLORS	(page_queue_coloring.numcolors)
167ef39c05bSAlexander Leidinger #define PQ_PRIME1	(page_queue_coloring.prime1)
168ef39c05bSAlexander Leidinger #define PQ_PRIME2	(page_queue_coloring.prime2)
169ef39c05bSAlexander Leidinger #define PQ_COLORMASK	(page_queue_coloring.colormask)
170ef39c05bSAlexander Leidinger #define PQ_MAXLENGTH	(page_queue_coloring.maxlength)
171ef39c05bSAlexander Leidinger 
172ef39c05bSAlexander Leidinger /* Returns the real queue a page is on. */
173ef39c05bSAlexander Leidinger #define VM_PAGE_GETQUEUE(m)	((m)->queue)
174ef39c05bSAlexander Leidinger 
175ef39c05bSAlexander Leidinger /* Returns the well known queue a page is on. */
176ef39c05bSAlexander Leidinger #define VM_PAGE_GETKNOWNQUEUE1(m)	((m)->queue - (m)->pc)
177ef39c05bSAlexander Leidinger #define VM_PAGE_GETKNOWNQUEUE2(m)	VM_PAGE_GETQUEUE(m)
178ef39c05bSAlexander Leidinger 
179ef39c05bSAlexander Leidinger /* Given the real queue number and a page color return the well know queue. */
180ef39c05bSAlexander Leidinger #define VM_PAGE_RESOLVEQUEUE(m, q)	((q) - (m)->pc)
181ef39c05bSAlexander Leidinger 
182ef39c05bSAlexander Leidinger /* Returns true if the page is in the named well known queue. */
183ef39c05bSAlexander Leidinger #define VM_PAGE_INQUEUE1(m, q)	(VM_PAGE_GETKNOWNQUEUE1(m) == (q))
184ef39c05bSAlexander Leidinger #define VM_PAGE_INQUEUE2(m, q)	(VM_PAGE_GETKNOWNQUEUE2(m) == (q))
185ef39c05bSAlexander Leidinger 
186ef39c05bSAlexander Leidinger /* Sets the queue a page is on. */
187ef39c05bSAlexander Leidinger #define VM_PAGE_SETQUEUE1(m, q)	(VM_PAGE_GETQUEUE(m) = (q) + (m)->pc)
188ef39c05bSAlexander Leidinger #define VM_PAGE_SETQUEUE2(m, q)	(VM_PAGE_GETQUEUE(m) = (q))
1895070c7f8SJohn Dyson 
190be72f788SAlan Cox struct vpgqueues {
191be72f788SAlan Cox 	struct pglist pl;
1925070c7f8SJohn Dyson 	int	*cnt;
1935d2aec89SAlan Cox 	int	lcnt;
194be72f788SAlan Cox };
195be72f788SAlan Cox 
196ef39c05bSAlexander Leidinger struct pq_coloring {
197ef39c05bSAlexander Leidinger 	int numcolors;
198ef39c05bSAlexander Leidinger 	int colormask;
199ef39c05bSAlexander Leidinger 	int prime1;
200ef39c05bSAlexander Leidinger 	int prime2;
201ef39c05bSAlexander Leidinger 	int inactive;
202ef39c05bSAlexander Leidinger 	int active;
203ef39c05bSAlexander Leidinger 	int cache;
204ef39c05bSAlexander Leidinger 	int hold;
205ef39c05bSAlexander Leidinger 	int count;
206ef39c05bSAlexander Leidinger 	int maxlength;
207ef39c05bSAlexander Leidinger };
20870c17636SAlan Cox 
209ef39c05bSAlexander Leidinger extern struct vpgqueues vm_page_queues[PQ_MAXCOUNT];
210ef39c05bSAlexander Leidinger extern struct mtx vm_page_queue_free_mtx;
211ef39c05bSAlexander Leidinger extern struct pq_coloring page_queue_coloring;
2120237469fSJulian Elischer 
213df8bae1dSRodney W. Grimes /*
214df8bae1dSRodney W. Grimes  * These are the flags defined for vm_page.
215df8bae1dSRodney W. Grimes  *
2168b03c8edSMatthew Dillon  * Note: PG_UNMANAGED (used by OBJT_PHYS) indicates that the page is
2178b03c8edSMatthew Dillon  * 	 not under PV management but otherwise should be treated as a
2188b03c8edSMatthew Dillon  *	 normal page.  Pages not under PV management cannot be paged out
2198b03c8edSMatthew Dillon  *	 via the object/vm_page_t because there is no knowledge of their
2208b03c8edSMatthew Dillon  *	 pte mappings, nor can they be removed from their objects via
2218b03c8edSMatthew Dillon  *	 the object, and such pages are also not on any PQ queue.
222df8bae1dSRodney W. Grimes  */
2231c7c3c6aSMatthew Dillon #define	PG_BUSY		0x0001		/* page is in transit (O) */
2242b6b0df7SMatthew Dillon #define PG_WINATCFLS	0x0004		/* flush dirty page on inactive q */
2251c7c3c6aSMatthew Dillon #define	PG_FICTITIOUS	0x0008		/* physical page doesn't exist (O) */
2261c7c3c6aSMatthew Dillon #define	PG_WRITEABLE	0x0010		/* page is mapped writeable */
2271c7c3c6aSMatthew Dillon #define	PG_ZERO		0x0040		/* page is zeroed */
2281c7c3c6aSMatthew Dillon #define PG_REFERENCED	0x0080		/* page has been referenced */
2291c7c3c6aSMatthew Dillon #define PG_CLEANCHK	0x0100		/* page will be checked for cleaning */
2308b03c8edSMatthew Dillon #define PG_UNMANAGED	0x0800		/* No PV management for page */
231936524aaSMatthew Dillon #define PG_MARKER	0x1000		/* special queue marker page */
23299571dc3SJeff Roberson #define	PG_SLAB		0x2000		/* object pointer is actually a slab */
233df8bae1dSRodney W. Grimes 
23424a1cce3SDavid Greenman /*
23524a1cce3SDavid Greenman  * Misc constants.
23624a1cce3SDavid Greenman  */
23724a1cce3SDavid Greenman #define ACT_DECLINE		1
23824a1cce3SDavid Greenman #define ACT_ADVANCE		3
23938efa82bSJohn Dyson #define ACT_INIT		5
2405070c7f8SJohn Dyson #define ACT_MAX			64
241df8bae1dSRodney W. Grimes 
242c4473420SPeter Wemm #ifdef _KERNEL
243df8bae1dSRodney W. Grimes /*
24424a1cce3SDavid Greenman  * Each pageable resident page falls into one of four lists:
245df8bae1dSRodney W. Grimes  *
246df8bae1dSRodney W. Grimes  *	free
247df8bae1dSRodney W. Grimes  *		Available for allocation now.
24824a1cce3SDavid Greenman  *
24924a1cce3SDavid Greenman  * The following are all LRU sorted:
25024a1cce3SDavid Greenman  *
25124a1cce3SDavid Greenman  *	cache
25224a1cce3SDavid Greenman  *		Almost available for allocation. Still in an
25324a1cce3SDavid Greenman  *		object, but clean and immediately freeable at
25424a1cce3SDavid Greenman  *		non-interrupt times.
25524a1cce3SDavid Greenman  *
256df8bae1dSRodney W. Grimes  *	inactive
2576c5e9bbdSMike Pritchard  *		Low activity, candidates for reclamation.
258df8bae1dSRodney W. Grimes  *		This is the list of pages that should be
259df8bae1dSRodney W. Grimes  *		paged out next.
26024a1cce3SDavid Greenman  *
261df8bae1dSRodney W. Grimes  *	active
26224a1cce3SDavid Greenman  *		Pages that are "active" i.e. they have been
26324a1cce3SDavid Greenman  *		recently referenced.
26410ad4d48SJohn Dyson  *
26510ad4d48SJohn Dyson  *	zero
26610ad4d48SJohn Dyson  *		Pages that are really free and have been pre-zeroed
26710ad4d48SJohn Dyson  *
268df8bae1dSRodney W. Grimes  */
269df8bae1dSRodney W. Grimes 
270a316d390SJohn Dyson extern int vm_page_zero_count;
271a316d390SJohn Dyson 
2720d94caffSDavid Greenman extern vm_page_t vm_page_array;		/* First resident page in table */
2730385347cSPeter Wemm extern int vm_page_array_size;		/* number of vm_page_t's */
2740d94caffSDavid Greenman extern long first_page;			/* first physical page number */
2750d94caffSDavid Greenman 
276df8bae1dSRodney W. Grimes #define VM_PAGE_TO_PHYS(entry)	((entry)->phys_addr)
277df8bae1dSRodney W. Grimes 
278df8bae1dSRodney W. Grimes #define PHYS_TO_VM_PAGE(pa) \
279df8bae1dSRodney W. Grimes 		(&vm_page_array[atop(pa) - first_page ])
280df8bae1dSRodney W. Grimes 
2811f545269SAlan Cox extern struct mtx vm_page_queue_mtx;
2821f545269SAlan Cox #define vm_page_lock_queues()   mtx_lock(&vm_page_queue_mtx)
2831f545269SAlan Cox #define vm_page_unlock_queues() mtx_unlock(&vm_page_queue_mtx)
2848f9110f6SJohn Dyson 
2850d94caffSDavid Greenman #if PAGE_SIZE == 4096
28621a708cfSMarcel Moolenaar #define VM_PAGE_BITS_ALL 0xffu
28721a708cfSMarcel Moolenaar #elif PAGE_SIZE == 8192
28821a708cfSMarcel Moolenaar #define VM_PAGE_BITS_ALL 0xffffu
28921a708cfSMarcel Moolenaar #elif PAGE_SIZE == 16384
29021a708cfSMarcel Moolenaar #define VM_PAGE_BITS_ALL 0xffffffffu
29121a708cfSMarcel Moolenaar #elif PAGE_SIZE == 32768
29221a708cfSMarcel Moolenaar #define VM_PAGE_BITS_ALL 0xfffffffffffffffflu
2930d94caffSDavid Greenman #endif
2940d94caffSDavid Greenman 
295827b2fa0SAlan Cox /* page allocation classes: */
2966d40c3d3SDavid Greenman #define VM_ALLOC_NORMAL		0
2976d40c3d3SDavid Greenman #define VM_ALLOC_INTERRUPT	1
2986d40c3d3SDavid Greenman #define VM_ALLOC_SYSTEM		2
299827b2fa0SAlan Cox #define	VM_ALLOC_CLASS_MASK	3
300827b2fa0SAlan Cox /* page allocation flags: */
301026aa839SJeff Roberson #define	VM_ALLOC_WIRED		0x0020	/* non pageable */
302026aa839SJeff Roberson #define	VM_ALLOC_ZERO		0x0040	/* Try to obtain a zeroed page */
303026aa839SJeff Roberson #define	VM_ALLOC_RETRY		0x0080	/* vm_page_grab() only */
304026aa839SJeff Roberson #define	VM_ALLOC_NOOBJ		0x0100	/* No associated object */
3050f9f9bcbSAlan Cox #define	VM_ALLOC_NOBUSY		0x0200	/* Do not busy the page */
3060d94caffSDavid Greenman 
3071b40f8c0SMatthew Dillon void vm_page_flag_set(vm_page_t m, unsigned short bits);
3081b40f8c0SMatthew Dillon void vm_page_flag_clear(vm_page_t m, unsigned short bits);
3091b40f8c0SMatthew Dillon void vm_page_busy(vm_page_t m);
3101b40f8c0SMatthew Dillon void vm_page_flash(vm_page_t m);
3111b40f8c0SMatthew Dillon void vm_page_io_start(vm_page_t m);
3121b40f8c0SMatthew Dillon void vm_page_io_finish(vm_page_t m);
3131b40f8c0SMatthew Dillon void vm_page_hold(vm_page_t mem);
3141b40f8c0SMatthew Dillon void vm_page_unhold(vm_page_t mem);
3151b40f8c0SMatthew Dillon void vm_page_free(vm_page_t m);
3161b40f8c0SMatthew Dillon void vm_page_free_zero(vm_page_t m);
317e5f8bd94SAlan Cox int vm_page_sleep_if_busy(vm_page_t m, int also_m_busy, const char *msg);
3181b40f8c0SMatthew Dillon void vm_page_dirty(vm_page_t m);
3191b40f8c0SMatthew Dillon void vm_page_wakeup(vm_page_t m);
3201b40f8c0SMatthew Dillon 
3216d03d577SMatthew Dillon void vm_pageq_init(void);
322227f9a1cSJake Burkholder vm_page_t vm_pageq_add_new_page(vm_paddr_t pa);
3232be21c5eSAlan Cox void vm_pageq_enqueue(int queue, vm_page_t m);
3246d03d577SMatthew Dillon void vm_pageq_remove_nowakeup(vm_page_t m);
3256d03d577SMatthew Dillon void vm_pageq_remove(vm_page_t m);
3266d03d577SMatthew Dillon vm_page_t vm_pageq_find(int basequeue, int index, boolean_t prefer_zero);
3276d03d577SMatthew Dillon void vm_pageq_requeue(vm_page_t m);
3286d03d577SMatthew Dillon 
3291b40f8c0SMatthew Dillon void vm_page_activate (vm_page_t);
3301b40f8c0SMatthew Dillon vm_page_t vm_page_alloc (vm_object_t, vm_pindex_t, int);
3314362fadaSBrian Feldman vm_page_t vm_page_alloc_contig (vm_pindex_t, vm_paddr_t, vm_paddr_t,
3324362fadaSBrian Feldman 	    vm_offset_t, vm_offset_t);
3334362fadaSBrian Feldman void vm_page_release_contig (vm_page_t, vm_pindex_t);
3341b40f8c0SMatthew Dillon vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int);
3351b40f8c0SMatthew Dillon void vm_page_cache (register vm_page_t);
3361b40f8c0SMatthew Dillon int vm_page_try_to_cache (vm_page_t);
3371b40f8c0SMatthew Dillon int vm_page_try_to_free (vm_page_t);
3381b40f8c0SMatthew Dillon void vm_page_dontneed (register vm_page_t);
3391b40f8c0SMatthew Dillon void vm_page_deactivate (vm_page_t);
3401b40f8c0SMatthew Dillon void vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t);
3411b40f8c0SMatthew Dillon vm_page_t vm_page_lookup (vm_object_t, vm_pindex_t);
3421b40f8c0SMatthew Dillon void vm_page_remove (vm_page_t);
3431b40f8c0SMatthew Dillon void vm_page_rename (vm_page_t, vm_object_t, vm_pindex_t);
344ab42316cSAlan Cox vm_page_t vm_page_select_cache(int);
345ada2a050SAlan Cox vm_page_t vm_page_splay(vm_pindex_t, vm_page_t);
346889eb0fcSAlan Cox vm_offset_t vm_page_startup(vm_offset_t vaddr);
3471b40f8c0SMatthew Dillon void vm_page_unmanage (vm_page_t);
3481b40f8c0SMatthew Dillon void vm_page_unwire (vm_page_t, int);
3491b40f8c0SMatthew Dillon void vm_page_wire (vm_page_t);
3501b40f8c0SMatthew Dillon void vm_page_set_validclean (vm_page_t, int, int);
3511b40f8c0SMatthew Dillon void vm_page_clear_dirty (vm_page_t, int, int);
3521b40f8c0SMatthew Dillon void vm_page_set_invalid (vm_page_t, int, int);
3531b40f8c0SMatthew Dillon int vm_page_is_valid (vm_page_t, int, int);
3541b40f8c0SMatthew Dillon void vm_page_test_dirty (vm_page_t);
3551b40f8c0SMatthew Dillon int vm_page_bits (int, int);
3568d17e694SJulian Elischer void vm_page_zero_invalid(vm_page_t m, boolean_t setvalid);
357faa273d5SMatthew Dillon void vm_page_free_toq(vm_page_t m);
3583516c025SPeter Wemm void vm_page_zero_idle_wakeup(void);
35998cb733cSKenneth D. Merry void vm_page_cowfault (vm_page_t);
36098cb733cSKenneth D. Merry void vm_page_cowsetup (vm_page_t);
36198cb733cSKenneth D. Merry void vm_page_cowclear (vm_page_t);
36298cb733cSKenneth D. Merry 
363f3b676f0SAlan Cox /*
364f3b676f0SAlan Cox  *	vm_page_undirty:
365f3b676f0SAlan Cox  *
366f3b676f0SAlan Cox  *	Set page to not be dirty.  Note: does not clear pmap modify bits
367f3b676f0SAlan Cox  */
368f3b676f0SAlan Cox static __inline void
369f3b676f0SAlan Cox vm_page_undirty(vm_page_t m)
370f3b676f0SAlan Cox {
371f3b676f0SAlan Cox 	m->dirty = 0;
372f3b676f0SAlan Cox }
373f3b676f0SAlan Cox 
374c4473420SPeter Wemm #endif				/* _KERNEL */
375df8bae1dSRodney W. Grimes #endif				/* !_VM_PAGE_ */
376