1139825Simp/*- 21541Srgrimes * Copyright (c) 1991, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley by 61541Srgrimes * The Mach Operating System project at Carnegie-Mellon University. 71541Srgrimes * 81541Srgrimes * Redistribution and use in source and binary forms, with or without 91541Srgrimes * modification, are permitted provided that the following conditions 101541Srgrimes * are met: 111541Srgrimes * 1. Redistributions of source code must retain the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer. 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 4. Neither the name of the University nor the names of its contributors 171541Srgrimes * may be used to endorse or promote products derived from this software 181541Srgrimes * without specific prior written permission. 191541Srgrimes * 201541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301541Srgrimes * SUCH DAMAGE. 311541Srgrimes * 321817Sdg * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93 331541Srgrimes * 341541Srgrimes * 351541Srgrimes * Copyright (c) 1987, 1990 Carnegie-Mellon University. 361541Srgrimes * All rights reserved. 371541Srgrimes * 381541Srgrimes * Authors: Avadis Tevanian, Jr., Michael Wayne Young 395455Sdg * 401541Srgrimes * Permission to use, copy, modify and distribute this software and 411541Srgrimes * its documentation is hereby granted, provided that both the copyright 421541Srgrimes * notice and this permission notice appear in all copies of the 431541Srgrimes * software, derivative works or modified versions, and any portions 441541Srgrimes * thereof, and that both notices appear in supporting documentation. 455455Sdg * 465455Sdg * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 475455Sdg * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 481541Srgrimes * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 495455Sdg * 501541Srgrimes * Carnegie Mellon requests users of this software to return to 511541Srgrimes * 521541Srgrimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 531541Srgrimes * School of Computer Science 541541Srgrimes * Carnegie Mellon University 551541Srgrimes * Pittsburgh PA 15213-3890 561541Srgrimes * 571541Srgrimes * any improvements or extensions that they make and grant Carnegie the 581541Srgrimes * rights to redistribute these changes. 591817Sdg * 6050477Speter * $FreeBSD$ 611541Srgrimes */ 621541Srgrimes 631541Srgrimes/* 641541Srgrimes * Resident memory system definitions. 651541Srgrimes */ 661541Srgrimes 671541Srgrimes#ifndef _VM_PAGE_ 681541Srgrimes#define _VM_PAGE_ 691541Srgrimes 706816Sdg#include <vm/pmap.h> 7138517Sdfr 721541Srgrimes/* 731541Srgrimes * Management of resident (logical) pages. 741541Srgrimes * 751541Srgrimes * A small structure is kept for each resident 761541Srgrimes * page, indexed by page number. Each structure 771541Srgrimes * is an element of several lists: 781541Srgrimes * 791541Srgrimes * A hash table bucket used to quickly 801541Srgrimes * perform object/offset lookups 811541Srgrimes * 821541Srgrimes * A list of all pages for a given object, 831541Srgrimes * so they can be quickly deactivated at 841541Srgrimes * time of deallocation. 851541Srgrimes * 861541Srgrimes * An ordered list of pages due for pageout. 871541Srgrimes * 881541Srgrimes * In addition, the structure contains the object 891541Srgrimes * and offset to which this page belongs (for pageout), 901541Srgrimes * and sundry status bits. 911541Srgrimes * 92223307Salc * In general, operations on this structure's mutable fields are 93223307Salc * synchronized using either one of or a combination of the lock on the 94223307Salc * object that the page belongs to (O), the pool lock for the page (P), 95223307Salc * or the lock for either the free or paging queues (Q). If a field is 96223307Salc * annotated below with two of these locks, then holding either lock is 97226319Skib * sufficient for read access, but both locks are required for write 98223307Salc * access. 99223307Salc * 100226319Skib * In contrast, the synchronization of accesses to the page's 101226319Skib * dirty field is machine dependent (M). In the 102226319Skib * machine-independent layer, the lock on the object that the 103226319Skib * page belongs to must be held in order to operate on the field. 104226319Skib * However, the pmap layer is permitted to set all bits within 105226319Skib * the field without holding that lock. If the underlying 106226319Skib * architecture does not support atomic read-modify-write 107226319Skib * operations on the field's type, then the machine-independent 108226319Skib * layer uses a 32-bit atomic on the aligned 32-bit word that 109226319Skib * contains the dirty field. In the machine-independent layer, 110226319Skib * the implementation of read-modify-write operations on the 111226319Skib * field is encapsulated in vm_page_clear_dirty_mask(). 1121541Srgrimes */ 1131541Srgrimes 11460938SjakeTAILQ_HEAD(pglist, vm_page); 1151541Srgrimes 116229382Skib#if PAGE_SIZE == 4096 117229382Skib#define VM_PAGE_BITS_ALL 0xffu 118229382Skibtypedef uint8_t vm_page_bits_t; 119229382Skib#elif PAGE_SIZE == 8192 120229382Skib#define VM_PAGE_BITS_ALL 0xffffu 121229382Skibtypedef uint16_t vm_page_bits_t; 122229382Skib#elif PAGE_SIZE == 16384 123229382Skib#define VM_PAGE_BITS_ALL 0xffffffffu 124229382Skibtypedef uint32_t vm_page_bits_t; 125229382Skib#elif PAGE_SIZE == 32768 126229382Skib#define VM_PAGE_BITS_ALL 0xfffffffffffffffflu 127229382Skibtypedef uint64_t vm_page_bits_t; 128229382Skib#endif 129229382Skib 1301541Srgrimesstruct vm_page { 131207460Skmacy TAILQ_ENTRY(vm_page) pageq; /* queue info for FIFO queue or free list (Q) */ 13260938Sjake TAILQ_ENTRY(vm_page) listq; /* pages in same object (O) */ 133105407Sdillon struct vm_page *left; /* splay tree link (O) */ 134105407Sdillon struct vm_page *right; /* splay tree link (O) */ 1351541Srgrimes 136207669Salc vm_object_t object; /* which object am I in (O,P)*/ 137217479Salc vm_pindex_t pindex; /* offset into object (O,P) */ 138121511Salc vm_paddr_t phys_addr; /* physical address of page */ 13960755Speter struct md_page md; /* machine dependant stuff */ 140207702Salc uint8_t queue; /* page queue index (P,Q) */ 141186719Skib int8_t segind; 142225418Skib short hold_count; /* page hold count (P) */ 143170816Salc uint8_t order; /* index of the buddy queue */ 144170816Salc uint8_t pool; 145207905Salc u_short cow; /* page cow mapping count (P) */ 146207706Salc u_int wire_count; /* wired down maps refs (P) */ 147225418Skib uint8_t aflags; /* access is atomic */ 148225418Skib uint8_t flags; /* see below, often immutable after alloc */ 149161125Salc u_short oflags; /* page flags (O) */ 150217478Salc u_char act_count; /* page usage count (O) */ 151139338Salc u_char busy; /* page busy count (O) */ 15213490Sdyson /* NOTE that these must support one bit per DEV_BSIZE in a page!!! */ 15313490Sdyson /* so, on normal X86 kernels, they must be at least 8 bits wide */ 154229382Skib vm_page_bits_t valid; /* map of valid DEV_BSIZE chunks (O) */ 155229382Skib vm_page_bits_t dirty; /* map of dirty DEV_BSIZE chunks (M) */ 1561541Srgrimes}; 1571541Srgrimes 158161125Salc/* 159161125Salc * Page flags stored in oflags: 160161125Salc * 161161125Salc * Access to these page flags is synchronized by the lock on the object 162161125Salc * containing the page (O). 163224746Skib * 164224746Skib * Note: VPO_UNMANAGED (used by OBJT_DEVICE, OBJT_PHYS and OBJT_SG) 165224746Skib * indicates that the page is not under PV management but 166224746Skib * otherwise should be treated as a normal page. Pages not 167224746Skib * under PV management cannot be paged out via the 168224746Skib * object/vm_page_t because there is no knowledge of their pte 169224746Skib * mappings, and such pages are also not on any PQ queue. 170224746Skib * 171161125Salc */ 172163604Salc#define VPO_BUSY 0x0001 /* page is in transit */ 173161125Salc#define VPO_WANTED 0x0002 /* someone is waiting for page */ 174224746Skib#define VPO_UNMANAGED 0x0004 /* No PV management for page */ 175161125Salc#define VPO_SWAPINPROG 0x0200 /* swap I/O in progress on page */ 176161257Salc#define VPO_NOSYNC 0x0400 /* do not collect for syncer */ 177161125Salc 178217508Salc#define PQ_NONE 255 179217508Salc#define PQ_INACTIVE 0 180217508Salc#define PQ_ACTIVE 1 181217508Salc#define PQ_HOLD 2 182217508Salc#define PQ_COUNT 3 18318169Sdyson 18452647Salcstruct vpgqueues { 18552647Salc struct pglist pl; 18618169Sdyson int *cnt; 18752647Salc}; 18818169Sdyson 189177342Salcextern struct vpgqueues vm_page_queues[PQ_COUNT]; 19052647Salc 191197750Salcstruct vpglocks { 192197750Salc struct mtx data; 193197750Salc char pad[CACHE_LINE_SIZE - sizeof(struct mtx)]; 194197750Salc} __aligned(CACHE_LINE_SIZE); 195197750Salc 196197750Salcextern struct vpglocks vm_page_queue_free_lock; 197207410Skmacyextern struct vpglocks pa_lock[]; 198197750Salc 199207410Skmacy#if defined(__arm__) 200207410Skmacy#define PDRSHIFT PDR_SHIFT 201207410Skmacy#elif !defined(PDRSHIFT) 202207410Skmacy#define PDRSHIFT 21 203207410Skmacy#endif 204207410Skmacy 205207410Skmacy#define pa_index(pa) ((pa) >> PDRSHIFT) 206207410Skmacy#define PA_LOCKPTR(pa) &pa_lock[pa_index((pa)) % PA_LOCK_COUNT].data 207207410Skmacy#define PA_LOCKOBJPTR(pa) ((struct lock_object *)PA_LOCKPTR((pa))) 208207410Skmacy#define PA_LOCK(pa) mtx_lock(PA_LOCKPTR(pa)) 209207410Skmacy#define PA_TRYLOCK(pa) mtx_trylock(PA_LOCKPTR(pa)) 210207410Skmacy#define PA_UNLOCK(pa) mtx_unlock(PA_LOCKPTR(pa)) 211207410Skmacy#define PA_UNLOCK_COND(pa) \ 212207410Skmacy do { \ 213208504Salc if ((pa) != 0) { \ 214208504Salc PA_UNLOCK((pa)); \ 215208504Salc (pa) = 0; \ 216208504Salc } \ 217207410Skmacy } while (0) 218207410Skmacy 219207410Skmacy#define PA_LOCK_ASSERT(pa, a) mtx_assert(PA_LOCKPTR(pa), (a)) 220207410Skmacy 221230836Skib#ifdef KLD_MODULE 222230836Skib#define vm_page_lock(m) vm_page_lock_KBI((m), LOCK_FILE, LOCK_LINE) 223230836Skib#define vm_page_unlock(m) vm_page_unlock_KBI((m), LOCK_FILE, LOCK_LINE) 224230836Skib#define vm_page_trylock(m) vm_page_trylock_KBI((m), LOCK_FILE, LOCK_LINE) 225230836Skib#if defined(INVARIANTS) 226230836Skib#define vm_page_lock_assert(m, a) \ 227230836Skib vm_page_lock_assert_KBI((m), (a), __FILE__, __LINE__) 228230836Skib#else 229230836Skib#define vm_page_lock_assert(m, a) 230230836Skib#endif 231230836Skib#else /* !KLD_MODULE */ 232207410Skmacy#define vm_page_lockptr(m) (PA_LOCKPTR(VM_PAGE_TO_PHYS((m)))) 233207410Skmacy#define vm_page_lock(m) mtx_lock(vm_page_lockptr((m))) 234207410Skmacy#define vm_page_unlock(m) mtx_unlock(vm_page_lockptr((m))) 235207410Skmacy#define vm_page_trylock(m) mtx_trylock(vm_page_lockptr((m))) 236207410Skmacy#define vm_page_lock_assert(m, a) mtx_assert(vm_page_lockptr((m)), (a)) 237230836Skib#endif 238207410Skmacy 239197750Salc#define vm_page_queue_free_mtx vm_page_queue_free_lock.data 240240760Salc 2411541Srgrimes/* 2421541Srgrimes * These are the flags defined for vm_page. 2431541Srgrimes * 244240760Salc * aflags are updated by atomic accesses. Use the vm_page_aflag_set() 245225418Skib * and vm_page_aflag_clear() functions to set and clear the flags. 246225418Skib * 247225418Skib * PGA_REFERENCED may be cleared only if the object containing the page is 248240760Salc * locked. It is set by both the MI and MD VM layers. 249208990Salc * 250225418Skib * PGA_WRITEABLE is set exclusively on managed pages by pmap_enter(). When it 251240760Salc * does so, the page must be VPO_BUSY. The MI VM layer must never access this 252240760Salc * flag directly. Instead, it should call pmap_page_is_write_mapped(). 253234476Snwhitehorn * 254234476Snwhitehorn * PGA_EXECUTABLE may be set by pmap routines, and indicates that a page has 255240760Salc * at least one executable mapping. It is not consumed by the MI VM layer. 2561541Srgrimes */ 257225418Skib#define PGA_WRITEABLE 0x01 /* page may be mapped writeable */ 258225418Skib#define PGA_REFERENCED 0x02 /* page has been referenced */ 259234476Snwhitehorn#define PGA_EXECUTABLE 0x04 /* page may be mapped executable */ 2601541Srgrimes 2619507Sdg/* 262225418Skib * Page flags. If changed at any other time than page allocation or 263225418Skib * freeing, the modification must be protected by the vm_page lock. 264225418Skib */ 265225418Skib#define PG_CACHED 0x01 /* page is cached */ 266225418Skib#define PG_FREE 0x02 /* page is free */ 267240760Salc#define PG_FICTITIOUS 0x04 /* physical page doesn't exist */ 268225418Skib#define PG_ZERO 0x08 /* page is zeroed */ 269225418Skib#define PG_MARKER 0x10 /* special queue marker page */ 270225418Skib#define PG_SLAB 0x20 /* object pointer is actually a slab */ 271225418Skib#define PG_WINATCFLS 0x40 /* flush dirty page on inactive q */ 272240760Salc#define PG_NODUMP 0x80 /* don't include this page in a dump */ 273225418Skib 274225418Skib/* 2759507Sdg * Misc constants. 2769507Sdg */ 2779507Sdg#define ACT_DECLINE 1 2789507Sdg#define ACT_ADVANCE 3 27916750Sdyson#define ACT_INIT 5 28018169Sdyson#define ACT_MAX 64 2819507Sdg 28255206Speter#ifdef _KERNEL 283169291Salc 2841541Srgrimes/* 285171420Salc * Each pageable resident page falls into one of five lists: 2861541Srgrimes * 2875455Sdg * free 2881541Srgrimes * Available for allocation now. 2899507Sdg * 2909507Sdg * cache 291172317Salc * Almost available for allocation. Still associated with 292172317Salc * an object, but clean and immediately freeable. 2939507Sdg * 294171420Salc * hold 295171420Salc * Will become free after a pending I/O operation 296171420Salc * completes. 297171420Salc * 298171420Salc * The following lists are LRU sorted: 299171420Salc * 3001541Srgrimes * inactive 30113765Smpp * Low activity, candidates for reclamation. 3021541Srgrimes * This is the list of pages that should be 3031541Srgrimes * paged out next. 3049507Sdg * 3051541Srgrimes * active 3069507Sdg * Pages that are "active" i.e. they have been 3079507Sdg * recently referenced. 30810544Sdyson * 3091541Srgrimes */ 3101541Srgrimes 311210327Sjchandrastruct vnode; 31212767Sdysonextern int vm_page_zero_count; 31312767Sdyson 3145455Sdgextern vm_page_t vm_page_array; /* First resident page in table */ 315236920Skibextern long vm_page_array_size; /* number of vm_page_t's */ 3165455Sdgextern long first_page; /* first physical page number */ 3171541Srgrimes 318170816Salc#define VM_PAGE_IS_FREE(m) (((m)->flags & PG_FREE) != 0) 319170816Salc 3201541Srgrimes#define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr) 3211541Srgrimes 322170816Salcvm_page_t vm_phys_paddr_to_vm_page(vm_paddr_t pa); 323170816Salc 324236924Skibvm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa); 3251541Srgrimes 326197750Salcextern struct vpglocks vm_page_queue_lock; 327197750Salc 328197750Salc#define vm_page_queue_mtx vm_page_queue_lock.data 32999927Salc#define vm_page_lock_queues() mtx_lock(&vm_page_queue_mtx) 33099927Salc#define vm_page_unlock_queues() mtx_unlock(&vm_page_queue_mtx) 3311541Srgrimes 332100276Salc/* page allocation classes: */ 33333109Sdyson#define VM_ALLOC_NORMAL 0 33433109Sdyson#define VM_ALLOC_INTERRUPT 1 33533109Sdyson#define VM_ALLOC_SYSTEM 2 336100276Salc#define VM_ALLOC_CLASS_MASK 3 337100276Salc/* page allocation flags: */ 338106276Sjeff#define VM_ALLOC_WIRED 0x0020 /* non pageable */ 339106276Sjeff#define VM_ALLOC_ZERO 0x0040 /* Try to obtain a zeroed page */ 340209792Skib#define VM_ALLOC_RETRY 0x0080 /* Mandatory with vm_page_grab() */ 341106276Sjeff#define VM_ALLOC_NOOBJ 0x0100 /* No associated object */ 342136850Salc#define VM_ALLOC_NOBUSY 0x0200 /* Do not busy the page */ 343172317Salc#define VM_ALLOC_IFCACHED 0x0400 /* Fail if the page is not cached */ 344172317Salc#define VM_ALLOC_IFNOTCACHED 0x0800 /* Fail if the page is cached */ 345209713Skib#define VM_ALLOC_IGN_SBUSY 0x1000 /* vm_page_grab() only */ 346232066Skmacy#define VM_ALLOC_NODUMP 0x2000 /* don't include in dump */ 3475455Sdg 348209713Skib#define VM_ALLOC_COUNT_SHIFT 16 349209713Skib#define VM_ALLOC_COUNT(count) ((count) << VM_ALLOC_COUNT_SHIFT) 350209713Skib 351225418Skibvoid vm_page_aflag_set(vm_page_t m, uint8_t bits); 352225418Skibvoid vm_page_aflag_clear(vm_page_t m, uint8_t bits); 35379248Sdillonvoid vm_page_busy(vm_page_t m); 35479248Sdillonvoid vm_page_flash(vm_page_t m); 35579248Sdillonvoid vm_page_io_start(vm_page_t m); 35679248Sdillonvoid vm_page_io_finish(vm_page_t m); 35779248Sdillonvoid vm_page_hold(vm_page_t mem); 35879248Sdillonvoid vm_page_unhold(vm_page_t mem); 35979248Sdillonvoid vm_page_free(vm_page_t m); 36079248Sdillonvoid vm_page_free_zero(vm_page_t m); 36179248Sdillonvoid vm_page_dirty(vm_page_t m); 36279248Sdillonvoid vm_page_wakeup(vm_page_t m); 36379248Sdillon 36479263Sdillonvoid vm_pageq_remove(vm_page_t m); 36579263Sdillon 36679248Sdillonvoid vm_page_activate (vm_page_t); 36779248Sdillonvm_page_t vm_page_alloc (vm_object_t, vm_pindex_t, int); 368262933Sdumbbellvm_page_t vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req, 369262933Sdumbbell u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, 370262933Sdumbbell u_long boundary, vm_memattr_t memattr); 371215973Sjchandravm_page_t vm_page_alloc_freelist(int, int); 37279248Sdillonvm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int); 373193126Salcvoid vm_page_cache(vm_page_t); 374172341Salcvoid vm_page_cache_free(vm_object_t, vm_pindex_t, vm_pindex_t); 375172317Salcvoid vm_page_cache_remove(vm_page_t); 376172317Salcvoid vm_page_cache_transfer(vm_object_t, vm_pindex_t, vm_object_t); 37779248Sdillonint vm_page_try_to_cache (vm_page_t); 37879248Sdillonint vm_page_try_to_free (vm_page_t); 379193126Salcvoid vm_page_dontneed(vm_page_t); 38079248Sdillonvoid vm_page_deactivate (vm_page_t); 381209685Skibvm_page_t vm_page_find_least(vm_object_t, vm_pindex_t); 382219476Salcvm_page_t vm_page_getfake(vm_paddr_t paddr, vm_memattr_t memattr); 383236923Skibvoid vm_page_initfake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr); 38479248Sdillonvoid vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t); 385234766Salcboolean_t vm_page_is_cached(vm_object_t object, vm_pindex_t pindex); 38679248Sdillonvm_page_t vm_page_lookup (vm_object_t, vm_pindex_t); 387209407Salcvm_page_t vm_page_next(vm_page_t m); 388207410Skmacyint vm_page_pa_tryrelock(pmap_t, vm_paddr_t, vm_paddr_t *); 389209407Salcvm_page_t vm_page_prev(vm_page_t m); 390219476Salcvoid vm_page_putfake(vm_page_t m); 391239554Skibvoid vm_page_readahead_finish(vm_page_t m); 392225418Skibvoid vm_page_reference(vm_page_t m); 39379248Sdillonvoid vm_page_remove (vm_page_t); 39479248Sdillonvoid vm_page_rename (vm_page_t, vm_object_t, vm_pindex_t); 395177414Salcvoid vm_page_requeue(vm_page_t m); 396192034Salcvoid vm_page_set_valid(vm_page_t m, int base, int size); 397161674Salcvoid vm_page_sleep(vm_page_t m, const char *msg); 398106422Salcvm_page_t vm_page_splay(vm_pindex_t, vm_page_t); 399127868Salcvm_offset_t vm_page_startup(vm_offset_t vaddr); 400216511Salcvoid vm_page_unhold_pages(vm_page_t *ma, int count); 40179248Sdillonvoid vm_page_unwire (vm_page_t, int); 402219476Salcvoid vm_page_updatefake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr); 40379248Sdillonvoid vm_page_wire (vm_page_t); 40479248Sdillonvoid vm_page_set_validclean (vm_page_t, int, int); 40579248Sdillonvoid vm_page_clear_dirty (vm_page_t, int, int); 40679248Sdillonvoid vm_page_set_invalid (vm_page_t, int, int); 40779248Sdillonint vm_page_is_valid (vm_page_t, int, int); 40879248Sdillonvoid vm_page_test_dirty (vm_page_t); 409229382Skibvm_page_bits_t vm_page_bits(int base, int size); 41045347Sjulianvoid vm_page_zero_invalid(vm_page_t m, boolean_t setvalid); 41143752Sdillonvoid vm_page_free_toq(vm_page_t m); 41282314Spetervoid vm_page_zero_idle_wakeup(void); 41398849Skenvoid vm_page_cowfault (vm_page_t); 414186719Skibint vm_page_cowsetup(vm_page_t); 41598849Skenvoid vm_page_cowclear (vm_page_t); 41698849Sken 417230836Skibvoid vm_page_lock_KBI(vm_page_t m, const char *file, int line); 418230836Skibvoid vm_page_unlock_KBI(vm_page_t m, const char *file, int line); 419230836Skibint vm_page_trylock_KBI(vm_page_t m, const char *file, int line); 420230836Skib#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) 421230836Skibvoid vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line); 422230836Skib#endif 423230836Skib 424222992Skib#ifdef INVARIANTS 425222992Skibvoid vm_page_object_lock_assert(vm_page_t m); 426222992Skib#define VM_PAGE_OBJECT_LOCK_ASSERT(m) vm_page_object_lock_assert(m) 427222992Skib#else 428222992Skib#define VM_PAGE_OBJECT_LOCK_ASSERT(m) (void)0 429222992Skib#endif 430222992Skib 431105549Salc/* 432161674Salc * vm_page_sleep_if_busy: 433161674Salc * 434163604Salc * Sleep and release the page queues lock if VPO_BUSY is set or, 435161674Salc * if also_m_busy is TRUE, busy is non-zero. Returns TRUE if the 436161674Salc * thread slept and the page queues lock was released. 437161674Salc * Otherwise, retains the page queues lock and returns FALSE. 438161674Salc * 439161674Salc * The object containing the given page must be locked. 440161674Salc */ 441161674Salcstatic __inline int 442161674Salcvm_page_sleep_if_busy(vm_page_t m, int also_m_busy, const char *msg) 443161674Salc{ 444161674Salc 445163604Salc if ((m->oflags & VPO_BUSY) || (also_m_busy && m->busy)) { 446161674Salc vm_page_sleep(m, msg); 447161674Salc return (TRUE); 448161674Salc } 449161674Salc return (FALSE); 450161674Salc} 451161674Salc 452161674Salc/* 453105549Salc * vm_page_undirty: 454105549Salc * 455105549Salc * Set page to not be dirty. Note: does not clear pmap modify bits 456105549Salc */ 457105549Salcstatic __inline void 458105549Salcvm_page_undirty(vm_page_t m) 459105549Salc{ 460222992Skib 461222992Skib VM_PAGE_OBJECT_LOCK_ASSERT(m); 462105549Salc m->dirty = 0; 463105549Salc} 464105549Salc 46555206Speter#endif /* _KERNEL */ 4665455Sdg#endif /* !_VM_PAGE_ */ 467