Deleted Added
full compact
vm_page.h (4461) vm_page.h (5455)
1/*
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 25 unchanged lines hidden (view full) ---

35 *
36 * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93
37 *
38 *
39 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
40 * All rights reserved.
41 *
42 * Authors: Avadis Tevanian, Jr., Michael Wayne Young
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 25 unchanged lines hidden (view full) ---

35 *
36 * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93
37 *
38 *
39 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
40 * All rights reserved.
41 *
42 * Authors: Avadis Tevanian, Jr., Michael Wayne Young
43 *
43 *
44 * Permission to use, copy, modify and distribute this software and
45 * its documentation is hereby granted, provided that both the copyright
46 * notice and this permission notice appear in all copies of the
47 * software, derivative works or modified versions, and any portions
48 * thereof, and that both notices appear in supporting documentation.
44 * Permission to use, copy, modify and distribute this software and
45 * its documentation is hereby granted, provided that both the copyright
46 * notice and this permission notice appear in all copies of the
47 * software, derivative works or modified versions, and any portions
48 * thereof, and that both notices appear in supporting documentation.
49 *
50 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
51 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
49 *
50 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
51 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
52 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
52 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
53 *
53 *
54 * Carnegie Mellon requests users of this software to return to
55 *
56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
54 * Carnegie Mellon requests users of this software to return to
55 *
56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
64 * $Id: vm_page.h,v 1.9 1994/10/21 01:19:28 wollman Exp $
64 * $Id: vm_page.h,v 1.10 1994/11/14 08:19:08 bde Exp $
65 */
66
67/*
68 * Resident memory system definitions.
69 */
70
71#ifndef _VM_PAGE_
72#define _VM_PAGE_

--- 21 unchanged lines hidden (view full) ---

