Merge branch master
[unleashed.git] / include / vm / page.h
blob333c224ba8540037d2a41120bedea9b552cb9901
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved.
25 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
26 /* All Rights Reserved */
29 * University Copyright- Copyright (c) 1982, 1986, 1988
30 * The Regents of the University of California
31 * All Rights Reserved
33 * University Acknowledgment- Portions of this document are derived from
34 * software developed by the University of California, Berkeley, and its
35 * contributors.
38 #ifndef _VM_PAGE_H
39 #define _VM_PAGE_H
41 #include <vm/seg.h>
42 #include <sys/stdbool.h>
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
48 #if defined(_KERNEL) || defined(_KMEMUSER)
51 * Shared/Exclusive lock.
55 * Types of page locking supported by page_lock & friends.
57 typedef enum {
58 SE_SHARED,
59 SE_EXCL /* exclusive lock (value == -1) */
60 } se_t;
63 * For requesting that page_lock reclaim the page from the free list.
65 typedef enum {
66 P_RECLAIM, /* reclaim page from free list */
67 P_NO_RECLAIM /* DON`T reclaim the page */
68 } reclaim_t;
71 * Callers of page_try_reclaim_lock and page_lock_es can use this flag
72 * to get SE_EXCL access before reader/writers are given access.
74 #define SE_EXCL_WANTED 0x02
77 * All page_*lock() requests will be denied unless this flag is set in
78 * the 'es' parameter.
80 #define SE_RETIRED 0x04
82 #endif /* _KERNEL | _KMEMUSER */
84 typedef int selock_t;
87 * Define VM_STATS to turn on all sorts of statistic gathering about
88 * the VM layer. By default, it is turned on when DEBUG is defined or if
89 * explicitly enabled by CONFIG_VM_STATS.
91 #include <sys/cfgparam.h>
92 #if defined(DEBUG) || defined(CONFIG_VM_STATS)
93 #define VM_STATS
94 #endif /* DEBUG || CONFIG_VM_STATS */
96 #ifdef VM_STATS
97 #define VM_STAT_ADD(stat) do { (stat)++; } while (0)
98 #define VM_STAT_COND_ADD(cond, stat) do { \
99 if (cond) \
100 VM_STAT_ADD(stat); \
101 } while (0)
102 #else
103 #define VM_STAT_ADD(stat) do { } while (0)
104 #define VM_STAT_COND_ADD(cond, stat) do { } while (0)
105 #endif /* VM_STATS */
107 #ifdef _KERNEL
110 * PAGE_LLOCK_SIZE is 2 * NCPU, but no smaller than 128.
111 * PAGE_LLOCK_SHIFT is log2(PAGE_LLOCK_SIZE).
113 * We use ? : instead of #if because <vm/page.h> is included everywhere;
114 * NCPU_P2 is only a constant in the "unix" module.
117 #define PAGE_LLOCK_SHIFT \
118 ((unsigned)(((2*NCPU_P2) > 128) ? NCPU_LOG2 + 1 : 7))
120 #define PAGE_LLOCK_SIZE (1ul << PAGE_LLOCK_SHIFT)
123 * The number of low order 0 (or less variable) bits in the page_t address.
125 #if defined(__sparc)
126 #define PP_SHIFT 7
127 #else
128 #define PP_SHIFT 6
129 #endif
132 * pp may be the root of a large page, and many low order bits will be 0.
133 * Shift and XOR multiple times to capture the good bits across the range of
134 * possible page sizes.
136 #define PAGE_LLOCK_HASH(pp) \
137 (((((uintptr_t)(pp) >> PP_SHIFT) ^ \
138 ((uintptr_t)(pp) >> (PAGE_LLOCK_SHIFT + PP_SHIFT))) ^ \
139 ((uintptr_t)(pp) >> ((PAGE_LLOCK_SHIFT * 2) + PP_SHIFT)) ^ \
140 ((uintptr_t)(pp) >> ((PAGE_LLOCK_SHIFT * 3) + PP_SHIFT))) & \
141 (PAGE_LLOCK_SIZE - 1))
143 #define page_struct_lock(pp) \
144 mutex_enter(&page_llocks[PAGE_LLOCK_HASH(PP_PAGEROOT(pp))].pad_mutex)
145 #define page_struct_unlock(pp) \
146 mutex_exit(&page_llocks[PAGE_LLOCK_HASH(PP_PAGEROOT(pp))].pad_mutex)
148 #endif /* _KERNEL */
150 #include <sys/t_lock.h>
152 struct as;
155 * Each physical page has a page structure, which is used to maintain
156 * these pages as a cache. A page can be found via a hashed lookup
157 * based on the [vp, offset]. If a page has an [vp, offset] identity,
158 * then it is entered on a doubly linked circular list off the
159 * vnode using the vpnext/vpprev pointers. If the p_free bit
160 * is on, then the page is also on a doubly linked circular free
161 * list using next/prev pointers. If the "p_selock" and "p_iolock"
162 * are held, then the page is currently being read in (exclusive p_selock)
163 * or written back (shared p_selock). In this case, the next/prev pointers
164 * are used to link the pages together for a consecutive i/o request. If
165 * the page is being brought in from its backing store, then other processes
166 * will wait for the i/o to complete before attaching to the page since it
167 * will have an "exclusive" lock.
169 * Each page structure has the locks described below along with
170 * the fields they protect:
172 * p_selock This is a per-page shared/exclusive lock that is
173 * used to implement the logical shared/exclusive
174 * lock for each page. The "shared" lock is normally
175 * used in most cases while the "exclusive" lock is
176 * required to destroy or retain exclusive access to
177 * a page (e.g., while reading in pages). The appropriate
178 * lock is always held whenever there is any reference
179 * to a page structure (e.g., during i/o).
180 * (Note that with the addition of the "writer-lock-wanted"
181 * semantics (via SE_EWANTED), threads must not acquire
182 * multiple reader locks or else a deadly embrace will
183 * occur in the following situation: thread 1 obtains a
184 * reader lock; next thread 2 fails to get a writer lock
185 * but specified SE_EWANTED so it will wait by either
186 * blocking (when using page_lock_es) or spinning while
187 * retrying (when using page_try_reclaim_lock) until the
188 * reader lock is released; then thread 1 attempts to
189 * get another reader lock but is denied due to
190 * SE_EWANTED being set, and now both threads are in a
191 * deadly embrace.)
193 * p_hash
194 * p_vnode
195 * p_offset
197 * p_free
198 * p_age
200 * p_iolock This is a binary semaphore lock that provides
201 * exclusive access to the i/o list links in each
202 * page structure. It is always held while the page
203 * is on an i/o list (i.e., involved in i/o). That is,
204 * even though a page may be only `shared' locked
205 * while it is doing a write, the following fields may
206 * change anyway. Normally, the page must be
207 * `exclusively' locked to change anything in it.
209 * p_next
210 * p_prev
212 * The following fields are protected by the global page_llocks[]:
214 * p_lckcnt
215 * p_cowcnt
217 * The following lists are protected by the global page_freelock:
219 * page_cachelist
220 * page_freelist
222 * The following, for our purposes, are protected by
223 * the global freemem_lock:
225 * freemem
226 * freemem_wait
227 * freemem_cv
229 * The following fields are protected by hat layer lock(s). When a page
230 * structure is not mapped and is not associated with a vnode (after a call
231 * to page_hashout() for example) the p_nrm field may be modified with out
232 * holding the hat layer lock:
234 * p_nrm
235 * p_mapping
236 * p_share
238 * The following field is file system dependent. How it is used and
239 * the locking strategies applied are up to the individual file system
240 * implementation.
242 * p_fsdata
244 * The page structure is used to represent and control the system's
245 * physical pages. There is one instance of the structure for each
246 * page that is not permenately allocated. For example, the pages that
247 * hold the page structures are permanently held by the kernel
248 * and hence do not need page structures to track them. The array
249 * of page structures is allocated early on in the kernel's life and
250 * is based on the amount of available physical memory.
252 * Each page structure may simultaneously appear on several linked lists.
253 * The lists are: hash list, free or in i/o list, and a vnode's page list.
254 * Each type of list is protected by a different group of mutexes as described
255 * below:
257 * The hash list is used to quickly find a page when the page's vnode and
258 * offset within the vnode are known. Each page that is hashed is
259 * connected via the `p_hash' field. The anchor for each hash is in the
260 * array `page_hash'. An array of mutexes, `ph_mutex', protects the
261 * lists anchored by page_hash[]. To either search or modify a given hash
262 * list, the appropriate mutex in the ph_mutex array must be held.
264 * The free list contains pages that are `free to be given away'. For
265 * efficiency reasons, pages on this list are placed in two catagories:
266 * pages that are still associated with a vnode, and pages that are not
267 * associated with a vnode. Free pages always have their `p_free' bit set,
268 * free pages that are still associated with a vnode also have their
269 * `p_age' bit set. Pages on the free list are connected via their
270 * `p_next' and `p_prev' fields. When a page is involved in some sort
271 * of i/o, it is not free and these fields may be used to link associated
272 * pages together. At the moment, the free list is protected by a
273 * single mutex `page_freelock'. The list of free pages still associated
274 * with a vnode is anchored by `page_cachelist' while other free pages
275 * are anchored in architecture dependent ways (to handle page coloring etc.).
277 * Pages associated with a given vmobject appear on a list anchored in the
278 * vmobject by the `list' field. They are linked together with
279 * `p_list.vnode'. The field `p_offset' contains a page's offset within
280 * the object. The pages on this list are not kept in offset order. These
281 * lists, in a manner similar to the hash lists, are protected by an array
282 * of mutexes called `vph_hash'. Before searching or modifying this chain
283 * the appropriate mutex in the vph_hash[] array must be held.
285 * Again, each of the lists that a page can appear on is protected by a
286 * mutex. Before reading or writing any of the fields comprising the
287 * list, the appropriate lock must be held. These list locks should only
288 * be held for very short intervals.
290 * In addition to the list locks, each page structure contains a
291 * shared/exclusive lock that protects various fields within it.
292 * To modify one of these fields, the `p_selock' must be exclusively held.
293 * To read a field with a degree of certainty, the lock must be at least
294 * held shared.
296 * Removing a page structure from one of the lists requires holding
297 * the appropriate list lock and the page's p_selock. A page may be
298 * prevented from changing identity, being freed, or otherwise modified
299 * by acquiring p_selock shared.
301 * To avoid deadlocks, a strict locking protocol must be followed. Basically
302 * there are two cases: In the first case, the page structure in question
303 * is known ahead of time (e.g., when the page is to be added or removed
304 * from a list). In the second case, the page structure is not known and
305 * must be found by searching one of the lists.
307 * When adding or removing a known page to one of the lists, first the
308 * page must be exclusively locked (since at least one of its fields
309 * will be modified), second the lock protecting the list must be acquired,
310 * third the page inserted or deleted, and finally the list lock dropped.
312 * The more interesting case occures when the particular page structure
313 * is not known ahead of time. For example, when a call is made to
314 * page_lookup(), it is not known if a page with the desired (vnode and
315 * offset pair) identity exists. So the appropriate mutex in ph_mutex is
316 * acquired, the hash list searched, and if the desired page is found
317 * an attempt is made to lock it. The attempt to acquire p_selock must
318 * not block while the hash list lock is held. A deadlock could occure
319 * if some other process was trying to remove the page from the list.
320 * The removing process (following the above protocol) would have exclusively
321 * locked the page, and be spinning waiting to acquire the lock protecting
322 * the hash list. Since the searching process holds the hash list lock
323 * and is waiting to acquire the page lock, a deadlock occurs.
325 * The proper scheme to follow is: first, lock the appropriate list,
326 * search the list, and if the desired page is found either use
327 * page_trylock() (which will not block) or pass the address of the
328 * list lock to page_lock(). If page_lock() can not acquire the page's
329 * lock, it will drop the list lock before going to sleep. page_lock()
330 * returns a value to indicate if the list lock was dropped allowing the
331 * calling program to react appropriately (i.e., retry the operation).
333 * If the list lock was dropped before the attempt at locking the page
334 * was made, checks would have to be made to ensure that the page had
335 * not changed identity before its lock was obtained. This is because
336 * the interval between dropping the list lock and acquiring the page
337 * lock is indeterminate.
339 * In addition, when both a hash list lock (ph_mutex[]) and a vmobject list
340 * lock (vmobject->lock) are needed, the hash list lock must be acquired
341 * first. The routine page_hashin() is a good example of this sequence.
342 * This sequence is ASSERTed by checking that the vnode page cache lock is
343 * not held just before each acquisition of one of the mutexs in ph_mutex[].
345 * So, as a quick summary:
347 * pse_mutex[]'s protect the p_selock and p_cv fields.
349 * p_selock protects the p_free, p_age, p_vnode, p_offset and p_hash,
351 * ph_mutex[]'s protect the page_hash[] array and its chains.
353 * vmobject lock protects the object's list field and the page chains.
355 * First lock the page, then the hash chain, then the vnode chain. When
356 * this is not possible `trylocks' must be used. Sleeping while holding
357 * any of these mutexes (p_selock is not a mutex) is not allowed.
360 * field reading writing ordering
361 * ======================================================================
362 * p_vnode p_selock(E,S) p_selock(E)
363 * p_offset
364 * p_free
365 * p_age
366 * =====================================================================
367 * p_hash p_selock(E,S) p_selock(E) && p_selock, ph_mutex
368 * ph_mutex[]
369 * =====================================================================
370 * p_list p_selock(E,S) p_selock(E) && p_selock,
371 * vmobject's lock vmobject's lock
372 * =====================================================================
373 * When the p_free bit is set:
375 * p_next p_selock(E,S) p_selock(E) && p_selock,
376 * p_prev page_freelock page_freelock
378 * When the p_free bit is not set:
380 * p_next p_selock(E,S) p_selock(E) && p_selock, p_iolock
381 * p_prev p_iolock
382 * =====================================================================
383 * p_selock pse_mutex[] pse_mutex[] can`t acquire any
384 * p_cv other mutexes or
385 * sleep while holding
386 * this lock.
387 * =====================================================================
388 * p_lckcnt p_selock(E,S) p_selock(E)
389 * OR
390 * p_selock(S) &&
391 * page_llocks[]
392 * p_cowcnt
393 * =====================================================================
394 * p_nrm hat layer lock hat layer lock
395 * p_mapping
396 * p_pagenum
397 * =====================================================================
399 * where:
400 * E----> exclusive version of p_selock.
401 * S----> shared version of p_selock.
404 * Global data structures and variable:
406 * field reading writing ordering
407 * =====================================================================
408 * page_hash[] ph_mutex[] ph_mutex[] can hold this lock
409 * before acquiring
410 * a vmobject's lock
411 * or pse_mutex.
412 * =====================================================================
413 * vmobject->list vmobject's lock vmobject's lock can only acquire
414 * a pse_mutex while
415 * holding this lock.
416 * =====================================================================
417 * page_cachelist page_freelock page_freelock can't acquire any
418 * page_freelist page_freelock page_freelock
419 * =====================================================================
420 * freemem freemem_lock freemem_lock can't acquire any
421 * freemem_wait other mutexes while
422 * freemem_cv holding this mutex.
423 * =====================================================================
425 * Page relocation, PG_NORELOC and P_NORELOC.
427 * Pages may be relocated using the page_relocate() interface. Relocation
428 * involves moving the contents and identity of a page to another, free page.
429 * To relocate a page, the SE_EXCL lock must be obtained. The way to prevent
430 * a page from being relocated is to hold the SE_SHARED lock (the SE_EXCL
431 * lock must not be held indefinitely). If the page is going to be held
432 * SE_SHARED indefinitely, then the PG_NORELOC hint should be passed
433 * to page_create_va so that pages that are prevented from being relocated
434 * can be managed differently by the platform specific layer.
436 * Pages locked in memory using page_pp_lock (p_lckcnt/p_cowcnt != 0)
437 * are guaranteed to be held in memory, but can still be relocated
438 * providing the SE_EXCL lock can be obtained.
440 * The P_NORELOC bit in the page_t.p_state field is provided for use by
441 * the platform specific code in managing pages when the PG_NORELOC
442 * hint is used.
444 * Memory delete and page locking.
446 * The set of all usable pages is managed using the global page list as
447 * implemented by the memseg structure defined below. When memory is added
448 * or deleted this list changes. Additions to this list guarantee that the
449 * list is never corrupt. In order to avoid the necessity of an additional
450 * lock to protect against failed accesses to the memseg being deleted and,
451 * more importantly, the page_ts, the memseg structure is never freed and the
452 * page_t virtual address space is remapped to a page (or pages) of
453 * zeros. If a page_t is manipulated while it is p_selock'd, or if it is
454 * locked indirectly via a hash or freelist lock, it is not possible for
455 * memory delete to collect the page and so that part of the page list is
456 * prevented from being deleted. If the page is referenced outside of one
457 * of these locks, it is possible for the page_t being referenced to be
458 * deleted. Examples of this are page_t pointers returned by
459 * page_numtopp_nolock, page_first and page_next. Providing the page_t
460 * is re-checked after taking the p_selock (for p_vnode != NULL), the
461 * remapping to the zero pages will be detected.
464 * Page size (p_szc field) and page locking.
466 * p_szc field of free pages is changed by free list manager under freelist
467 * locks and is of no concern to the rest of VM subsystem.
469 * p_szc changes of allocated anonymous (swapfs) can only be done only after
470 * exclusively locking all constituent pages and calling hat_pageunload() on
471 * each of them. To prevent p_szc changes of non free anonymous (swapfs) large
472 * pages it's enough to either lock SHARED any of constituent pages or prevent
473 * hat_pageunload() by holding hat level lock that protects mapping lists (this
474 * method is for hat code only)
476 * To increase (promote) p_szc of allocated non anonymous file system pages
477 * one has to first lock exclusively all involved constituent pages and call
478 * hat_pageunload() on each of them. To prevent p_szc promote it's enough to
479 * either lock SHARED any of constituent pages that will be needed to make a
480 * large page or prevent hat_pageunload() by holding hat level lock that
481 * protects mapping lists (this method is for hat code only).
483 * To decrease (demote) p_szc of an allocated non anonymous file system large
484 * page one can either use the same method as used for changeing p_szc of
485 * anonymous large pages or if it's not possible to lock all constituent pages
486 * exclusively a different method can be used. In the second method one only
487 * has to exclusively lock one of constituent pages but then one has to
488 * acquire further locks by calling page_szc_lock() and
489 * hat_page_demote(). hat_page_demote() acquires hat level locks and then
490 * demotes the page. This mechanism relies on the fact that any code that
491 * needs to prevent p_szc of a file system large page from changeing either
492 * locks all constituent large pages at least SHARED or locks some pages at
493 * least SHARED and calls page_szc_lock() or uses hat level page locks.
494 * Demotion using this method is implemented by page_demote_vp_pages().
495 * Please see comments in front of page_demote_vp_pages(), hat_page_demote()
496 * and page_szc_lock() for more details.
498 * Lock order: p_selock, page_szc_lock, ph_mutex/vmobject's lock/freelist,
499 * hat level locks.
502 typedef struct page {
503 uoff_t p_offset; /* offset into vnode for this page */
504 struct vnode *p_vnode; /* vnode that this page is named by */
505 selock_t p_selock; /* shared/exclusive lock on the page */
506 #if defined(_LP64)
507 uint_t p_vpmref; /* vpm ref - index of the vpmap_t */
508 #endif
509 struct page *unused; /* used to be p_hash; keep this here for binary compat */
510 union {
511 /* vnode page list - used when on cached list */
512 struct list_node vnode;
514 /* large page list - used when free & large page */
515 struct {
516 struct page *next;
517 struct page *prev;
518 } largepg;
519 } p_list;
520 struct page *p_next; /* next page in free/intrans lists */
521 struct page *p_prev; /* prev page in free/intrans lists */
522 ushort_t p_lckcnt; /* number of locks on page data */
523 ushort_t p_cowcnt; /* number of copy on write lock */
524 kcondvar_t p_cv; /* page struct's condition var */
525 kcondvar_t p_io_cv; /* for iolock */
526 uchar_t p_iolock_state; /* replaces p_iolock */
527 volatile uchar_t p_szc; /* page size code */
528 uchar_t p_fsdata; /* file system dependent byte */
529 uchar_t p_state; /* p_free, p_noreloc */
530 uchar_t p_nrm; /* non-cache, ref, mod readonly bits */
531 #if defined(__sparc)
532 uchar_t p_vcolor; /* virtual color */
533 #else
534 uchar_t p_embed; /* x86 - changes p_mapping & p_index */
535 #endif
536 uchar_t p_index; /* MPSS mapping info. Not used on x86 */
537 uchar_t p_toxic; /* page has an unrecoverable error */
538 void *p_mapping; /* hat specific translation info */
539 pfn_t p_pagenum; /* physical page number */
541 uint_t p_share; /* number of translations */
542 #if defined(_LP64)
543 uint_t p_sharepad; /* pad for growing p_share */
544 #endif
545 uint_t p_slckcnt; /* number of softlocks */
546 #if defined(__sparc)
547 uint_t p_kpmref; /* number of kpm mapping sharers */
548 struct kpme *p_kpmelist; /* kpm specific mapping info */
549 #else
550 /* index of entry in p_map when p_embed is set */
551 uint_t p_mlentry;
552 #endif
553 #if defined(_LP64)
554 kmutex_t p_ilock; /* protects p_vpmref */
555 #else
556 uint64_t p_msresv_2; /* page allocation debugging */
557 #endif
559 struct vmobject *p_object;
560 avl_node_t p_object_node;
561 } page_t;
564 typedef page_t devpage_t;
565 #define devpage page
567 #define PAGE_LOCK_MAXIMUM \
568 ((1 << (sizeof (((page_t *)0)->p_lckcnt) * NBBY)) - 1)
570 #define PAGE_SLOCK_MAXIMUM UINT_MAX
572 #ifdef _KERNEL
575 * Flags used while creating pages.
577 #define PG_EXCL 0x0001
578 #define PG_WAIT 0x0002 /* Blocking memory allocations */
579 #define PG_PHYSCONTIG 0x0004 /* NOT SUPPORTED */
580 #define PG_MATCH_COLOR 0x0008 /* SUPPORTED by free list routines */
581 #define PG_NORELOC 0x0010 /* Non-relocatable alloc hint. */
582 /* Page must be PP_ISNORELOC */
583 #define PG_PANIC 0x0020 /* system will panic if alloc fails */
584 #define PG_PUSHPAGE 0x0040 /* alloc may use reserve */
585 #define PG_LOCAL 0x0080 /* alloc from given lgrp only */
586 #define PG_NORMALPRI 0x0100 /* PG_WAIT like priority, but */
587 /* non-blocking */
589 * When p_selock has the SE_EWANTED bit set, threads waiting for SE_EXCL
590 * access are given priority over all other waiting threads.
592 #define SE_EWANTED 0x40000000
593 #define PAGE_LOCKED(pp) (((pp)->p_selock & ~SE_EWANTED) != 0)
594 #define PAGE_SHARED(pp) (((pp)->p_selock & ~SE_EWANTED) > 0)
595 #define PAGE_EXCL(pp) ((pp)->p_selock < 0)
596 #define PAGE_LOCKED_SE(pp, se) \
597 ((se) == SE_EXCL ? PAGE_EXCL(pp) : PAGE_SHARED(pp))
599 extern pad_mutex_t page_llocks[]; /* page logical lock mutex */
600 extern kmutex_t freemem_lock; /* freemem lock */
602 extern pgcnt_t total_pages; /* total pages in the system */
605 * Variables controlling locking of physical memory.
607 extern pgcnt_t pages_pp_maximum; /* tuning: lock + claim <= max */
608 extern void init_pages_pp_maximum(void);
610 struct lgrp;
612 /* page_list_{add,sub} flags */
614 /* which list */
615 #define PG_FREE_LIST 0x0001
616 #define PG_CACHE_LIST 0x0002
618 /* where on list */
619 #define PG_LIST_TAIL 0x0010
620 #define PG_LIST_HEAD 0x0020
622 /* called from */
623 #define PG_LIST_ISINIT 0x1000
626 * Page frame operations.
628 struct page *page_lookup(struct vmobject *, uoff_t, se_t);
629 struct page *page_lookup_create(struct vmobject *, uoff_t, se_t, struct page *,
630 spgcnt_t *, int);
631 struct page *page_lookup_nowait(struct vmobject *, uoff_t, se_t);
632 struct page *page_find(struct vmobject *, uoff_t);
633 struct page *page_exists(struct vmobject *, uoff_t);
634 int page_exists_physcontig(struct vmobject *, uoff_t, uint_t, struct page **);
635 int page_exists_forreal(struct vmobject *, uoff_t, uint_t *);
636 void page_needfree(spgcnt_t);
637 int page_alloc_pages(struct vmobject *, struct seg *, caddr_t,
638 struct page **, struct page **, uint_t, int, int);
639 struct page *page_create_va_large(struct vmobject *, uoff_t off, size_t bytes,
640 uint_t flags, struct seg *seg, caddr_t vaddr, void *arg);
641 struct page *page_create_va(struct vmobject *, uoff_t, size_t, uint_t,
642 struct seg *, caddr_t);
643 int page_create_wait(pgcnt_t npages, uint_t flags);
644 void page_create_putback(spgcnt_t npages);
645 void page_free(page_t *, int);
646 void page_free_at_startup(page_t *);
647 void page_free_pages(page_t *);
648 void free_vp_pages(struct vmobject *, uoff_t, size_t);
649 int page_reclaim(struct page *, struct vmobject *);
650 void page_destroy(page_t *, int);
651 void page_destroy_pages(page_t *);
652 void page_destroy_free(page_t *);
653 void page_rename(struct page *, struct vmobject *, uoff_t);
654 int page_hashin(struct page *, struct vmobject *, uoff_t, bool);
655 void page_hashout(page_t *, bool);
656 void page_add(page_t **, page_t *);
657 void page_add_common(page_t **, page_t *);
658 void page_sub(page_t **, page_t *);
659 void page_sub_common(page_t **, page_t *);
660 struct page *page_get_freelist(struct vmobject *, uoff_t, struct seg *,
661 caddr_t, size_t, uint_t, struct lgrp *);
663 struct page *page_get_cachelist(struct vmobject *, uoff_t, struct seg *,
664 caddr_t, uint_t, struct lgrp *);
665 #if defined(__i386) || defined(__amd64)
666 int page_chk_freelist(uint_t);
667 #endif
668 void page_list_add(page_t *, int);
669 void page_boot_demote(page_t *);
670 void page_promote_size(page_t *, uint_t);
671 void page_list_add_pages(page_t *, int);
672 void page_list_sub(page_t *, int);
673 void page_list_sub_pages(page_t *, uint_t);
674 void page_list_xfer(page_t *, int, int);
675 void page_list_break(page_t **, page_t **, size_t);
676 void page_list_concat(page_t **, page_t **);
677 void page_vpadd(page_t **, page_t *);
678 void page_vpsub(page_t **, page_t *);
679 void page_lpadd(page_t **, page_t *);
680 void page_lpsub(page_t **, page_t *);
681 int page_lock(struct page *, se_t, struct vmobject *, reclaim_t);
682 int page_lock_es(struct page *, se_t, struct vmobject *, reclaim_t, int);
683 void page_lock_clr_exclwanted(page_t *);
684 int page_trylock(page_t *, se_t);
685 int page_try_reclaim_lock(page_t *, se_t, int);
686 int page_tryupgrade(page_t *);
687 void page_downgrade(page_t *);
688 void page_unlock(page_t *);
689 void page_unlock_nocapture(page_t *);
690 void page_lock_delete(page_t *);
691 int page_deleted(page_t *);
692 int page_pp_lock(page_t *, int, int);
693 void page_pp_unlock(page_t *, int, int);
694 int page_resv(pgcnt_t, uint_t);
695 void page_unresv(pgcnt_t);
696 void page_pp_useclaim(page_t *, page_t *, uint_t);
697 int page_addclaim(page_t *);
698 int page_subclaim(page_t *);
699 int page_addclaim_pages(page_t **);
700 int page_subclaim_pages(page_t **);
701 pfn_t page_pptonum(page_t *);
702 page_t *page_numtopp(pfn_t, se_t);
703 page_t *page_numtopp_noreclaim(pfn_t, se_t);
704 page_t *page_numtopp_nolock(pfn_t);
705 page_t *page_numtopp_nowait(pfn_t, se_t);
706 page_t *page_first();
707 page_t *page_next(page_t *);
708 page_t *page_list_next(page_t *);
709 page_t *page_nextn(page_t *, ulong_t);
710 page_t *page_next_scan_init(void **);
711 page_t *page_next_scan_large(page_t *, ulong_t *, void **);
712 void prefetch_page_r(void *);
713 int ppcopy(page_t *, page_t *);
714 void page_relocate_hash(page_t *, page_t *);
715 void pagezero(page_t *, uint_t, uint_t);
716 void pagescrub(page_t *, uint_t, uint_t);
717 void page_io_lock(page_t *);
718 void page_io_unlock(page_t *);
719 int page_io_trylock(page_t *);
720 int page_iolock_assert(page_t *);
721 void page_iolock_init(page_t *);
722 void page_io_wait(page_t *);
723 int page_io_locked(page_t *);
724 pgcnt_t page_busy(int);
725 void page_lock_init(void);
726 ulong_t page_share_cnt(page_t *);
727 int page_isshared(page_t *);
728 int page_isfree(page_t *);
729 int page_isref(page_t *);
730 int page_ismod(page_t *);
731 int page_release(page_t *, int);
732 void page_retire_init(void);
733 int page_retire(uint64_t, uchar_t);
734 int page_retire_check(uint64_t, uint64_t *);
735 int page_unretire(uint64_t);
736 int page_unretire_pp(page_t *, int);
737 void page_tryretire(page_t *);
738 void page_retire_mdboot();
739 uint64_t page_retire_pend_count(void);
740 uint64_t page_retire_pend_kas_count(void);
741 void page_retire_incr_pend_count(void *);
742 void page_retire_decr_pend_count(void *);
743 void page_clrtoxic(page_t *, uchar_t);
744 void page_settoxic(page_t *, uchar_t);
746 int page_reclaim_mem(pgcnt_t, pgcnt_t, int);
748 void page_set_props(page_t *, uint_t);
749 void page_clr_all_props(page_t *);
750 int page_clear_lck_cow(page_t *, int);
752 kmutex_t *page_se_mutex(struct page *);
753 kmutex_t *page_szc_lock(struct page *);
754 int page_szc_lock_assert(struct page *pp);
758 * Page relocation interfaces. page_relocate() is generic.
759 * page_get_replacement_page() is provided by the PSM.
760 * page_free_replacement_page() is generic.
762 int group_page_trylock(page_t *, se_t);
763 void group_page_unlock(page_t *);
764 int page_relocate(page_t **, page_t **, int, int, spgcnt_t *, struct lgrp *);
765 int do_page_relocate(page_t **, page_t **, int, spgcnt_t *, struct lgrp *);
766 page_t *page_get_replacement_page(page_t *, struct lgrp *, uint_t);
767 void page_free_replacement_page(page_t *);
769 int page_try_demote_pages(page_t *);
770 int page_try_demote_free_pages(page_t *);
771 void page_demote_free_pages(page_t *);
773 struct anon_map;
775 void page_mark_migrate(struct seg *, caddr_t, size_t, struct anon_map *,
776 ulong_t, struct vmobject *, uoff_t, int);
777 void page_migrate(struct seg *, caddr_t, page_t **, pgcnt_t);
780 * Tell the PIM we are adding physical memory
782 void add_physmem(page_t *, size_t, pfn_t);
783 void add_physmem_cb(page_t *, pfn_t); /* callback for page_t part */
786 * hw_page_array[] is configured with hardware supported page sizes by
787 * platform specific code.
789 typedef struct {
790 size_t hp_size;
791 uint_t hp_shift;
792 uint_t hp_colors;
793 pgcnt_t hp_pgcnt; /* base pagesize cnt */
794 } hw_pagesize_t;
796 extern hw_pagesize_t hw_page_array[];
797 extern uint_t page_coloring_shift;
798 extern uint_t page_colors_mask;
799 extern int cpu_page_colors;
800 extern uint_t colorequiv;
801 extern uchar_t colorequivszc[];
803 uint_t page_num_pagesizes(void);
804 uint_t page_num_user_pagesizes(int);
805 size_t page_get_pagesize(uint_t);
806 size_t page_get_user_pagesize(uint_t n);
807 pgcnt_t page_get_pagecnt(uint_t);
808 uint_t page_get_shift(uint_t);
809 int page_szc(size_t);
810 int page_szc_user_filtered(size_t);
812 /* page_get_replacement page flags */
813 #define PGR_SAMESZC 0x1 /* only look for page size same as orig */
814 #define PGR_NORELOC 0x2 /* allocate a P_NORELOC page */
817 * macros for "masked arithmetic"
818 * The purpose is to step through all combinations of a set of bits while
819 * keeping some other bits fixed. Fixed bits need not be contiguous. The
820 * variable bits need not be contiguous either, or even right aligned. The
821 * trick is to set all fixed bits to 1, then increment, then restore the
822 * fixed bits. If incrementing causes a carry from a low bit position, the
823 * carry propagates thru the fixed bits, because they are temporarily set to 1.
824 * v is the value
825 * i is the increment
826 * eq_mask defines the fixed bits
827 * mask limits the size of the result
829 #define ADD_MASKED(v, i, eq_mask, mask) \
830 (((((v) | (eq_mask)) + (i)) & (mask) & ~(eq_mask)) | ((v) & (eq_mask)))
833 * convenience macro which increments by 1
835 #define INC_MASKED(v, eq_mask, mask) ADD_MASKED(v, 1, eq_mask, mask)
837 #endif /* _KERNEL */
840 * Constants used for the p_iolock_state
842 #define PAGE_IO_INUSE 0x1
843 #define PAGE_IO_WANTED 0x2
846 * Constants used for page_release status
848 #define PGREL_NOTREL 0x1
849 #define PGREL_CLEAN 0x2
850 #define PGREL_MOD 0x3
853 * The p_state field holds what used to be the p_age and p_free
854 * bits. These fields are protected by p_selock (see above).
856 #define P_FREE 0x80 /* Page on free list */
857 #define P_NORELOC 0x40 /* Page is non-relocatable */
858 #define P_MIGRATE 0x20 /* Migrate page on next touch */
859 #define P_SWAP 0x10 /* belongs to vnode that is V_ISSWAP */
860 #define P_BOOTPAGES 0x08 /* member of bootpages list */
861 #define P_RAF 0x04 /* page retired at free */
862 #define P_PVN_TAG 0x02 /* pvn_vplist_dirty tag */
864 #define PP_ISFREE(pp) ((pp)->p_state & P_FREE)
865 #define PP_ISAGED(pp) (((pp)->p_state & P_FREE) && \
866 ((pp)->p_vnode == NULL))
867 #define PP_ISNORELOC(pp) ((pp)->p_state & P_NORELOC)
868 #define PP_ISKAS(pp) (VN_ISKAS((pp)->p_vnode))
869 #define PP_ISNORELOCKERNEL(pp) (PP_ISNORELOC(pp) && PP_ISKAS(pp))
870 #define PP_ISMIGRATE(pp) ((pp)->p_state & P_MIGRATE)
871 #define PP_ISSWAP(pp) ((pp)->p_state & P_SWAP)
872 #define PP_ISBOOTPAGES(pp) ((pp)->p_state & P_BOOTPAGES)
873 #define PP_ISRAF(pp) ((pp)->p_state & P_RAF)
874 #define PP_ISPVN_TAG(pp) ((pp)->p_state & P_PVN_TAG)
876 #define PP_SETFREE(pp) ((pp)->p_state = ((pp)->p_state & ~P_MIGRATE) \
877 | P_FREE)
878 #define PP_SETAGED(pp) ASSERT(PP_ISAGED(pp))
879 #define PP_SETNORELOC(pp) ((pp)->p_state |= P_NORELOC)
880 #define PP_SETMIGRATE(pp) ((pp)->p_state |= P_MIGRATE)
881 #define PP_SETSWAP(pp) ((pp)->p_state |= P_SWAP)
882 #define PP_SETBOOTPAGES(pp) ((pp)->p_state |= P_BOOTPAGES)
883 #define PP_SETRAF(pp) ((pp)->p_state |= P_RAF)
884 #define PP_SETPVN_TAG(pp) ((pp)->p_state |= P_PVN_TAG)
886 #define PP_CLRFREE(pp) ((pp)->p_state &= ~P_FREE)
887 #define PP_CLRAGED(pp) ASSERT(!PP_ISAGED(pp))
888 #define PP_CLRNORELOC(pp) ((pp)->p_state &= ~P_NORELOC)
889 #define PP_CLRMIGRATE(pp) ((pp)->p_state &= ~P_MIGRATE)
890 #define PP_CLRSWAP(pp) ((pp)->p_state &= ~P_SWAP)
891 #define PP_CLRBOOTPAGES(pp) ((pp)->p_state &= ~P_BOOTPAGES)
892 #define PP_CLRRAF(pp) ((pp)->p_state &= ~P_RAF)
893 #define PP_CLRPVN_TAG(pp) ((pp)->p_state &= ~P_PVN_TAG)
896 * Flags for page_t p_toxic, for tracking memory hardware errors.
898 * These flags are OR'ed into p_toxic with page_settoxic() to track which
899 * error(s) have occurred on a given page. The flags are cleared with
900 * page_clrtoxic(). Both page_settoxic() and page_cleartoxic use atomic
901 * primitives to manipulate the p_toxic field so no other locking is needed.
903 * When an error occurs on a page, p_toxic is set to record the error. The
904 * error could be a memory error or something else (i.e. a datapath). The Page
905 * Retire mechanism does not try to determine the exact cause of the error;
906 * Page Retire rightly leaves that sort of determination to FMA's Diagnostic
907 * Engine (DE).
909 * Note that, while p_toxic bits can be set without holding any locks, they
910 * should only be cleared while holding the page exclusively locked.
911 * There is one exception to this, the PR_CAPTURE bit is protected by a mutex
912 * within the page capture logic and thus to set or clear the bit, that mutex
913 * needs to be held. The page does not need to be locked but the page_clrtoxic
914 * function must be used as we need an atomic operation.
915 * Also note that there is what amounts to a hack to prevent recursion with
916 * large pages such that if we are unlocking a page and the PR_CAPTURE bit is
917 * set, we will only try to capture the page if the current threads T_CAPTURING
918 * flag is not set. If the flag is set, the unlock will not try to capture
919 * the page even though the PR_CAPTURE bit is set.
921 * Pages with PR_UE or PR_FMA flags are retired unconditionally, while pages
922 * with PR_MCE are retired if the system has not retired too many of them.
924 * A page must be exclusively locked to be retired. Pages can be retired if
925 * they are mapped, modified, or both, as long as they are not marked PR_UE,
926 * since pages with uncorrectable errors cannot be relocated in memory.
927 * Once a page has been successfully retired it is zeroed, attached to the
928 * retired_pages vnode and, finally, PR_RETIRED is set in p_toxic. The other
929 * p_toxic bits are NOT cleared. Pages are not left locked after retiring them
930 * to avoid special case code throughout the kernel; rather, page_*lock() will
931 * fail to lock the page, unless SE_RETIRED is passed as an argument.
933 * While we have your attention, go take a look at the comments at the
934 * beginning of page_retire.c too.
936 #define PR_OK 0x00 /* no problem */
937 #define PR_MCE 0x01 /* page has seen two or more CEs */
938 #define PR_UE 0x02 /* page has an unhandled UE */
939 #define PR_UE_SCRUBBED 0x04 /* page has seen a UE but was cleaned */
940 #define PR_FMA 0x08 /* A DE wants this page retired */
941 #define PR_CAPTURE 0x10 /* page is hashed on page_capture_hash[] */
942 #define PR_RESV 0x20 /* Reserved for future use */
943 #define PR_MSG 0x40 /* message(s) already printed for this page */
944 #define PR_RETIRED 0x80 /* This page has been retired */
946 #define PR_REASONS (PR_UE | PR_MCE | PR_FMA)
947 #define PR_TOXIC (PR_UE)
948 #define PR_ERRMASK (PR_UE | PR_UE_SCRUBBED | PR_MCE | PR_FMA)
949 #define PR_TOXICFLAGS (0xCF)
951 #define PP_RETIRED(pp) ((pp)->p_toxic & PR_RETIRED)
952 #define PP_TOXIC(pp) ((pp)->p_toxic & PR_TOXIC)
953 #define PP_PR_REQ(pp) (((pp)->p_toxic & PR_REASONS) && !PP_RETIRED(pp))
954 #define PP_PR_NOSHARE(pp) \
955 ((((pp)->p_toxic & (PR_RETIRED | PR_FMA | PR_UE)) == PR_FMA) && \
956 !PP_ISKAS(pp))
959 * Flags for page_unretire_pp
961 #define PR_UNR_FREE 0x1
962 #define PR_UNR_CLEAN 0x2
963 #define PR_UNR_TEMP 0x4
966 * kpm large page description.
967 * The virtual address range of segkpm is divided into chunks of
968 * kpm_pgsz. Each chunk is controlled by a kpm_page_t. The ushort
969 * is sufficient for 2^^15 * PAGESIZE, so e.g. the maximum kpm_pgsz
970 * for 8K is 256M and 2G for 64K pages. It it kept as small as
971 * possible to save physical memory space.
973 * There are 2 segkpm mapping windows within in the virtual address
974 * space when we have to prevent VAC alias conflicts. The so called
975 * Alias window (mappings are always by PAGESIZE) is controlled by
976 * kp_refcnta. The regular window is controlled by kp_refcnt for the
977 * normal operation, which is to use the largest available pagesize.
978 * When VAC alias conflicts are present within a chunk in the regular
979 * window the large page mapping is broken up into smaller PAGESIZE
980 * mappings. kp_refcntc is used to control the pages that are invoked
981 * in the conflict and kp_refcnts holds the active mappings done
982 * with the small page size. In non vac conflict mode kp_refcntc is
983 * also used as "go" indication (-1) for the trap level tsbmiss
984 * handler.
986 typedef struct kpm_page {
987 short kp_refcnt; /* pages mapped large */
988 short kp_refcnta; /* pages mapped in Alias window */
989 short kp_refcntc; /* TL-tsbmiss flag; #vac alias conflict pages */
990 short kp_refcnts; /* vac alias: pages mapped small */
991 } kpm_page_t;
994 * Note: khl_lock offset changes must be reflected in sfmmu_asm.s
996 typedef struct kpm_hlk {
997 kmutex_t khl_mutex; /* kpm_page mutex */
998 uint_t khl_lock; /* trap level tsbmiss handling */
999 } kpm_hlk_t;
1002 * kpm small page description.
1003 * When kpm_pgsz is equal to PAGESIZE a smaller representation is used
1004 * to save memory space. Alias range mappings and regular segkpm
1005 * mappings are done in units of PAGESIZE and can share the mapping
1006 * information and the mappings are always distinguishable by their
1007 * virtual address. Other information needed for VAC conflict prevention
1008 * is already available on a per page basis.
1010 * The state about how a kpm page is mapped and whether it is ready to go
1011 * is indicated by the following 1 byte kpm_spage structure. This byte is
1012 * split into two 4-bit parts - kp_mapped and kp_mapped_go.
1013 * - kp_mapped == 1 the page is mapped cacheable
1014 * - kp_mapped == 2 the page is mapped non-cacheable
1015 * - kp_mapped_go == 1 the mapping is ready to be dropped in
1016 * - kp_mapped_go == 0 the mapping is not ready to be dropped in.
1017 * When kp_mapped_go == 0, we will have C handler resolve the VAC conflict.
1018 * Otherwise, the assembly tsb miss handler can simply drop in the mapping
1019 * when a tsb miss occurs.
1021 typedef union kpm_spage {
1022 struct {
1023 #ifdef _BIG_ENDIAN
1024 uchar_t mapped_go: 4; /* go or nogo flag */
1025 uchar_t mapped: 4; /* page mapped small */
1026 #else
1027 uchar_t mapped: 4; /* page mapped small */
1028 uchar_t mapped_go: 4; /* go or nogo flag */
1029 #endif
1030 } kpm_spage_un;
1031 uchar_t kp_mapped_flag;
1032 } kpm_spage_t;
1034 #define kp_mapped kpm_spage_un.mapped
1035 #define kp_mapped_go kpm_spage_un.mapped_go
1038 * Note: kshl_lock offset changes must be reflected in sfmmu_asm.s
1040 typedef struct kpm_shlk {
1041 uint_t kshl_lock; /* trap level tsbmiss handling */
1042 } kpm_shlk_t;
1045 * Each segment of physical memory is described by a memseg struct.
1046 * Within a segment, memory is considered contiguous. The members
1047 * can be categorized as follows:
1048 * . Platform independent:
1049 * pages, epages, pages_base, pages_end, next, lnext.
1050 * . 64bit only but platform independent:
1051 * kpm_pbase, kpm_nkpmpgs, kpm_pages, kpm_spages.
1052 * . Really platform or mmu specific:
1053 * pagespa, epagespa, nextpa, kpm_pagespa.
1054 * . Mixed:
1055 * msegflags.
1057 struct memseg {
1058 page_t *pages, *epages; /* [from, to] in page array */
1059 pfn_t pages_base, pages_end; /* [from, to] in page numbers */
1060 struct memseg *next; /* next segment in list */
1061 struct memseg *lnext; /* next segment in deleted list */
1062 #if defined(__sparc)
1063 uint64_t pagespa, epagespa; /* [from, to] page array physical */
1064 uint64_t nextpa; /* physical next pointer */
1065 pfn_t kpm_pbase; /* start of kpm range */
1066 pgcnt_t kpm_nkpmpgs; /* # of kpm_pgsz pages */
1067 union _mseg_un {
1068 kpm_page_t *kpm_lpgs; /* ptr to kpm_page array */
1069 kpm_spage_t *kpm_spgs; /* ptr to kpm_spage array */
1070 } mseg_un;
1071 uint64_t kpm_pagespa; /* physical ptr to kpm (s)pages array */
1072 #endif /* __sparc */
1073 uint_t msegflags; /* memseg flags */
1076 /* memseg union aliases */
1077 #define kpm_pages mseg_un.kpm_lpgs
1078 #define kpm_spages mseg_un.kpm_spgs
1080 /* msegflags */
1081 #define MEMSEG_DYNAMIC 0x1 /* DR: memory was added dynamically */
1082 #define MEMSEG_META_INCL 0x2 /* DR: memseg includes it's metadata */
1083 #define MEMSEG_META_ALLOC 0x4 /* DR: memseg allocated it's metadata */
1085 /* memseg support macros */
1086 #define MSEG_NPAGES(SEG) ((SEG)->pages_end - (SEG)->pages_base)
1088 /* memseg hash */
1089 #define MEM_HASH_SHIFT 0x9
1090 #define N_MEM_SLOTS 0x200 /* must be a power of 2 */
1091 #define MEMSEG_PFN_HASH(pfn) (((pfn)/mhash_per_slot) & (N_MEM_SLOTS - 1))
1093 /* memseg externals */
1094 extern struct memseg *memsegs; /* list of memory segments */
1095 extern ulong_t mhash_per_slot;
1096 extern uint64_t memsegspa; /* memsegs as physical address */
1098 void build_pfn_hash();
1099 extern struct memseg *page_numtomemseg_nolock(pfn_t pfnum);
1102 * page capture related info:
1103 * The page capture routines allow us to asynchronously capture given pages
1104 * for the explicit use of the requestor. New requestors can be added by
1105 * explicitly adding themselves to the PC_* flags below and incrementing
1106 * PC_NUM_CALLBACKS as necessary.
1108 * Subsystems using page capture must register a callback before attempting
1109 * to capture a page. A duration of -1 will indicate that we will never give
1110 * up while trying to capture a page and will only stop trying to capture the
1111 * given page once we have successfully captured it. Thus the user needs to be
1112 * aware of the behavior of all callers who have a duration of -1.
1114 * For now, only /dev/physmem and page retire use the page capture interface
1115 * and only a single request can be outstanding for a given page. Thus, if
1116 * /dev/phsymem wants a page and page retire also wants the same page, only
1117 * the page retire request will be honored until the point in time that the
1118 * page is actually retired, at which point in time, subsequent requests by
1119 * /dev/physmem will succeed if the CAPTURE_GET_RETIRED flag was set.
1122 #define PC_RETIRE (0)
1123 #define PC_PHYSMEM (1)
1124 #define PC_NUM_CALLBACKS (2)
1125 #define PC_MASK ((1 << PC_NUM_CALLBACKS) - 1)
1127 #define CAPTURE_RETIRE (1 << PC_RETIRE)
1128 #define CAPTURE_PHYSMEM (1 << PC_PHYSMEM)
1130 #define CAPTURE_ASYNC (0x0200)
1132 #define CAPTURE_GET_RETIRED (0x1000)
1133 #define CAPTURE_GET_CAGE (0x2000)
1135 struct page_capture_callback {
1136 int cb_active; /* 1 means active, 0 means inactive */
1137 clock_t duration; /* the length in time that we'll attempt to */
1138 /* capture this page asynchronously. (in HZ) */
1139 krwlock_t cb_rwlock;
1140 int (*cb_func)(page_t *, void *, uint_t); /* callback function */
1143 extern kcondvar_t pc_cv;
1145 void page_capture_register_callback(uint_t index, clock_t duration,
1146 int (*cb_func)(page_t *, void *, uint_t));
1147 void page_capture_unregister_callback(uint_t index);
1148 int page_trycapture(page_t *pp, uint_t szc, uint_t flags, void *datap);
1149 void page_unlock_capture(page_t *pp);
1150 int page_capture_unretire_pp(page_t *);
1152 extern int memsegs_trylock(int);
1153 extern void memsegs_lock(int);
1154 extern void memsegs_unlock(int);
1155 extern int memsegs_lock_held(void);
1156 extern void memlist_read_lock(void);
1157 extern void memlist_read_unlock(void);
1158 extern void memlist_write_lock(void);
1159 extern void memlist_write_unlock(void);
1161 #ifdef __cplusplus
1163 #endif
1165 #endif /* _VM_PAGE_H */