2 * Copyright (c) 1991 Regents of the University of California.
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 4. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * from: @(#)vm_page.c 7.4 (Berkeley) 5/7/91
36 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
37 * All rights reserved.
39 * Authors: Avadis Tevanian, Jr., Michael Wayne Young
41 * Permission to use, copy, modify and distribute this software and
42 * its documentation is hereby granted, provided that both the copyright
43 * notice and this permission notice appear in all copies of the
44 * software, derivative works or modified versions, and any portions
45 * thereof, and that both notices appear in supporting documentation.
47 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
48 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
49 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
51 * Carnegie Mellon requests users of this software to return to
53 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
54 * School of Computer Science
55 * Carnegie Mellon University
56 * Pittsburgh PA 15213-3890
58 * any improvements or extensions that they make and grant Carnegie the
59 * rights to redistribute these changes.
63 * GENERAL RULES ON VM_PAGE MANIPULATION
65 * - a pageq mutex is required when adding or removing a page from a
66 * page queue (vm_page_queue[]), regardless of other mutexes or the
67 * busy state of a page.
69 * - a hash chain mutex is required when associating or disassociating
70 * a page from the VM PAGE CACHE hash table (vm_page_buckets),
71 * regardless of other mutexes or the busy state of a page.
73 * - either a hash chain mutex OR a busied page is required in order
74 * to modify the page flags. A hash chain mutex must be obtained in
75 * order to busy a page. A page's flags cannot be modified by a
76 * hash chain mutex if the page is marked busy.
78 * - The object memq mutex is held when inserting or removing
79 * pages from an object (vm_page_insert() or vm_page_remove()). This
80 * is different from the object's main mutex.
82 * Generally speaking, you have to be aware of side effects when running
83 * vm_page ops. A vm_page_lookup() will return with the hash chain
84 * locked, whether it was able to lookup the page or not. vm_page_free(),
85 * vm_page_cache(), vm_page_activate(), and a number of other routines
86 * will release the hash chain mutex for you. Intermediate manipulation
87 * routines such as vm_page_flag_set() expect the hash chain to be held
88 * on entry and the hash chain will remain held on return.
90 * pageq scanning can only occur with the pageq in question locked.
91 * We have a known bottleneck with the active queue, but the cache
92 * and free queues are actually arrays already.
96 * Resident memory management module.
99 #include <sys/cdefs.h>
100 __FBSDID("$FreeBSD$");
102 #include <sys/param.h>
103 #include <sys/systm.h>
104 #include <sys/lock.h>
105 #include <sys/kernel.h>
106 #include <sys/malloc.h>
107 #include <sys/mutex.h>
108 #include <sys/proc.h>
109 #include <sys/sysctl.h>
110 #include <sys/vmmeter.h>
111 #include <sys/vnode.h>
114 #include <vm/vm_param.h>
115 #include <vm/vm_kern.h>
116 #include <vm/vm_object.h>
117 #include <vm/vm_page.h>
118 #include <vm/vm_pageout.h>
119 #include <vm/vm_pager.h>
120 #include <vm/vm_phys.h>
121 #include <vm/vm_extern.h>
123 #include <vm/uma_int.h>
125 #include <machine/md_var.h>
128 * Associated with page of user-allocatable memory is a
132 struct mtx vm_page_queue_mtx;
133 struct mtx vm_page_queue_free_mtx;
135 vm_page_t vm_page_array = 0;
136 int vm_page_array_size = 0;
138 int vm_page_zero_count = 0;
140 static int boot_pages = UMA_BOOT_PAGES;
141 TUNABLE_INT("vm.boot_pages", &boot_pages);
142 SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RD, &boot_pages, 0,
143 "number of pages allocated for bootstrapping the VM system");
148 * Sets the page size, perhaps based upon the memory
149 * size. Must be called before any use of page-size
150 * dependent functions.
153 vm_set_page_size(void)
155 if (cnt.v_page_size == 0)
156 cnt.v_page_size = PAGE_SIZE;
157 if (((cnt.v_page_size - 1) & cnt.v_page_size) != 0)
158 panic("vm_set_page_size: page size not a power of two");
162 * vm_page_blacklist_lookup:
164 * See if a physical address in this page has been listed
165 * in the blacklist tunable. Entries in the tunable are
166 * separated by spaces or commas. If an invalid integer is
167 * encountered then the rest of the string is skipped.
170 vm_page_blacklist_lookup(char *list, vm_paddr_t pa)
175 for (pos = list; *pos != '\0'; pos = cp) {
176 bad = strtoq(pos, &cp, 0);
178 if (*cp == ' ' || *cp == ',') {
185 if (pa == trunc_page(bad))
194 * Initializes the resident memory module.
196 * Allocates memory for the page cells, and
197 * for the object/offset-to-page hash table headers.
198 * Each page cell is initialized and placed on the free list.
201 vm_page_startup(vm_offset_t vaddr)
205 vm_paddr_t page_range;
213 /* the biggest memory array is the second group of pages */
215 vm_paddr_t biggestsize;
216 vm_paddr_t low_water, high_water;
225 vaddr = round_page(vaddr);
227 for (i = 0; phys_avail[i + 1]; i += 2) {
228 phys_avail[i] = round_page(phys_avail[i]);
229 phys_avail[i + 1] = trunc_page(phys_avail[i + 1]);
232 low_water = phys_avail[0];
233 high_water = phys_avail[1];
235 for (i = 0; phys_avail[i + 1]; i += 2) {
236 vm_paddr_t size = phys_avail[i + 1] - phys_avail[i];
238 if (size > biggestsize) {
242 if (phys_avail[i] < low_water)
243 low_water = phys_avail[i];
244 if (phys_avail[i + 1] > high_water)
245 high_water = phys_avail[i + 1];
250 end = phys_avail[biggestone+1];
253 * Initialize the locks.
255 mtx_init(&vm_page_queue_mtx, "vm page queue mutex", NULL, MTX_DEF |
257 mtx_init(&vm_page_queue_free_mtx, "vm page queue free mutex", NULL,
261 * Initialize the queue headers for the free queue, the active queue
262 * and the inactive queue.
267 * Allocate memory for use when boot strapping the kernel memory
270 new_end = end - (boot_pages * UMA_SLAB_SIZE);
271 new_end = trunc_page(new_end);
272 mapped = pmap_map(&vaddr, new_end, end,
273 VM_PROT_READ | VM_PROT_WRITE);
274 bzero((void *)mapped, end - new_end);
275 uma_startup((void *)mapped, boot_pages);
277 #if defined(__amd64__) || defined(__i386__)
279 * Allocate a bitmap to indicate that a random physical page
280 * needs to be included in a minidump.
282 * The amd64 port needs this to indicate which direct map pages
283 * need to be dumped, via calls to dump_add_page()/dump_drop_page().
285 * However, i386 still needs this workspace internally within the
286 * minidump code. In theory, they are not needed on i386, but are
287 * included should the sf_buf code decide to use them.
289 page_range = phys_avail[(nblocks - 1) * 2 + 1] / PAGE_SIZE;
290 vm_page_dump_size = round_page(roundup2(page_range, NBBY) / NBBY);
291 new_end -= vm_page_dump_size;
292 vm_page_dump = (void *)(uintptr_t)pmap_map(&vaddr, new_end,
293 new_end + vm_page_dump_size, VM_PROT_READ | VM_PROT_WRITE);
294 bzero((void *)vm_page_dump, vm_page_dump_size);
297 * Compute the number of pages of memory that will be available for
298 * use (taking into account the overhead of a page structure per
301 first_page = low_water / PAGE_SIZE;
302 #ifdef VM_PHYSSEG_SPARSE
304 for (i = 0; phys_avail[i + 1] != 0; i += 2)
305 page_range += atop(phys_avail[i + 1] - phys_avail[i]);
306 #elif defined(VM_PHYSSEG_DENSE)
307 page_range = high_water / PAGE_SIZE - first_page;
309 #error "Either VM_PHYSSEG_DENSE or VM_PHYSSEG_SPARSE must be defined."
311 npages = (total - (page_range * sizeof(struct vm_page)) -
312 (end - new_end)) / PAGE_SIZE;
316 * Reserve an unmapped guard page to trap access to vm_page_array[-1].
321 * Initialize the mem entry structures now, and put them in the free
324 new_end = trunc_page(end - page_range * sizeof(struct vm_page));
325 mapped = pmap_map(&vaddr, new_end, end,
326 VM_PROT_READ | VM_PROT_WRITE);
327 vm_page_array = (vm_page_t) mapped;
330 * pmap_map on amd64 comes out of the direct-map, not kvm like i386,
331 * so the pages must be tracked for a crashdump to include this data.
332 * This includes the vm_page_array and the early UMA bootstrap pages.
334 for (pa = new_end; pa < phys_avail[biggestone + 1]; pa += PAGE_SIZE)
337 phys_avail[biggestone + 1] = new_end;
340 * Clear all of the page structures
342 bzero((caddr_t) vm_page_array, page_range * sizeof(struct vm_page));
343 for (i = 0; i < page_range; i++)
344 vm_page_array[i].order = VM_NFREEORDER;
345 vm_page_array_size = page_range;
348 * This assertion tests the hypothesis that npages and total are
352 for (i = 0; phys_avail[i + 1] != 0; i += 2)
353 page_range += atop(phys_avail[i + 1] - phys_avail[i]);
354 KASSERT(page_range == npages,
355 ("vm_page_startup: inconsistent page counts"));
358 * Initialize the physical memory allocator.
363 * Add every available physical page that is not blacklisted to
366 cnt.v_page_count = 0;
367 cnt.v_free_count = 0;
368 list = getenv("vm.blacklist");
369 for (i = 0; phys_avail[i + 1] != 0; i += 2) {
371 last_pa = phys_avail[i + 1];
372 while (pa < last_pa) {
374 vm_page_blacklist_lookup(list, pa))
375 printf("Skipping page with pa 0x%jx\n",
378 vm_phys_add_page(pa);
387 vm_page_flag_set(vm_page_t m, unsigned short bits)
390 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
395 vm_page_flag_clear(vm_page_t m, unsigned short bits)
398 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
403 vm_page_busy(vm_page_t m)
406 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
407 KASSERT((m->oflags & VPO_BUSY) == 0,
408 ("vm_page_busy: page already busy!!!"));
409 m->oflags |= VPO_BUSY;
415 * wakeup anyone waiting for the page.
418 vm_page_flash(vm_page_t m)
421 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
422 if (m->oflags & VPO_WANTED) {
423 m->oflags &= ~VPO_WANTED;
431 * clear the VPO_BUSY flag and wakeup anyone waiting for the
436 vm_page_wakeup(vm_page_t m)
439 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
440 KASSERT(m->oflags & VPO_BUSY, ("vm_page_wakeup: page not busy!!!"));
441 m->oflags &= ~VPO_BUSY;
446 vm_page_io_start(vm_page_t m)
449 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
454 vm_page_io_finish(vm_page_t m)
457 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
464 * Keep page from being freed by the page daemon
465 * much of the same effect as wiring, except much lower
466 * overhead and should be used only for *very* temporary
467 * holding ("wiring").
470 vm_page_hold(vm_page_t mem)
473 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
478 vm_page_unhold(vm_page_t mem)
481 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
483 KASSERT(mem->hold_count >= 0, ("vm_page_unhold: hold count < 0!!!"));
484 if (mem->hold_count == 0 && VM_PAGE_INQUEUE2(mem, PQ_HOLD))
485 vm_page_free_toq(mem);
494 vm_page_free(vm_page_t m)
497 m->flags &= ~PG_ZERO;
504 * Free a page to the zerod-pages queue
507 vm_page_free_zero(vm_page_t m)
517 * Sleep and release the page queues lock.
519 * The object containing the given page must be locked.
522 vm_page_sleep(vm_page_t m, const char *msg)
525 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
526 if (!mtx_owned(&vm_page_queue_mtx))
527 vm_page_lock_queues();
528 vm_page_flag_set(m, PG_REFERENCED);
529 vm_page_unlock_queues();
532 * It's possible that while we sleep, the page will get
533 * unbusied and freed. If we are holding the object
534 * lock, we will assume we hold a reference to the object
535 * such that even if m->object changes, we can re-lock
538 m->oflags |= VPO_WANTED;
539 msleep(m, VM_OBJECT_MTX(m->object), PVM, msg, 0);
545 * make page all dirty
548 vm_page_dirty(vm_page_t m)
550 KASSERT(VM_PAGE_GETKNOWNQUEUE1(m) != PQ_CACHE,
551 ("vm_page_dirty: page in cache!"));
552 KASSERT(!VM_PAGE_IS_FREE(m),
553 ("vm_page_dirty: page is free!"));
554 m->dirty = VM_PAGE_BITS_ALL;
560 * Implements Sleator and Tarjan's top-down splay algorithm. Returns
561 * the vm_page containing the given pindex. If, however, that
562 * pindex is not found in the vm_object, returns a vm_page that is
563 * adjacent to the pindex, coming before or after it.
566 vm_page_splay(vm_pindex_t pindex, vm_page_t root)
568 struct vm_page dummy;
569 vm_page_t lefttreemax, righttreemin, y;
573 lefttreemax = righttreemin = &dummy;
575 if (pindex < root->pindex) {
576 if ((y = root->left) == NULL)
578 if (pindex < y->pindex) {
580 root->left = y->right;
583 if ((y = root->left) == NULL)
586 /* Link into the new root's right tree. */
587 righttreemin->left = root;
589 } else if (pindex > root->pindex) {
590 if ((y = root->right) == NULL)
592 if (pindex > y->pindex) {
594 root->right = y->left;
597 if ((y = root->right) == NULL)
600 /* Link into the new root's left tree. */
601 lefttreemax->right = root;
606 /* Assemble the new root. */
607 lefttreemax->right = root->left;
608 righttreemin->left = root->right;
609 root->left = dummy.right;
610 root->right = dummy.left;
615 * vm_page_insert: [ internal use only ]
617 * Inserts the given mem entry into the object and object list.
619 * The pagetables are not updated but will presumably fault the page
620 * in if necessary, or if a kernel page the caller will at some point
621 * enter the page into the kernel's pmap. We are not allowed to block
622 * here so we *can't* do this anyway.
624 * The object and page must be locked.
625 * This routine may not block.
628 vm_page_insert(vm_page_t m, vm_object_t object, vm_pindex_t pindex)
632 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
633 if (m->object != NULL)
634 panic("vm_page_insert: page already inserted");
637 * Record the object/offset pair in this page
643 * Now link into the object's ordered list of backed pages.
649 TAILQ_INSERT_TAIL(&object->memq, m, listq);
651 root = vm_page_splay(pindex, root);
652 if (pindex < root->pindex) {
653 m->left = root->left;
656 TAILQ_INSERT_BEFORE(root, m, listq);
657 } else if (pindex == root->pindex)
658 panic("vm_page_insert: offset already allocated");
660 m->right = root->right;
663 TAILQ_INSERT_AFTER(&object->memq, root, m, listq);
667 object->generation++;
670 * show that the object has one more resident page.
672 object->resident_page_count++;
674 * Hold the vnode until the last page is released.
676 if (object->resident_page_count == 1 && object->type == OBJT_VNODE)
677 vhold((struct vnode *)object->handle);
680 * Since we are inserting a new and possibly dirty page,
681 * update the object's OBJ_MIGHTBEDIRTY flag.
683 if (m->flags & PG_WRITEABLE)
684 vm_object_set_writeable_dirty(object);
689 * NOTE: used by device pager as well -wfj
691 * Removes the given mem entry from the object/offset-page
692 * table and the object page list, but do not invalidate/terminate
695 * The object and page must be locked.
696 * The underlying pmap entry (if any) is NOT removed here.
697 * This routine may not block.
700 vm_page_remove(vm_page_t m)
705 if ((object = m->object) == NULL)
707 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
708 if (m->oflags & VPO_BUSY) {
709 m->oflags &= ~VPO_BUSY;
712 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
715 * Now remove from the object's list of backed pages.
717 if (m != object->root)
718 vm_page_splay(m->pindex, object->root);
722 root = vm_page_splay(m->pindex, m->left);
723 root->right = m->right;
726 TAILQ_REMOVE(&object->memq, m, listq);
729 * And show that the object has one fewer resident page.
731 object->resident_page_count--;
732 object->generation++;
734 * The vnode may now be recycled.
736 if (object->resident_page_count == 0 && object->type == OBJT_VNODE)
737 vdrop((struct vnode *)object->handle);
745 * Returns the page associated with the object/offset
746 * pair specified; if none is found, NULL is returned.
748 * The object must be locked.
749 * This routine may not block.
750 * This is a critical path routine
753 vm_page_lookup(vm_object_t object, vm_pindex_t pindex)
757 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
758 if ((m = object->root) != NULL && m->pindex != pindex) {
759 m = vm_page_splay(pindex, m);
760 if ((object->root = m)->pindex != pindex)
769 * Move the given memory entry from its
770 * current object to the specified target object/offset.
772 * The object must be locked.
773 * This routine may not block.
775 * Note: swap associated with the page must be invalidated by the move. We
776 * have to do this for several reasons: (1) we aren't freeing the
777 * page, (2) we are dirtying the page, (3) the VM system is probably
778 * moving the page from object A to B, and will then later move
779 * the backing store from A to B and we can't have a conflict.
781 * Note: we *always* dirty the page. It is necessary both for the
782 * fact that we moved it, and because we may be invalidating
783 * swap. If the page is on the cache, we have to deactivate it
784 * or vm_page_dirty() will panic. Dirty pages are not allowed
788 vm_page_rename(vm_page_t m, vm_object_t new_object, vm_pindex_t new_pindex)
792 vm_page_insert(m, new_object, new_pindex);
793 if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
794 vm_page_deactivate(m);
799 * vm_page_select_cache:
801 * Move a page of the given color from the cache queue to the free
802 * queue. As pages might be found, but are not applicable, they are
805 * This routine may not block.
808 vm_page_select_cache(void)
812 boolean_t was_trylocked;
814 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
815 while ((m = TAILQ_FIRST(&vm_page_queues[PQ_CACHE].pl)) != NULL) {
816 KASSERT(m->dirty == 0, ("Found dirty cache page %p", m));
817 KASSERT(!pmap_page_is_mapped(m),
818 ("Found mapped cache page %p", m));
819 KASSERT((m->flags & PG_UNMANAGED) == 0,
820 ("Found unmanaged cache page %p", m));
821 KASSERT(m->wire_count == 0, ("Found wired cache page %p", m));
822 if (m->hold_count == 0 && (object = m->object,
823 (was_trylocked = VM_OBJECT_TRYLOCK(object)) ||
824 VM_OBJECT_LOCKED(object))) {
825 KASSERT((m->oflags & VPO_BUSY) == 0 && m->busy == 0,
826 ("Found busy cache page %p", m));
829 VM_OBJECT_UNLOCK(object);
832 vm_page_deactivate(m);
840 * Allocate and return a memory cell associated
841 * with this VM object/offset pair.
844 * VM_ALLOC_NORMAL normal process request
845 * VM_ALLOC_SYSTEM system *really* needs a page
846 * VM_ALLOC_INTERRUPT interrupt time request
847 * VM_ALLOC_ZERO zero page
849 * This routine may not block.
851 * Additional special handling is required when called from an
852 * interrupt (VM_ALLOC_INTERRUPT). We are not allowed to mess with
853 * the page cache in this case.
856 vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int req)
861 page_req = req & VM_ALLOC_CLASS_MASK;
862 KASSERT(curthread->td_intr_nesting_level == 0 ||
863 page_req == VM_ALLOC_INTERRUPT,
864 ("vm_page_alloc(NORMAL|SYSTEM) in interrupt context"));
866 if ((req & VM_ALLOC_NOOBJ) == 0) {
867 KASSERT(object != NULL,
868 ("vm_page_alloc: NULL object."));
869 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
873 * The pager is allowed to eat deeper into the free page list.
875 if ((curproc == pageproc) && (page_req != VM_ALLOC_INTERRUPT)) {
876 page_req = VM_ALLOC_SYSTEM;
880 mtx_lock(&vm_page_queue_free_mtx);
881 if (cnt.v_free_count > cnt.v_free_reserved ||
882 (page_req == VM_ALLOC_SYSTEM &&
883 cnt.v_cache_count == 0 &&
884 cnt.v_free_count > cnt.v_interrupt_free_min) ||
885 (page_req == VM_ALLOC_INTERRUPT && cnt.v_free_count > 0)) {
887 * Allocate from the free queue if the number of free pages
888 * exceeds the minimum for the request class.
890 m = vm_phys_alloc_pages(object != NULL ?
891 VM_FREEPOOL_DEFAULT : VM_FREEPOOL_DIRECT, 0);
892 } else if (page_req != VM_ALLOC_INTERRUPT) {
893 mtx_unlock(&vm_page_queue_free_mtx);
895 * Allocatable from cache (non-interrupt only). On success,
896 * we must free the page and try again, thus ensuring that
897 * cnt.v_*_free_min counters are replenished.
899 vm_page_lock_queues();
900 if ((m = vm_page_select_cache()) == NULL) {
901 KASSERT(cnt.v_cache_count == 0,
902 ("vm_page_alloc: cache queue is missing %d pages",
904 vm_page_unlock_queues();
905 atomic_add_int(&vm_pageout_deficit, 1);
908 if (page_req != VM_ALLOC_SYSTEM)
911 mtx_lock(&vm_page_queue_free_mtx);
912 if (cnt.v_free_count <= cnt.v_interrupt_free_min) {
913 mtx_unlock(&vm_page_queue_free_mtx);
916 m = vm_phys_alloc_pages(object != NULL ?
917 VM_FREEPOOL_DEFAULT : VM_FREEPOOL_DIRECT, 0);
919 vm_page_unlock_queues();
924 * Not allocatable from cache from interrupt, give up.
926 mtx_unlock(&vm_page_queue_free_mtx);
927 atomic_add_int(&vm_pageout_deficit, 1);
933 * At this point we had better have found a good page.
938 ("vm_page_alloc(): missing page on free queue")
940 KASSERT(VM_PAGE_IS_FREE(m),
941 ("vm_page_alloc: page %p is not free", m));
944 * Initialize structure. Only the PG_ZERO flag is inherited.
947 if (m->flags & PG_ZERO) {
948 vm_page_zero_count--;
949 if (req & VM_ALLOC_ZERO)
952 if (object != NULL && object->type == OBJT_PHYS)
953 flags |= PG_UNMANAGED;
955 if (req & (VM_ALLOC_NOBUSY | VM_ALLOC_NOOBJ))
958 m->oflags = VPO_BUSY;
959 if (req & VM_ALLOC_WIRED) {
960 atomic_add_int(&cnt.v_wire_count, 1);
968 KASSERT(m->dirty == 0, ("vm_page_alloc: free/cache page %p was dirty", m));
969 mtx_unlock(&vm_page_queue_free_mtx);
971 if ((req & VM_ALLOC_NOOBJ) == 0)
972 vm_page_insert(m, object, pindex);
977 * Don't wakeup too often - wakeup the pageout daemon when
978 * we would be nearly out of memory.
980 if (vm_paging_needed())
987 * vm_wait: (also see VM_WAIT macro)
989 * Block until free pages are available for allocation
990 * - Called in various places before memory allocations.
996 mtx_lock(&vm_page_queue_free_mtx);
997 if (curproc == pageproc) {
998 vm_pageout_pages_needed = 1;
999 msleep(&vm_pageout_pages_needed, &vm_page_queue_free_mtx,
1000 PDROP | PSWP, "VMWait", 0);
1002 if (!vm_pages_needed) {
1003 vm_pages_needed = 1;
1004 wakeup(&vm_pages_needed);
1006 msleep(&cnt.v_free_count, &vm_page_queue_free_mtx, PDROP | PVM,
1012 * vm_waitpfault: (also see VM_WAITPFAULT macro)
1014 * Block until free pages are available for allocation
1015 * - Called only in vm_fault so that processes page faulting
1016 * can be easily tracked.
1017 * - Sleeps at a lower priority than vm_wait() so that vm_wait()ing
1018 * processes will be able to grab memory first. Do not change
1019 * this balance without careful testing first.
1025 mtx_lock(&vm_page_queue_free_mtx);
1026 if (!vm_pages_needed) {
1027 vm_pages_needed = 1;
1028 wakeup(&vm_pages_needed);
1030 msleep(&cnt.v_free_count, &vm_page_queue_free_mtx, PDROP | PUSER,
1037 * Put the specified page on the active list (if appropriate).
1038 * Ensure that act_count is at least ACT_INIT but do not otherwise
1041 * The page queues must be locked.
1042 * This routine may not block.
1045 vm_page_activate(vm_page_t m)
1048 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1049 if (VM_PAGE_GETKNOWNQUEUE2(m) != PQ_ACTIVE) {
1050 if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
1051 cnt.v_reactivated++;
1053 if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
1054 if (m->act_count < ACT_INIT)
1055 m->act_count = ACT_INIT;
1056 vm_pageq_enqueue(PQ_ACTIVE, m);
1059 if (m->act_count < ACT_INIT)
1060 m->act_count = ACT_INIT;
1065 * vm_page_free_wakeup:
1067 * Helper routine for vm_page_free_toq() and vm_page_cache(). This
1068 * routine is called when a page has been added to the cache or free
1071 * The page queues must be locked.
1072 * This routine may not block.
1075 vm_page_free_wakeup(void)
1078 mtx_assert(&vm_page_queue_free_mtx, MA_OWNED);
1080 * if pageout daemon needs pages, then tell it that there are
1083 if (vm_pageout_pages_needed &&
1084 cnt.v_cache_count + cnt.v_free_count >= cnt.v_pageout_free_min) {
1085 wakeup(&vm_pageout_pages_needed);
1086 vm_pageout_pages_needed = 0;
1089 * wakeup processes that are waiting on memory if we hit a
1090 * high water mark. And wakeup scheduler process if we have
1091 * lots of memory. this process will swapin processes.
1093 if (vm_pages_needed && !vm_page_count_min()) {
1094 vm_pages_needed = 0;
1095 wakeup(&cnt.v_free_count);
1102 * Returns the given page to the free list,
1103 * disassociating it with any VM object.
1105 * Object and page must be locked prior to entry.
1106 * This routine may not block.
1110 vm_page_free_toq(vm_page_t m)
1113 if (VM_PAGE_GETQUEUE(m) != PQ_NONE)
1114 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1115 KASSERT(!pmap_page_is_mapped(m),
1116 ("vm_page_free_toq: freeing mapped page %p", m));
1117 PCPU_INC(cnt.v_tfree);
1119 if (m->busy || VM_PAGE_IS_FREE(m)) {
1121 "vm_page_free: pindex(%lu), busy(%d), VPO_BUSY(%d), hold(%d)\n",
1122 (u_long)m->pindex, m->busy, (m->oflags & VPO_BUSY) ? 1 : 0,
1124 if (VM_PAGE_IS_FREE(m))
1125 panic("vm_page_free: freeing free page");
1127 panic("vm_page_free: freeing busy page");
1131 * unqueue, then remove page. Note that we cannot destroy
1132 * the page here because we do not want to call the pager's
1133 * callback routine until after we've put the page on the
1134 * appropriate free queue.
1136 vm_pageq_remove_nowakeup(m);
1140 * If fictitious remove object association and
1141 * return, otherwise delay object association removal.
1143 if ((m->flags & PG_FICTITIOUS) != 0) {
1150 if (m->wire_count != 0) {
1151 if (m->wire_count > 1) {
1152 panic("vm_page_free: invalid wire count (%d), pindex: 0x%lx",
1153 m->wire_count, (long)m->pindex);
1155 panic("vm_page_free: freeing wired page");
1157 if (m->hold_count != 0) {
1158 m->flags &= ~PG_ZERO;
1159 vm_pageq_enqueue(PQ_HOLD, m);
1161 m->flags |= PG_FREE;
1162 mtx_lock(&vm_page_queue_free_mtx);
1163 if ((m->flags & PG_ZERO) != 0) {
1164 vm_phys_free_pages(m, 0);
1165 ++vm_page_zero_count;
1167 vm_phys_free_pages(m, 0);
1168 vm_page_zero_idle_wakeup();
1170 vm_page_free_wakeup();
1171 mtx_unlock(&vm_page_queue_free_mtx);
1178 * Mark this page as wired down by yet
1179 * another map, removing it from paging queues
1182 * The page queues must be locked.
1183 * This routine may not block.
1186 vm_page_wire(vm_page_t m)
1190 * Only bump the wire statistics if the page is not already wired,
1191 * and only unqueue the page if it is on some queue (if it is unmanaged
1192 * it is already off the queues).
1194 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1195 if (m->flags & PG_FICTITIOUS)
1197 if (m->wire_count == 0) {
1198 if ((m->flags & PG_UNMANAGED) == 0)
1200 atomic_add_int(&cnt.v_wire_count, 1);
1203 KASSERT(m->wire_count != 0, ("vm_page_wire: wire_count overflow m=%p", m));
1209 * Release one wiring of this page, potentially
1210 * enabling it to be paged again.
1212 * Many pages placed on the inactive queue should actually go
1213 * into the cache, but it is difficult to figure out which. What
1214 * we do instead, if the inactive target is well met, is to put
1215 * clean pages at the head of the inactive queue instead of the tail.
1216 * This will cause them to be moved to the cache more quickly and
1217 * if not actively re-referenced, freed more quickly. If we just
1218 * stick these pages at the end of the inactive queue, heavy filesystem
1219 * meta-data accesses can cause an unnecessary paging load on memory bound
1220 * processes. This optimization causes one-time-use metadata to be
1221 * reused more quickly.
1223 * BUT, if we are in a low-memory situation we have no choice but to
1224 * put clean pages on the cache queue.
1226 * A number of routines use vm_page_unwire() to guarantee that the page
1227 * will go into either the inactive or active queues, and will NEVER
1228 * be placed in the cache - for example, just after dirtying a page.
1229 * dirty pages in the cache are not allowed.
1231 * The page queues must be locked.
1232 * This routine may not block.
1235 vm_page_unwire(vm_page_t m, int activate)
1238 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1239 if (m->flags & PG_FICTITIOUS)
1241 if (m->wire_count > 0) {
1243 if (m->wire_count == 0) {
1244 atomic_subtract_int(&cnt.v_wire_count, 1);
1245 if (m->flags & PG_UNMANAGED) {
1247 } else if (activate)
1248 vm_pageq_enqueue(PQ_ACTIVE, m);
1250 vm_page_flag_clear(m, PG_WINATCFLS);
1251 vm_pageq_enqueue(PQ_INACTIVE, m);
1255 panic("vm_page_unwire: invalid wire count: %d", m->wire_count);
1261 * Move the specified page to the inactive queue. If the page has
1262 * any associated swap, the swap is deallocated.
1264 * Normally athead is 0 resulting in LRU operation. athead is set
1265 * to 1 if we want this page to be 'as if it were placed in the cache',
1266 * except without unmapping it from the process address space.
1268 * This routine may not block.
1271 _vm_page_deactivate(vm_page_t m, int athead)
1274 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1277 * Ignore if already inactive.
1279 if (VM_PAGE_INQUEUE2(m, PQ_INACTIVE))
1281 if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
1282 if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
1283 cnt.v_reactivated++;
1284 vm_page_flag_clear(m, PG_WINATCFLS);
1287 TAILQ_INSERT_HEAD(&vm_page_queues[PQ_INACTIVE].pl, m, pageq);
1289 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq);
1290 VM_PAGE_SETQUEUE2(m, PQ_INACTIVE);
1291 cnt.v_inactive_count++;
1296 vm_page_deactivate(vm_page_t m)
1298 _vm_page_deactivate(m, 0);
1302 * vm_page_try_to_cache:
1304 * Returns 0 on failure, 1 on success
1307 vm_page_try_to_cache(vm_page_t m)
1310 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1311 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1312 if (m->dirty || m->hold_count || m->busy || m->wire_count ||
1313 (m->oflags & VPO_BUSY) || (m->flags & PG_UNMANAGED)) {
1324 * vm_page_try_to_free()
1326 * Attempt to free the page. If we cannot free it, we do nothing.
1327 * 1 is returned on success, 0 on failure.
1330 vm_page_try_to_free(vm_page_t m)
1333 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1334 if (m->object != NULL)
1335 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1336 if (m->dirty || m->hold_count || m->busy || m->wire_count ||
1337 (m->oflags & VPO_BUSY) || (m->flags & PG_UNMANAGED)) {
1350 * Put the specified page onto the page cache queue (if appropriate).
1352 * This routine may not block.
1355 vm_page_cache(vm_page_t m)
1358 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1359 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1360 if ((m->flags & PG_UNMANAGED) || (m->oflags & VPO_BUSY) || m->busy ||
1361 m->hold_count || m->wire_count) {
1362 panic("vm_page_cache: attempting to cache busy page");
1364 if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
1368 * Remove all pmaps and indicate that the page is not
1369 * writeable or mapped.
1372 if (m->dirty != 0) {
1373 panic("vm_page_cache: caching a dirty page, pindex: %ld",
1376 vm_pageq_remove_nowakeup(m);
1377 vm_pageq_enqueue(PQ_CACHE, m);
1378 mtx_lock(&vm_page_queue_free_mtx);
1379 vm_page_free_wakeup();
1380 mtx_unlock(&vm_page_queue_free_mtx);
1386 * Cache, deactivate, or do nothing as appropriate. This routine
1387 * is typically used by madvise() MADV_DONTNEED.
1389 * Generally speaking we want to move the page into the cache so
1390 * it gets reused quickly. However, this can result in a silly syndrome
1391 * due to the page recycling too quickly. Small objects will not be
1392 * fully cached. On the otherhand, if we move the page to the inactive
1393 * queue we wind up with a problem whereby very large objects
1394 * unnecessarily blow away our inactive and cache queues.
1396 * The solution is to move the pages based on a fixed weighting. We
1397 * either leave them alone, deactivate them, or move them to the cache,
1398 * where moving them to the cache has the highest weighting.
1399 * By forcing some pages into other queues we eventually force the
1400 * system to balance the queues, potentially recovering other unrelated
1401 * space from active. The idea is to not force this to happen too
1405 vm_page_dontneed(vm_page_t m)
1407 static int dnweight;
1411 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1415 * occassionally leave the page alone
1417 if ((dnw & 0x01F0) == 0 ||
1418 VM_PAGE_INQUEUE2(m, PQ_INACTIVE) ||
1419 VM_PAGE_INQUEUE1(m, PQ_CACHE)
1421 if (m->act_count >= ACT_INIT)
1426 if (m->dirty == 0 && pmap_is_modified(m))
1429 if (m->dirty || (dnw & 0x0070) == 0) {
1431 * Deactivate the page 3 times out of 32.
1436 * Cache the page 28 times out of every 32. Note that
1437 * the page is deactivated instead of cached, but placed
1438 * at the head of the queue instead of the tail.
1442 _vm_page_deactivate(m, head);
1446 * Grab a page, waiting until we are waken up due to the page
1447 * changing state. We keep on waiting, if the page continues
1448 * to be in the object. If the page doesn't exist, first allocate it
1449 * and then conditionally zero it.
1451 * This routine may block.
1454 vm_page_grab(vm_object_t object, vm_pindex_t pindex, int allocflags)
1458 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
1460 if ((m = vm_page_lookup(object, pindex)) != NULL) {
1461 if (vm_page_sleep_if_busy(m, TRUE, "pgrbwt")) {
1462 if ((allocflags & VM_ALLOC_RETRY) == 0)
1466 if ((allocflags & VM_ALLOC_WIRED) != 0) {
1467 vm_page_lock_queues();
1469 vm_page_unlock_queues();
1471 if ((allocflags & VM_ALLOC_NOBUSY) == 0)
1476 m = vm_page_alloc(object, pindex, allocflags & ~VM_ALLOC_RETRY);
1478 VM_OBJECT_UNLOCK(object);
1480 VM_OBJECT_LOCK(object);
1481 if ((allocflags & VM_ALLOC_RETRY) == 0)
1485 if (allocflags & VM_ALLOC_ZERO && (m->flags & PG_ZERO) == 0)
1491 * Mapping function for valid bits or for dirty bits in
1492 * a page. May not block.
1494 * Inputs are required to range within a page.
1497 vm_page_bits(int base, int size)
1503 base + size <= PAGE_SIZE,
1504 ("vm_page_bits: illegal base/size %d/%d", base, size)
1507 if (size == 0) /* handle degenerate case */
1510 first_bit = base >> DEV_BSHIFT;
1511 last_bit = (base + size - 1) >> DEV_BSHIFT;
1513 return ((2 << last_bit) - (1 << first_bit));
1517 * vm_page_set_validclean:
1519 * Sets portions of a page valid and clean. The arguments are expected
1520 * to be DEV_BSIZE aligned but if they aren't the bitmap is inclusive
1521 * of any partial chunks touched by the range. The invalid portion of
1522 * such chunks will be zero'd.
1524 * This routine may not block.
1526 * (base + size) must be less then or equal to PAGE_SIZE.
1529 vm_page_set_validclean(vm_page_t m, int base, int size)
1535 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1536 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1537 if (size == 0) /* handle degenerate case */
1541 * If the base is not DEV_BSIZE aligned and the valid
1542 * bit is clear, we have to zero out a portion of the
1545 if ((frag = base & ~(DEV_BSIZE - 1)) != base &&
1546 (m->valid & (1 << (base >> DEV_BSHIFT))) == 0)
1547 pmap_zero_page_area(m, frag, base - frag);
1550 * If the ending offset is not DEV_BSIZE aligned and the
1551 * valid bit is clear, we have to zero out a portion of
1554 endoff = base + size;
1555 if ((frag = endoff & ~(DEV_BSIZE - 1)) != endoff &&
1556 (m->valid & (1 << (endoff >> DEV_BSHIFT))) == 0)
1557 pmap_zero_page_area(m, endoff,
1558 DEV_BSIZE - (endoff & (DEV_BSIZE - 1)));
1561 * Set valid, clear dirty bits. If validating the entire
1562 * page we can safely clear the pmap modify bit. We also
1563 * use this opportunity to clear the VPO_NOSYNC flag. If a process
1564 * takes a write fault on a MAP_NOSYNC memory area the flag will
1567 * We set valid bits inclusive of any overlap, but we can only
1568 * clear dirty bits for DEV_BSIZE chunks that are fully within
1571 pagebits = vm_page_bits(base, size);
1572 m->valid |= pagebits;
1574 if ((frag = base & (DEV_BSIZE - 1)) != 0) {
1575 frag = DEV_BSIZE - frag;
1581 pagebits = vm_page_bits(base, size & (DEV_BSIZE - 1));
1583 m->dirty &= ~pagebits;
1584 if (base == 0 && size == PAGE_SIZE) {
1585 pmap_clear_modify(m);
1586 m->oflags &= ~VPO_NOSYNC;
1591 vm_page_clear_dirty(vm_page_t m, int base, int size)
1594 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1595 m->dirty &= ~vm_page_bits(base, size);
1599 * vm_page_set_invalid:
1601 * Invalidates DEV_BSIZE'd chunks within a page. Both the
1602 * valid and dirty bits for the effected areas are cleared.
1607 vm_page_set_invalid(vm_page_t m, int base, int size)
1611 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1612 bits = vm_page_bits(base, size);
1613 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1614 if (m->valid == VM_PAGE_BITS_ALL && bits != 0)
1618 m->object->generation++;
1622 * vm_page_zero_invalid()
1624 * The kernel assumes that the invalid portions of a page contain
1625 * garbage, but such pages can be mapped into memory by user code.
1626 * When this occurs, we must zero out the non-valid portions of the
1627 * page so user code sees what it expects.
1629 * Pages are most often semi-valid when the end of a file is mapped
1630 * into memory and the file's size is not page aligned.
1633 vm_page_zero_invalid(vm_page_t m, boolean_t setvalid)
1638 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1640 * Scan the valid bits looking for invalid sections that
1641 * must be zerod. Invalid sub-DEV_BSIZE'd areas ( where the
1642 * valid bit may be set ) have already been zerod by
1643 * vm_page_set_validclean().
1645 for (b = i = 0; i <= PAGE_SIZE / DEV_BSIZE; ++i) {
1646 if (i == (PAGE_SIZE / DEV_BSIZE) ||
1647 (m->valid & (1 << i))
1650 pmap_zero_page_area(m,
1651 b << DEV_BSHIFT, (i - b) << DEV_BSHIFT);
1658 * setvalid is TRUE when we can safely set the zero'd areas
1659 * as being valid. We can do this if there are no cache consistancy
1660 * issues. e.g. it is ok to do with UFS, but not ok to do with NFS.
1663 m->valid = VM_PAGE_BITS_ALL;
1669 * Is (partial) page valid? Note that the case where size == 0
1670 * will return FALSE in the degenerate case where the page is
1671 * entirely invalid, and TRUE otherwise.
1676 vm_page_is_valid(vm_page_t m, int base, int size)
1678 int bits = vm_page_bits(base, size);
1680 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1681 if (m->valid && ((m->valid & bits) == bits))
1688 * update dirty bits from pmap/mmu. May not block.
1691 vm_page_test_dirty(vm_page_t m)
1693 if ((m->dirty != VM_PAGE_BITS_ALL) && pmap_is_modified(m)) {
1698 int so_zerocp_fullpage = 0;
1701 * Replace the given page with a copy. The copied page assumes
1702 * the portion of the given page's "wire_count" that is not the
1703 * responsibility of this copy-on-write mechanism.
1705 * The object containing the given page must have a non-zero
1706 * paging-in-progress count and be locked.
1709 vm_page_cowfault(vm_page_t m)
1716 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
1717 KASSERT(object->paging_in_progress != 0,
1718 ("vm_page_cowfault: object %p's paging-in-progress count is zero.",
1725 mnew = vm_page_alloc(object, pindex, VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY);
1727 vm_page_insert(m, object, pindex);
1728 vm_page_unlock_queues();
1729 VM_OBJECT_UNLOCK(object);
1731 VM_OBJECT_LOCK(object);
1732 if (m == vm_page_lookup(object, pindex)) {
1733 vm_page_lock_queues();
1737 * Page disappeared during the wait.
1739 vm_page_lock_queues();
1746 * check to see if we raced with an xmit complete when
1747 * waiting to allocate a page. If so, put things back
1751 vm_page_insert(m, object, pindex);
1752 } else { /* clear COW & copy page */
1753 if (!so_zerocp_fullpage)
1754 pmap_copy_page(m, mnew);
1755 mnew->valid = VM_PAGE_BITS_ALL;
1756 vm_page_dirty(mnew);
1757 mnew->wire_count = m->wire_count - m->cow;
1758 m->wire_count = m->cow;
1763 vm_page_cowclear(vm_page_t m)
1766 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1770 * let vm_fault add back write permission lazily
1774 * sf_buf_free() will free the page, so we needn't do it here
1779 vm_page_cowsetup(vm_page_t m)
1782 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1784 pmap_remove_write(m);
1787 #include "opt_ddb.h"
1789 #include <sys/kernel.h>
1791 #include <ddb/ddb.h>
1793 DB_SHOW_COMMAND(page, vm_page_print_page_info)
1795 db_printf("cnt.v_free_count: %d\n", cnt.v_free_count);
1796 db_printf("cnt.v_cache_count: %d\n", cnt.v_cache_count);
1797 db_printf("cnt.v_inactive_count: %d\n", cnt.v_inactive_count);
1798 db_printf("cnt.v_active_count: %d\n", cnt.v_active_count);
1799 db_printf("cnt.v_wire_count: %d\n", cnt.v_wire_count);
1800 db_printf("cnt.v_free_reserved: %d\n", cnt.v_free_reserved);
1801 db_printf("cnt.v_free_min: %d\n", cnt.v_free_min);
1802 db_printf("cnt.v_free_target: %d\n", cnt.v_free_target);
1803 db_printf("cnt.v_cache_min: %d\n", cnt.v_cache_min);
1804 db_printf("cnt.v_inactive_target: %d\n", cnt.v_inactive_target);
1807 DB_SHOW_COMMAND(pageq, vm_page_print_pageq_info)
1810 db_printf("PQ_FREE:");
1811 db_printf(" %d", cnt.v_free_count);
1814 db_printf("PQ_CACHE:");
1815 db_printf(" %d", *vm_page_queues[PQ_CACHE].cnt);
1818 db_printf("PQ_ACTIVE: %d, PQ_INACTIVE: %d\n",
1819 *vm_page_queues[PQ_ACTIVE].cnt,
1820 *vm_page_queues[PQ_INACTIVE].cnt);