94 * Fields in this structure are locked either by the lock on the
95 * object that the page belongs to (O) or by the lock on the page
96 * queues (P).
97 */
98
99TAILQ_HEAD(pglist, vm_page);
100
101struct vm_page {
65 */
66
67/*
68 * Resident memory system definitions.
69 */
70
71#ifndef _VM_PAGE_
72#define _VM_PAGE_

--- 21 unchanged lines hidden (view full) ---

94 * Fields in this structure are locked either by the lock on the
95 * object that the page belongs to (O) or by the lock on the page
96 * queues (P).
97 */
98
99TAILQ_HEAD(pglist, vm_page);
100
101struct vm_page {
102 TAILQ_ENTRY(vm_page) pageq; /* queue info for FIFO
103 * queue or free list (P) */
104 TAILQ_ENTRY(vm_page) hashq; /* hash table links (O)*/
105 TAILQ_ENTRY(vm_page) listq; /* pages in same object (O)*/
102 TAILQ_ENTRY(vm_page) pageq; /* queue info for FIFO queue or free list (P) */
103 TAILQ_ENTRY(vm_page) hashq; /* hash table links (O) */
104 TAILQ_ENTRY(vm_page) listq; /* pages in same object (O) */
106
105
107 vm_object_t object; /* which object am I in (O,P)*/
108 vm_offset_t offset; /* offset into object (O,P) */
106 vm_object_t object; /* which object am I in (O,P) */
107 vm_offset_t offset; /* offset into object (O,P) */
108 vm_offset_t phys_addr; /* physical address of page */
109
109
110 u_short wire_count; /* wired down maps refs (P) */
111 u_short flags; /* see below */
112 short hold_count; /* page hold count */
113 u_short act_count; /* page usage count */
114 u_short busy; /* page busy count */
115
116 vm_offset_t phys_addr; /* physical address of page */
110 u_short wire_count; /* wired down maps refs (P) */
111 u_short flags; /* see below */
112 short hold_count; /* page hold count */
113 u_short act_count; /* page usage count */
114 u_short bmapped; /* number of buffers mapped */
115 u_short busy; /* page busy count */
116 u_short valid; /* map of valid DEV_BSIZE chunks */
117 u_short dirty; /* map of dirty DEV_BSIZE chunks */
117};
118
119/*
120 * These are the flags defined for vm_page.
121 *
122 * Note: PG_FILLED and PG_DIRTY are added for the filesystems.
123 */
124#define PG_INACTIVE 0x0001 /* page is in inactive list (P) */
125#define PG_ACTIVE 0x0002 /* page is in active list (P) */
118};
119
120/*
121 * These are the flags defined for vm_page.
122 *
123 * Note: PG_FILLED and PG_DIRTY are added for the filesystems.
124 */
125#define PG_INACTIVE 0x0001 /* page is in inactive list (P) */
126#define PG_ACTIVE 0x0002 /* page is in active list (P) */
126#define PG_LAUNDRY 0x0004 /* page is being cleaned now (P)*/
127#define PG_LAUNDRY 0x0004 /* page is being cleaned now (P) */
127#define PG_CLEAN 0x0008 /* page has not been modified */
128#define PG_BUSY 0x0010 /* page is in transit (O) */
129#define PG_WANTED 0x0020 /* someone is waiting for page (O) */
130#define PG_TABLED 0x0040 /* page is in VP table (O) */
131#define PG_COPYONWRITE 0x0080 /* must copy page before changing (O) */
132#define PG_FICTITIOUS 0x0100 /* physical page doesn't exist (O) */
133#define PG_FAKE 0x0200 /* page is placeholder for pagein (O) */
134#define PG_FILLED 0x0400 /* client flag to set when filled */
135#define PG_DIRTY 0x0800 /* client flag to set when dirty */
136#define PG_REFERENCED 0x1000 /* page has been referenced */
137#define PG_VMIO 0x2000 /* VMIO flag */
128#define PG_CLEAN 0x0008 /* page has not been modified */
129#define PG_BUSY 0x0010 /* page is in transit (O) */
130#define PG_WANTED 0x0020 /* someone is waiting for page (O) */
131#define PG_TABLED 0x0040 /* page is in VP table (O) */
132#define PG_COPYONWRITE 0x0080 /* must copy page before changing (O) */
133#define PG_FICTITIOUS 0x0100 /* physical page doesn't exist (O) */
134#define PG_FAKE 0x0200 /* page is placeholder for pagein (O) */
135#define PG_FILLED 0x0400 /* client flag to set when filled */
136#define PG_DIRTY 0x0800 /* client flag to set when dirty */
137#define PG_REFERENCED 0x1000 /* page has been referenced */
138#define PG_VMIO 0x2000 /* VMIO flag */
138#define PG_PAGEROWNED 0x4000 /* DEBUG: async paging op in progress */
139#define PG_CACHE 0x4000 /* On VMIO cache */
139#define PG_FREE 0x8000 /* page is in free list */
140
141#if VM_PAGE_DEBUG
142#define VM_PAGE_CHECK(mem) { \
143 if ((((unsigned int) mem) < ((unsigned int) &vm_page_array[0])) || \
144 (((unsigned int) mem) > \
145 ((unsigned int) &vm_page_array[last_page-first_page])) || \
146 ((mem->flags & (PG_ACTIVE | PG_INACTIVE)) == \
147 (PG_ACTIVE | PG_INACTIVE))) \
148 panic("vm_page_check: not valid!"); \
149}
140#define PG_FREE 0x8000 /* page is in free list */
141
142#if VM_PAGE_DEBUG
143#define VM_PAGE_CHECK(mem) { \
144 if ((((unsigned int) mem) < ((unsigned int) &vm_page_array[0])) || \
145 (((unsigned int) mem) > \
146 ((unsigned int) &vm_page_array[last_page-first_page])) || \
147 ((mem->flags & (PG_ACTIVE | PG_INACTIVE)) == \
148 (PG_ACTIVE | PG_INACTIVE))) \
149 panic("vm_page_check: not valid!"); \
150}
150#else /* VM_PAGE_DEBUG */
151#else /* VM_PAGE_DEBUG */
151#define VM_PAGE_CHECK(mem)
152#define VM_PAGE_CHECK(mem)
152#endif /* VM_PAGE_DEBUG */
153#endif /* VM_PAGE_DEBUG */
153
154#ifdef KERNEL
155/*
156 * Each pageable resident page falls into one of three lists:
157 *
154
155#ifdef KERNEL
156/*
157 * Each pageable resident page falls into one of three lists:
158 *
158 * free
159 * free
159 * Available for allocation now.
160 * inactive
161 * Not referenced in any map, but still has an
162 * object/offset-page mapping, and may be dirty.
163 * This is the list of pages that should be
164 * paged out next.
165 * active
166 * A list of pages which have been placed in
167 * at least one physical map. This list is
168 * ordered, in LRU-like fashion.
169 */
170
160 * Available for allocation now.
161 * inactive
162 * Not referenced in any map, but still has an
163 * object/offset-page mapping, and may be dirty.
164 * This is the list of pages that should be
165 * paged out next.
166 * active
167 * A list of pages which have been placed in
168 * at least one physical map. This list is
169 * ordered, in LRU-like fashion.
170 */
171
171extern
172struct pglist vm_page_queue_free; /* memory free queue */
173extern
174struct pglist vm_page_queue_active; /* active memory queue */
175extern
176struct pglist vm_page_queue_inactive; /* inactive memory queue */
172extern struct pglist vm_page_queue_free; /* memory free queue */
173extern struct pglist vm_page_queue_active; /* active memory queue */
174extern struct pglist vm_page_queue_inactive; /* inactive memory queue */
175extern struct pglist vm_page_queue_cache; /* cache memory queue */
177
176
178extern
179vm_page_t vm_page_array; /* First resident page in table */
180extern
181long first_page; /* first physical page number */
182 /* ... represented in vm_page_array */
183extern
184long last_page; /* last physical page number */
185 /* ... represented in vm_page_array */
186 /* [INCLUSIVE] */
187extern
188vm_offset_t first_phys_addr; /* physical address for first_page */
189extern
190vm_offset_t last_phys_addr; /* physical address for last_page */
177extern vm_page_t vm_page_array; /* First resident page in table */
178extern long first_page; /* first physical page number */
191
179
180 /* ... represented in vm_page_array */
181extern long last_page; /* last physical page number */
182
183 /* ... represented in vm_page_array */
184 /* [INCLUSIVE] */
185extern vm_offset_t first_phys_addr; /* physical address for first_page */
186extern vm_offset_t last_phys_addr; /* physical address for last_page */
187
192#define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr)
193
194#define IS_VM_PHYSADDR(pa) \
195 ((pa) >= first_phys_addr && (pa) <= last_phys_addr)
196
197#define PHYS_TO_VM_PAGE(pa) \
198 (&vm_page_array[atop(pa) - first_page ])
199
188#define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr)
189
190#define IS_VM_PHYSADDR(pa) \
191 ((pa) >= first_phys_addr && (pa) <= last_phys_addr)
192
193#define PHYS_TO_VM_PAGE(pa) \
194 (&vm_page_array[atop(pa) - first_page ])
195
200extern
201simple_lock_data_t vm_page_queue_lock; /* lock on active and inactive
202 page queues */
203extern /* lock on free page queue */
204simple_lock_data_t vm_page_queue_free_lock;
196extern simple_lock_data_t vm_page_queue_lock; /* lock on active and inactive page queues */
197extern simple_lock_data_t vm_page_queue_free_lock; /* lock on free page queue */
205
206/*
207 * Functions implemented as macros
208 */
209
210#define PAGE_ASSERT_WAIT(m, interruptible) { \
211 (m)->flags |= PG_WANTED; \
212 assert_wait((int) (m), (interruptible)); \

--- 13 unchanged lines hidden (view full) ---

226#define vm_page_set_modified(m) { (m)->flags &= ~PG_CLEAN; }
227
228#define VM_PAGE_INIT(mem, object, offset) { \
229 (mem)->flags = PG_BUSY | PG_CLEAN | PG_FAKE; \
230 vm_page_insert((mem), (object), (offset)); \
231 (mem)->wire_count = 0; \
232 (mem)->hold_count = 0; \
233 (mem)->act_count = 0; \
198
199/*
200 * Functions implemented as macros
201 */
202
203#define PAGE_ASSERT_WAIT(m, interruptible) { \
204 (m)->flags |= PG_WANTED; \
205 assert_wait((int) (m), (interruptible)); \

--- 13 unchanged lines hidden (view full) ---

219#define vm_page_set_modified(m) { (m)->flags &= ~PG_CLEAN; }
220
221#define VM_PAGE_INIT(mem, object, offset) { \
222 (mem)->flags = PG_BUSY | PG_CLEAN | PG_FAKE; \
223 vm_page_insert((mem), (object), (offset)); \
224 (mem)->wire_count = 0; \
225 (mem)->hold_count = 0; \
226 (mem)->act_count = 0; \
227 (mem)->busy = 0; \
228 (mem)->valid = 0; \
229 (mem)->dirty = 0; \
230 (mem)->bmapped = 0; \
234}
235
231}
232
236void vm_page_activate __P((vm_page_t));
237vm_page_t vm_page_alloc __P((vm_object_t, vm_offset_t));
238void vm_page_copy __P((vm_page_t, vm_page_t));
239void vm_page_deactivate __P((vm_page_t));
240void vm_page_free __P((vm_page_t));
241void vm_page_insert __P((vm_page_t, vm_object_t, vm_offset_t));
242vm_page_t vm_page_lookup __P((vm_object_t, vm_offset_t));
243void vm_page_remove __P((vm_page_t));
244void vm_page_rename __P((vm_page_t, vm_object_t, vm_offset_t));
245vm_offset_t vm_page_startup __P((vm_offset_t, vm_offset_t, vm_offset_t));
246void vm_page_unwire __P((vm_page_t));
247void vm_page_wire __P((vm_page_t));
248boolean_t vm_page_zero_fill __P((vm_page_t));
233#if PAGE_SIZE == 4096
234#define VM_PAGE_BITS_ALL 0xff
235#endif
249
236
237#if PAGE_SIZE == 8192
238#define VM_PAGE_BITS_ALL 0xffff
239#endif
250
240
241
242void vm_page_activate __P((vm_page_t));
243vm_page_t vm_page_alloc __P((vm_object_t, vm_offset_t, int));
244void vm_page_copy __P((vm_page_t, vm_page_t));
245void vm_page_deactivate __P((vm_page_t));
246void vm_page_free __P((vm_page_t));
247void vm_page_insert __P((vm_page_t, vm_object_t, vm_offset_t));
248vm_page_t vm_page_lookup __P((vm_object_t, vm_offset_t));
249void vm_page_remove __P((vm_page_t));
250void vm_page_rename __P((vm_page_t, vm_object_t, vm_offset_t));
251vm_offset_t vm_page_startup __P((vm_offset_t, vm_offset_t, vm_offset_t));
252void vm_page_unwire __P((vm_page_t));
253void vm_page_wire __P((vm_page_t));
254boolean_t vm_page_zero_fill __P((vm_page_t));
255void vm_page_set_dirty __P((vm_page_t, int, int));
256void vm_page_set_clean __P((vm_page_t, int, int));
257int vm_page_is_clean __P((vm_page_t, int, int));
258void vm_page_set_valid __P((vm_page_t, int, int));
259void vm_page_set_invalid __P((vm_page_t, int, int));
260int vm_page_is_valid __P((vm_page_t, int, int));
261void vm_page_test_dirty __P((vm_page_t));
262
263
251/*
252 * Keep page from being freed by the page daemon
253 * much of the same effect as wiring, except much lower
254 * overhead and should be used only for *very* temporary
255 * holding ("wiring").
256 */
257static __inline void
258vm_page_hold(vm_page_t mem)

--- 4 unchanged lines hidden (view full) ---

263#ifdef DIAGNOSTIC
264#include <sys/systm.h> /* make GCC shut up */
265#endif
266
267static __inline void
268vm_page_unhold(vm_page_t mem)
269{
270#ifdef DIAGNOSTIC
264/*
265 * Keep page from being freed by the page daemon
266 * much of the same effect as wiring, except much lower
267 * overhead and should be used only for *very* temporary
268 * holding ("wiring").
269 */
270static __inline void
271vm_page_hold(vm_page_t mem)

--- 4 unchanged lines hidden (view full) ---

276#ifdef DIAGNOSTIC
277#include <sys/systm.h> /* make GCC shut up */
278#endif
279
280static __inline void
281vm_page_unhold(vm_page_t mem)
282{
283#ifdef DIAGNOSTIC
271 if( --mem->hold_count < 0)
284 if (--mem->hold_count < 0)
272 panic("vm_page_unhold: hold count < 0!!!");
273#else
274 --mem->hold_count;
275#endif
276}
277
285 panic("vm_page_unhold: hold count < 0!!!");
286#else
287 --mem->hold_count;
288#endif
289}
290
278#endif /* KERNEL */
291#endif /* KERNEL */
279
292
280#endif /* !_VM_PAGE_ */
293#endif /* !_VM_PAGE_ */