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_extern.h>
122 #include <vm/uma_int.h>
124 #include <machine/md_var.h>
127 * Associated with page of user-allocatable memory is a
131 struct mtx vm_page_queue_mtx;
132 struct mtx vm_page_queue_free_mtx;
134 vm_page_t vm_page_array = 0;
135 int vm_page_array_size = 0;
137 int vm_page_zero_count = 0;
139 static int boot_pages = UMA_BOOT_PAGES;
140 TUNABLE_INT("vm.boot_pages", &boot_pages);
141 SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RD, &boot_pages, 0,
142 "number of pages allocated for bootstrapping the VM system");
147 * Sets the page size, perhaps based upon the memory
148 * size. Must be called before any use of page-size
149 * dependent functions.
152 vm_set_page_size(void)
154 if (cnt.v_page_size == 0)
155 cnt.v_page_size = PAGE_SIZE;
156 if (((cnt.v_page_size - 1) & cnt.v_page_size) != 0)
157 panic("vm_set_page_size: page size not a power of two");
161 * vm_page_blacklist_lookup:
163 * See if a physical address in this page has been listed
164 * in the blacklist tunable. Entries in the tunable are
165 * separated by spaces or commas. If an invalid integer is
166 * encountered then the rest of the string is skipped.
169 vm_page_blacklist_lookup(char *list, vm_paddr_t pa)
174 for (pos = list; *pos != '\0'; pos = cp) {
175 bad = strtoq(pos, &cp, 0);
177 if (*cp == ' ' || *cp == ',') {
184 if (pa == trunc_page(bad))
193 * Initializes the resident memory module.
195 * Allocates memory for the page cells, and
196 * for the object/offset-to-page hash table headers.
197 * Each page cell is initialized and placed on the free list.
200 vm_page_startup(vm_offset_t vaddr)
204 vm_paddr_t page_range;
212 /* the biggest memory array is the second group of pages */
214 vm_paddr_t biggestsize;
215 vm_paddr_t low_water, high_water;
224 vaddr = round_page(vaddr);
226 for (i = 0; phys_avail[i + 1]; i += 2) {
227 phys_avail[i] = round_page(phys_avail[i]);
228 phys_avail[i + 1] = trunc_page(phys_avail[i + 1]);
231 low_water = phys_avail[0];
232 high_water = phys_avail[1];
234 for (i = 0; phys_avail[i + 1]; i += 2) {
235 vm_paddr_t size = phys_avail[i + 1] - phys_avail[i];
237 if (size > biggestsize) {
241 if (phys_avail[i] < low_water)
242 low_water = phys_avail[i];
243 if (phys_avail[i + 1] > high_water)
244 high_water = phys_avail[i + 1];
249 end = phys_avail[biggestone+1];
252 * Initialize the locks.
254 mtx_init(&vm_page_queue_mtx, "vm page queue mutex", NULL, MTX_DEF |
256 mtx_init(&vm_page_queue_free_mtx, "vm page queue free mutex", NULL,
260 * Initialize the queue headers for the free queue, the active queue
261 * and the inactive queue.
266 * Allocate memory for use when boot strapping the kernel memory
269 new_end = end - (boot_pages * UMA_SLAB_SIZE);
270 new_end = trunc_page(new_end);
271 mapped = pmap_map(&vaddr, new_end, end,
272 VM_PROT_READ | VM_PROT_WRITE);
273 bzero((void *)mapped, end - new_end);
274 uma_startup((void *)mapped, boot_pages);
276 #if defined(__amd64__) || defined(__i386__)
278 * Allocate a bitmap to indicate that a random physical page
279 * needs to be included in a minidump.
281 * The amd64 port needs this to indicate which direct map pages
282 * need to be dumped, via calls to dump_add_page()/dump_drop_page().
284 * However, i386 still needs this workspace internally within the
285 * minidump code. In theory, they are not needed on i386, but are
286 * included should the sf_buf code decide to use them.
288 page_range = phys_avail[(nblocks - 1) * 2 + 1] / PAGE_SIZE;
289 vm_page_dump_size = round_page(roundup2(page_range, NBBY) / NBBY);
290 new_end -= vm_page_dump_size;
291 vm_page_dump = (void *)(uintptr_t)pmap_map(&vaddr, new_end,
292 new_end + vm_page_dump_size, VM_PROT_READ | VM_PROT_WRITE);
293 bzero((void *)vm_page_dump, vm_page_dump_size);
296 * Compute the number of pages of memory that will be available for
297 * use (taking into account the overhead of a page structure per
300 first_page = low_water / PAGE_SIZE;
301 page_range = high_water / PAGE_SIZE - first_page;
302 npages = (total - (page_range * sizeof(struct vm_page)) -
303 (end - new_end)) / PAGE_SIZE;
307 * Reserve an unmapped guard page to trap access to vm_page_array[-1].
312 * Initialize the mem entry structures now, and put them in the free
315 new_end = trunc_page(end - page_range * sizeof(struct vm_page));
316 mapped = pmap_map(&vaddr, new_end, end,
317 VM_PROT_READ | VM_PROT_WRITE);
318 vm_page_array = (vm_page_t) mapped;
321 * pmap_map on amd64 comes out of the direct-map, not kvm like i386,
322 * so the pages must be tracked for a crashdump to include this data.
323 * This includes the vm_page_array and the early UMA bootstrap pages.
325 for (pa = new_end; pa < phys_avail[biggestone + 1]; pa += PAGE_SIZE)
328 phys_avail[biggestone + 1] = new_end;
331 * Clear all of the page structures
333 bzero((caddr_t) vm_page_array, page_range * sizeof(struct vm_page));
334 vm_page_array_size = page_range;
337 * This assertion tests the hypothesis that npages and total are
341 for (i = 0; phys_avail[i + 1] != 0; i += 2)
342 page_range += atop(phys_avail[i + 1] - phys_avail[i]);
343 KASSERT(page_range == npages,
344 ("vm_page_startup: inconsistent page counts"));
347 * Construct the free queue(s) in descending order (by physical
348 * address) so that the first 16MB of physical memory is allocated
349 * last rather than first. On large-memory machines, this avoids
350 * the exhaustion of low physical memory before isa_dma_init has run.
352 cnt.v_page_count = 0;
353 cnt.v_free_count = 0;
354 list = getenv("vm.blacklist");
355 for (i = 0; phys_avail[i + 1] != 0; i += 2) {
357 last_pa = phys_avail[i + 1];
358 while (pa < last_pa) {
360 vm_page_blacklist_lookup(list, pa))
361 printf("Skipping page with pa 0x%jx\n",
364 vm_pageq_add_new_page(pa);
373 vm_page_flag_set(vm_page_t m, unsigned short bits)
376 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
381 vm_page_flag_clear(vm_page_t m, unsigned short bits)
384 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
389 vm_page_busy(vm_page_t m)
392 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
393 KASSERT((m->oflags & VPO_BUSY) == 0,
394 ("vm_page_busy: page already busy!!!"));
395 m->oflags |= VPO_BUSY;
401 * wakeup anyone waiting for the page.
404 vm_page_flash(vm_page_t m)
407 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
408 if (m->oflags & VPO_WANTED) {
409 m->oflags &= ~VPO_WANTED;
417 * clear the VPO_BUSY flag and wakeup anyone waiting for the
422 vm_page_wakeup(vm_page_t m)
425 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
426 KASSERT(m->oflags & VPO_BUSY, ("vm_page_wakeup: page not busy!!!"));
427 m->oflags &= ~VPO_BUSY;
432 vm_page_io_start(vm_page_t m)
435 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
440 vm_page_io_finish(vm_page_t m)
443 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
450 * Keep page from being freed by the page daemon
451 * much of the same effect as wiring, except much lower
452 * overhead and should be used only for *very* temporary
453 * holding ("wiring").
456 vm_page_hold(vm_page_t mem)
459 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
464 vm_page_unhold(vm_page_t mem)
467 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
469 KASSERT(mem->hold_count >= 0, ("vm_page_unhold: hold count < 0!!!"));
470 if (mem->hold_count == 0 && VM_PAGE_INQUEUE2(mem, PQ_HOLD))
471 vm_page_free_toq(mem);
479 * The clearing of PG_ZERO is a temporary safety until the code can be
480 * reviewed to determine that PG_ZERO is being properly cleared on
481 * write faults or maps. PG_ZERO was previously cleared in
485 vm_page_free(vm_page_t m)
487 vm_page_flag_clear(m, PG_ZERO);
489 vm_page_zero_idle_wakeup();
495 * Free a page to the zerod-pages queue
498 vm_page_free_zero(vm_page_t m)
500 vm_page_flag_set(m, PG_ZERO);
507 * Sleep and release the page queues lock.
509 * The object containing the given page must be locked.
512 vm_page_sleep(vm_page_t m, const char *msg)
515 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
516 if (!mtx_owned(&vm_page_queue_mtx))
517 vm_page_lock_queues();
518 vm_page_flag_set(m, PG_REFERENCED);
519 vm_page_unlock_queues();
522 * It's possible that while we sleep, the page will get
523 * unbusied and freed. If we are holding the object
524 * lock, we will assume we hold a reference to the object
525 * such that even if m->object changes, we can re-lock
528 m->oflags |= VPO_WANTED;
529 msleep(m, VM_OBJECT_MTX(m->object), PVM, msg, 0);
535 * make page all dirty
538 vm_page_dirty(vm_page_t m)
540 KASSERT(VM_PAGE_GETKNOWNQUEUE1(m) != PQ_CACHE,
541 ("vm_page_dirty: page in cache!"));
542 KASSERT(VM_PAGE_GETKNOWNQUEUE1(m) != PQ_FREE,
543 ("vm_page_dirty: page is free!"));
544 m->dirty = VM_PAGE_BITS_ALL;
550 * Implements Sleator and Tarjan's top-down splay algorithm. Returns
551 * the vm_page containing the given pindex. If, however, that
552 * pindex is not found in the vm_object, returns a vm_page that is
553 * adjacent to the pindex, coming before or after it.
556 vm_page_splay(vm_pindex_t pindex, vm_page_t root)
558 struct vm_page dummy;
559 vm_page_t lefttreemax, righttreemin, y;
563 lefttreemax = righttreemin = &dummy;
565 if (pindex < root->pindex) {
566 if ((y = root->left) == NULL)
568 if (pindex < y->pindex) {
570 root->left = y->right;
573 if ((y = root->left) == NULL)
576 /* Link into the new root's right tree. */
577 righttreemin->left = root;
579 } else if (pindex > root->pindex) {
580 if ((y = root->right) == NULL)
582 if (pindex > y->pindex) {
584 root->right = y->left;
587 if ((y = root->right) == NULL)
590 /* Link into the new root's left tree. */
591 lefttreemax->right = root;
596 /* Assemble the new root. */
597 lefttreemax->right = root->left;
598 righttreemin->left = root->right;
599 root->left = dummy.right;
600 root->right = dummy.left;
605 * vm_page_insert: [ internal use only ]
607 * Inserts the given mem entry into the object and object list.
609 * The pagetables are not updated but will presumably fault the page
610 * in if necessary, or if a kernel page the caller will at some point
611 * enter the page into the kernel's pmap. We are not allowed to block
612 * here so we *can't* do this anyway.
614 * The object and page must be locked.
615 * This routine may not block.
618 vm_page_insert(vm_page_t m, vm_object_t object, vm_pindex_t pindex)
622 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
623 if (m->object != NULL)
624 panic("vm_page_insert: page already inserted");
627 * Record the object/offset pair in this page
633 * Now link into the object's ordered list of backed pages.
639 TAILQ_INSERT_TAIL(&object->memq, m, listq);
641 root = vm_page_splay(pindex, root);
642 if (pindex < root->pindex) {
643 m->left = root->left;
646 TAILQ_INSERT_BEFORE(root, m, listq);
647 } else if (pindex == root->pindex)
648 panic("vm_page_insert: offset already allocated");
650 m->right = root->right;
653 TAILQ_INSERT_AFTER(&object->memq, root, m, listq);
657 object->generation++;
660 * show that the object has one more resident page.
662 object->resident_page_count++;
664 * Hold the vnode until the last page is released.
666 if (object->resident_page_count == 1 && object->type == OBJT_VNODE)
667 vhold((struct vnode *)object->handle);
670 * Since we are inserting a new and possibly dirty page,
671 * update the object's OBJ_MIGHTBEDIRTY flag.
673 if (m->flags & PG_WRITEABLE)
674 vm_object_set_writeable_dirty(object);
679 * NOTE: used by device pager as well -wfj
681 * Removes the given mem entry from the object/offset-page
682 * table and the object page list, but do not invalidate/terminate
685 * The object and page must be locked.
686 * The underlying pmap entry (if any) is NOT removed here.
687 * This routine may not block.
690 vm_page_remove(vm_page_t m)
695 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
696 if ((object = m->object) == NULL)
698 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
699 if (m->oflags & VPO_BUSY) {
700 m->oflags &= ~VPO_BUSY;
705 * Now remove from the object's list of backed pages.
707 if (m != object->root)
708 vm_page_splay(m->pindex, object->root);
712 root = vm_page_splay(m->pindex, m->left);
713 root->right = m->right;
716 TAILQ_REMOVE(&object->memq, m, listq);
719 * And show that the object has one fewer resident page.
721 object->resident_page_count--;
722 object->generation++;
724 * The vnode may now be recycled.
726 if (object->resident_page_count == 0 && object->type == OBJT_VNODE)
727 vdrop((struct vnode *)object->handle);
735 * Returns the page associated with the object/offset
736 * pair specified; if none is found, NULL is returned.
738 * The object must be locked.
739 * This routine may not block.
740 * This is a critical path routine
743 vm_page_lookup(vm_object_t object, vm_pindex_t pindex)
747 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
748 if ((m = object->root) != NULL && m->pindex != pindex) {
749 m = vm_page_splay(pindex, m);
750 if ((object->root = m)->pindex != pindex)
759 * Move the given memory entry from its
760 * current object to the specified target object/offset.
762 * The object must be locked.
763 * This routine may not block.
765 * Note: swap associated with the page must be invalidated by the move. We
766 * have to do this for several reasons: (1) we aren't freeing the
767 * page, (2) we are dirtying the page, (3) the VM system is probably
768 * moving the page from object A to B, and will then later move
769 * the backing store from A to B and we can't have a conflict.
771 * Note: we *always* dirty the page. It is necessary both for the
772 * fact that we moved it, and because we may be invalidating
773 * swap. If the page is on the cache, we have to deactivate it
774 * or vm_page_dirty() will panic. Dirty pages are not allowed
778 vm_page_rename(vm_page_t m, vm_object_t new_object, vm_pindex_t new_pindex)
782 vm_page_insert(m, new_object, new_pindex);
783 if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
784 vm_page_deactivate(m);
789 * vm_page_select_cache:
791 * Move a page of the given color from the cache queue to the free
792 * queue. As pages might be found, but are not applicable, they are
795 * This routine may not block.
798 vm_page_select_cache(int color)
802 boolean_t was_trylocked;
804 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
805 while ((m = vm_pageq_find(PQ_CACHE, color, FALSE)) != NULL) {
806 KASSERT(m->dirty == 0, ("Found dirty cache page %p", m));
807 KASSERT(!pmap_page_is_mapped(m),
808 ("Found mapped cache page %p", m));
809 KASSERT((m->flags & PG_UNMANAGED) == 0,
810 ("Found unmanaged cache page %p", m));
811 KASSERT(m->wire_count == 0, ("Found wired cache page %p", m));
812 if (m->hold_count == 0 && (object = m->object,
813 (was_trylocked = VM_OBJECT_TRYLOCK(object)) ||
814 VM_OBJECT_LOCKED(object))) {
815 KASSERT((m->oflags & VPO_BUSY) == 0 && m->busy == 0,
816 ("Found busy cache page %p", m));
819 VM_OBJECT_UNLOCK(object);
822 vm_page_deactivate(m);
830 * Allocate and return a memory cell associated
831 * with this VM object/offset pair.
834 * VM_ALLOC_NORMAL normal process request
835 * VM_ALLOC_SYSTEM system *really* needs a page
836 * VM_ALLOC_INTERRUPT interrupt time request
837 * VM_ALLOC_ZERO zero page
839 * This routine may not block.
841 * Additional special handling is required when called from an
842 * interrupt (VM_ALLOC_INTERRUPT). We are not allowed to mess with
843 * the page cache in this case.
846 vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int req)
849 int color, flags, page_req;
851 page_req = req & VM_ALLOC_CLASS_MASK;
852 KASSERT(curthread->td_intr_nesting_level == 0 ||
853 page_req == VM_ALLOC_INTERRUPT,
854 ("vm_page_alloc(NORMAL|SYSTEM) in interrupt context"));
856 if ((req & VM_ALLOC_NOOBJ) == 0) {
857 KASSERT(object != NULL,
858 ("vm_page_alloc: NULL object."));
859 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
860 color = (pindex + object->pg_color) & PQ_COLORMASK;
862 color = pindex & PQ_COLORMASK;
865 * The pager is allowed to eat deeper into the free page list.
867 if ((curproc == pageproc) && (page_req != VM_ALLOC_INTERRUPT)) {
868 page_req = VM_ALLOC_SYSTEM;
872 mtx_lock_spin(&vm_page_queue_free_mtx);
873 if (cnt.v_free_count > cnt.v_free_reserved ||
874 (page_req == VM_ALLOC_SYSTEM &&
875 cnt.v_cache_count == 0 &&
876 cnt.v_free_count > cnt.v_interrupt_free_min) ||
877 (page_req == VM_ALLOC_INTERRUPT && cnt.v_free_count > 0)) {
879 * Allocate from the free queue if the number of free pages
880 * exceeds the minimum for the request class.
882 m = vm_pageq_find(PQ_FREE, color, (req & VM_ALLOC_ZERO) != 0);
883 } else if (page_req != VM_ALLOC_INTERRUPT) {
884 mtx_unlock_spin(&vm_page_queue_free_mtx);
886 * Allocatable from cache (non-interrupt only). On success,
887 * we must free the page and try again, thus ensuring that
888 * cnt.v_*_free_min counters are replenished.
890 vm_page_lock_queues();
891 if ((m = vm_page_select_cache(color)) == NULL) {
892 KASSERT(cnt.v_cache_count == 0,
893 ("vm_page_alloc: cache queue is missing %d pages",
895 vm_page_unlock_queues();
896 atomic_add_int(&vm_pageout_deficit, 1);
899 if (page_req != VM_ALLOC_SYSTEM)
902 mtx_lock_spin(&vm_page_queue_free_mtx);
903 if (cnt.v_free_count <= cnt.v_interrupt_free_min) {
904 mtx_unlock_spin(&vm_page_queue_free_mtx);
907 m = vm_pageq_find(PQ_FREE, color, (req & VM_ALLOC_ZERO) != 0);
909 vm_page_unlock_queues();
914 * Not allocatable from cache from interrupt, give up.
916 mtx_unlock_spin(&vm_page_queue_free_mtx);
917 atomic_add_int(&vm_pageout_deficit, 1);
923 * At this point we had better have found a good page.
928 ("vm_page_alloc(): missing page on free queue")
932 * Remove from free queue
934 vm_pageq_remove_nowakeup(m);
937 * Initialize structure. Only the PG_ZERO flag is inherited.
940 if (m->flags & PG_ZERO) {
941 vm_page_zero_count--;
942 if (req & VM_ALLOC_ZERO)
946 if (req & (VM_ALLOC_NOBUSY | VM_ALLOC_NOOBJ))
949 m->oflags = VPO_BUSY;
950 if (req & VM_ALLOC_WIRED) {
951 atomic_add_int(&cnt.v_wire_count, 1);
959 KASSERT(m->dirty == 0, ("vm_page_alloc: free/cache page %p was dirty", m));
960 mtx_unlock_spin(&vm_page_queue_free_mtx);
962 if ((req & VM_ALLOC_NOOBJ) == 0)
963 vm_page_insert(m, object, pindex);
968 * Don't wakeup too often - wakeup the pageout daemon when
969 * we would be nearly out of memory.
971 if (vm_paging_needed())
978 * vm_wait: (also see VM_WAIT macro)
980 * Block until free pages are available for allocation
981 * - Called in various places before memory allocations.
987 vm_page_lock_queues();
988 if (curproc == pageproc) {
989 vm_pageout_pages_needed = 1;
990 msleep(&vm_pageout_pages_needed, &vm_page_queue_mtx,
991 PDROP | PSWP, "VMWait", 0);
993 if (!vm_pages_needed) {
995 wakeup(&vm_pages_needed);
997 msleep(&cnt.v_free_count, &vm_page_queue_mtx, PDROP | PVM,
1003 * vm_waitpfault: (also see VM_WAITPFAULT macro)
1005 * Block until free pages are available for allocation
1006 * - Called only in vm_fault so that processes page faulting
1007 * can be easily tracked.
1008 * - Sleeps at a lower priority than vm_wait() so that vm_wait()ing
1009 * processes will be able to grab memory first. Do not change
1010 * this balance without careful testing first.
1016 vm_page_lock_queues();
1017 if (!vm_pages_needed) {
1018 vm_pages_needed = 1;
1019 wakeup(&vm_pages_needed);
1021 msleep(&cnt.v_free_count, &vm_page_queue_mtx, PDROP | PUSER,
1028 * Put the specified page on the active list (if appropriate).
1029 * Ensure that act_count is at least ACT_INIT but do not otherwise
1032 * The page queues must be locked.
1033 * This routine may not block.
1036 vm_page_activate(vm_page_t m)
1039 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1040 if (VM_PAGE_GETKNOWNQUEUE2(m) != PQ_ACTIVE) {
1041 if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
1042 cnt.v_reactivated++;
1044 if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
1045 if (m->act_count < ACT_INIT)
1046 m->act_count = ACT_INIT;
1047 vm_pageq_enqueue(PQ_ACTIVE, m);
1050 if (m->act_count < ACT_INIT)
1051 m->act_count = ACT_INIT;
1056 * vm_page_free_wakeup:
1058 * Helper routine for vm_page_free_toq() and vm_page_cache(). This
1059 * routine is called when a page has been added to the cache or free
1062 * The page queues must be locked.
1063 * This routine may not block.
1066 vm_page_free_wakeup(void)
1069 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1071 * if pageout daemon needs pages, then tell it that there are
1074 if (vm_pageout_pages_needed &&
1075 cnt.v_cache_count + cnt.v_free_count >= cnt.v_pageout_free_min) {
1076 wakeup(&vm_pageout_pages_needed);
1077 vm_pageout_pages_needed = 0;
1080 * wakeup processes that are waiting on memory if we hit a
1081 * high water mark. And wakeup scheduler process if we have
1082 * lots of memory. this process will swapin processes.
1084 if (vm_pages_needed && !vm_page_count_min()) {
1085 vm_pages_needed = 0;
1086 wakeup(&cnt.v_free_count);
1093 * Returns the given page to the PQ_FREE list,
1094 * disassociating it with any VM object.
1096 * Object and page must be locked prior to entry.
1097 * This routine may not block.
1101 vm_page_free_toq(vm_page_t m)
1103 struct vpgqueues *pq;
1105 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1106 KASSERT(!pmap_page_is_mapped(m),
1107 ("vm_page_free_toq: freeing mapped page %p", m));
1110 if (m->busy || VM_PAGE_INQUEUE1(m, PQ_FREE)) {
1112 "vm_page_free: pindex(%lu), busy(%d), VPO_BUSY(%d), hold(%d)\n",
1113 (u_long)m->pindex, m->busy, (m->oflags & VPO_BUSY) ? 1 : 0,
1115 if (VM_PAGE_INQUEUE1(m, PQ_FREE))
1116 panic("vm_page_free: freeing free page");
1118 panic("vm_page_free: freeing busy page");
1122 * unqueue, then remove page. Note that we cannot destroy
1123 * the page here because we do not want to call the pager's
1124 * callback routine until after we've put the page on the
1125 * appropriate free queue.
1127 vm_pageq_remove_nowakeup(m);
1131 * If fictitious remove object association and
1132 * return, otherwise delay object association removal.
1134 if ((m->flags & PG_FICTITIOUS) != 0) {
1141 if (m->wire_count != 0) {
1142 if (m->wire_count > 1) {
1143 panic("vm_page_free: invalid wire count (%d), pindex: 0x%lx",
1144 m->wire_count, (long)m->pindex);
1146 panic("vm_page_free: freeing wired page");
1148 if (m->hold_count != 0) {
1149 m->flags &= ~PG_ZERO;
1150 VM_PAGE_SETQUEUE2(m, PQ_HOLD);
1152 VM_PAGE_SETQUEUE1(m, PQ_FREE);
1153 pq = &vm_page_queues[VM_PAGE_GETQUEUE(m)];
1154 mtx_lock_spin(&vm_page_queue_free_mtx);
1159 * Put zero'd pages on the end ( where we look for zero'd pages
1160 * first ) and non-zerod pages at the head.
1162 if (m->flags & PG_ZERO) {
1163 TAILQ_INSERT_TAIL(&pq->pl, m, pageq);
1164 ++vm_page_zero_count;
1166 TAILQ_INSERT_HEAD(&pq->pl, m, pageq);
1168 mtx_unlock_spin(&vm_page_queue_free_mtx);
1169 vm_page_free_wakeup();
1175 * Prevent PV management from being done on the page. The page is
1176 * removed from the paging queues as if it were wired, and as a
1177 * consequence of no longer being managed the pageout daemon will not
1178 * touch it (since there is no way to locate the pte mappings for the
1179 * page). madvise() calls that mess with the pmap will also no longer
1180 * operate on the page.
1182 * Beyond that the page is still reasonably 'normal'. Freeing the page
1183 * will clear the flag.
1185 * This routine is used by OBJT_PHYS objects - objects using unswappable
1186 * physical memory as backing store rather then swap-backed memory and
1187 * will eventually be extended to support 4MB unmanaged physical
1191 vm_page_unmanage(vm_page_t m)
1194 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1195 if ((m->flags & PG_UNMANAGED) == 0) {
1196 if (m->wire_count == 0)
1199 vm_page_flag_set(m, PG_UNMANAGED);
1205 * Mark this page as wired down by yet
1206 * another map, removing it from paging queues
1209 * The page queues must be locked.
1210 * This routine may not block.
1213 vm_page_wire(vm_page_t m)
1217 * Only bump the wire statistics if the page is not already wired,
1218 * and only unqueue the page if it is on some queue (if it is unmanaged
1219 * it is already off the queues).
1221 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1222 if (m->flags & PG_FICTITIOUS)
1224 if (m->wire_count == 0) {
1225 if ((m->flags & PG_UNMANAGED) == 0)
1227 atomic_add_int(&cnt.v_wire_count, 1);
1230 KASSERT(m->wire_count != 0, ("vm_page_wire: wire_count overflow m=%p", m));
1236 * Release one wiring of this page, potentially
1237 * enabling it to be paged again.
1239 * Many pages placed on the inactive queue should actually go
1240 * into the cache, but it is difficult to figure out which. What
1241 * we do instead, if the inactive target is well met, is to put
1242 * clean pages at the head of the inactive queue instead of the tail.
1243 * This will cause them to be moved to the cache more quickly and
1244 * if not actively re-referenced, freed more quickly. If we just
1245 * stick these pages at the end of the inactive queue, heavy filesystem
1246 * meta-data accesses can cause an unnecessary paging load on memory bound
1247 * processes. This optimization causes one-time-use metadata to be
1248 * reused more quickly.
1250 * BUT, if we are in a low-memory situation we have no choice but to
1251 * put clean pages on the cache queue.
1253 * A number of routines use vm_page_unwire() to guarantee that the page
1254 * will go into either the inactive or active queues, and will NEVER
1255 * be placed in the cache - for example, just after dirtying a page.
1256 * dirty pages in the cache are not allowed.
1258 * The page queues must be locked.
1259 * This routine may not block.
1262 vm_page_unwire(vm_page_t m, int activate)
1265 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1266 if (m->flags & PG_FICTITIOUS)
1268 if (m->wire_count > 0) {
1270 if (m->wire_count == 0) {
1271 atomic_subtract_int(&cnt.v_wire_count, 1);
1272 if (m->flags & PG_UNMANAGED) {
1274 } else if (activate)
1275 vm_pageq_enqueue(PQ_ACTIVE, m);
1277 vm_page_flag_clear(m, PG_WINATCFLS);
1278 vm_pageq_enqueue(PQ_INACTIVE, m);
1282 panic("vm_page_unwire: invalid wire count: %d", m->wire_count);
1288 * Move the specified page to the inactive queue. If the page has
1289 * any associated swap, the swap is deallocated.
1291 * Normally athead is 0 resulting in LRU operation. athead is set
1292 * to 1 if we want this page to be 'as if it were placed in the cache',
1293 * except without unmapping it from the process address space.
1295 * This routine may not block.
1298 _vm_page_deactivate(vm_page_t m, int athead)
1301 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1304 * Ignore if already inactive.
1306 if (VM_PAGE_INQUEUE2(m, PQ_INACTIVE))
1308 if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
1309 if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
1310 cnt.v_reactivated++;
1311 vm_page_flag_clear(m, PG_WINATCFLS);
1314 TAILQ_INSERT_HEAD(&vm_page_queues[PQ_INACTIVE].pl, m, pageq);
1316 TAILQ_INSERT_TAIL(&vm_page_queues[PQ_INACTIVE].pl, m, pageq);
1317 VM_PAGE_SETQUEUE2(m, PQ_INACTIVE);
1318 vm_page_queues[PQ_INACTIVE].lcnt++;
1319 cnt.v_inactive_count++;
1324 vm_page_deactivate(vm_page_t m)
1326 _vm_page_deactivate(m, 0);
1330 * vm_page_try_to_cache:
1332 * Returns 0 on failure, 1 on success
1335 vm_page_try_to_cache(vm_page_t m)
1338 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1339 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1340 if (m->dirty || m->hold_count || m->busy || m->wire_count ||
1341 (m->oflags & VPO_BUSY) || (m->flags & PG_UNMANAGED)) {
1352 * vm_page_try_to_free()
1354 * Attempt to free the page. If we cannot free it, we do nothing.
1355 * 1 is returned on success, 0 on failure.
1358 vm_page_try_to_free(vm_page_t m)
1361 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1362 if (m->object != NULL)
1363 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1364 if (m->dirty || m->hold_count || m->busy || m->wire_count ||
1365 (m->oflags & VPO_BUSY) || (m->flags & PG_UNMANAGED)) {
1378 * Put the specified page onto the page cache queue (if appropriate).
1380 * This routine may not block.
1383 vm_page_cache(vm_page_t m)
1386 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1387 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1388 if ((m->flags & PG_UNMANAGED) || (m->oflags & VPO_BUSY) || m->busy ||
1389 m->hold_count || m->wire_count) {
1390 printf("vm_page_cache: attempting to cache busy page\n");
1393 if (VM_PAGE_INQUEUE1(m, PQ_CACHE))
1397 * Remove all pmaps and indicate that the page is not
1398 * writeable or mapped.
1401 if (m->dirty != 0) {
1402 panic("vm_page_cache: caching a dirty page, pindex: %ld",
1405 vm_pageq_remove_nowakeup(m);
1406 vm_pageq_enqueue(PQ_CACHE + m->pc, m);
1407 vm_page_free_wakeup();
1413 * Cache, deactivate, or do nothing as appropriate. This routine
1414 * is typically used by madvise() MADV_DONTNEED.
1416 * Generally speaking we want to move the page into the cache so
1417 * it gets reused quickly. However, this can result in a silly syndrome
1418 * due to the page recycling too quickly. Small objects will not be
1419 * fully cached. On the otherhand, if we move the page to the inactive
1420 * queue we wind up with a problem whereby very large objects
1421 * unnecessarily blow away our inactive and cache queues.
1423 * The solution is to move the pages based on a fixed weighting. We
1424 * either leave them alone, deactivate them, or move them to the cache,
1425 * where moving them to the cache has the highest weighting.
1426 * By forcing some pages into other queues we eventually force the
1427 * system to balance the queues, potentially recovering other unrelated
1428 * space from active. The idea is to not force this to happen too
1432 vm_page_dontneed(vm_page_t m)
1434 static int dnweight;
1438 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1442 * occassionally leave the page alone
1444 if ((dnw & 0x01F0) == 0 ||
1445 VM_PAGE_INQUEUE2(m, PQ_INACTIVE) ||
1446 VM_PAGE_INQUEUE1(m, PQ_CACHE)
1448 if (m->act_count >= ACT_INIT)
1453 if (m->dirty == 0 && pmap_is_modified(m))
1456 if (m->dirty || (dnw & 0x0070) == 0) {
1458 * Deactivate the page 3 times out of 32.
1463 * Cache the page 28 times out of every 32. Note that
1464 * the page is deactivated instead of cached, but placed
1465 * at the head of the queue instead of the tail.
1469 _vm_page_deactivate(m, head);
1473 * Grab a page, waiting until we are waken up due to the page
1474 * changing state. We keep on waiting, if the page continues
1475 * to be in the object. If the page doesn't exist, first allocate it
1476 * and then conditionally zero it.
1478 * This routine may block.
1481 vm_page_grab(vm_object_t object, vm_pindex_t pindex, int allocflags)
1485 VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
1487 if ((m = vm_page_lookup(object, pindex)) != NULL) {
1488 if (vm_page_sleep_if_busy(m, TRUE, "pgrbwt")) {
1489 if ((allocflags & VM_ALLOC_RETRY) == 0)
1493 if ((allocflags & VM_ALLOC_WIRED) != 0) {
1494 vm_page_lock_queues();
1496 vm_page_unlock_queues();
1498 if ((allocflags & VM_ALLOC_NOBUSY) == 0)
1503 m = vm_page_alloc(object, pindex, allocflags & ~VM_ALLOC_RETRY);
1505 VM_OBJECT_UNLOCK(object);
1507 VM_OBJECT_LOCK(object);
1508 if ((allocflags & VM_ALLOC_RETRY) == 0)
1512 if (allocflags & VM_ALLOC_ZERO && (m->flags & PG_ZERO) == 0)
1518 * Mapping function for valid bits or for dirty bits in
1519 * a page. May not block.
1521 * Inputs are required to range within a page.
1524 vm_page_bits(int base, int size)
1530 base + size <= PAGE_SIZE,
1531 ("vm_page_bits: illegal base/size %d/%d", base, size)
1534 if (size == 0) /* handle degenerate case */
1537 first_bit = base >> DEV_BSHIFT;
1538 last_bit = (base + size - 1) >> DEV_BSHIFT;
1540 return ((2 << last_bit) - (1 << first_bit));
1544 * vm_page_set_validclean:
1546 * Sets portions of a page valid and clean. The arguments are expected
1547 * to be DEV_BSIZE aligned but if they aren't the bitmap is inclusive
1548 * of any partial chunks touched by the range. The invalid portion of
1549 * such chunks will be zero'd.
1551 * This routine may not block.
1553 * (base + size) must be less then or equal to PAGE_SIZE.
1556 vm_page_set_validclean(vm_page_t m, int base, int size)
1562 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1563 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1564 if (size == 0) /* handle degenerate case */
1568 * If the base is not DEV_BSIZE aligned and the valid
1569 * bit is clear, we have to zero out a portion of the
1572 if ((frag = base & ~(DEV_BSIZE - 1)) != base &&
1573 (m->valid & (1 << (base >> DEV_BSHIFT))) == 0)
1574 pmap_zero_page_area(m, frag, base - frag);
1577 * If the ending offset is not DEV_BSIZE aligned and the
1578 * valid bit is clear, we have to zero out a portion of
1581 endoff = base + size;
1582 if ((frag = endoff & ~(DEV_BSIZE - 1)) != endoff &&
1583 (m->valid & (1 << (endoff >> DEV_BSHIFT))) == 0)
1584 pmap_zero_page_area(m, endoff,
1585 DEV_BSIZE - (endoff & (DEV_BSIZE - 1)));
1588 * Set valid, clear dirty bits. If validating the entire
1589 * page we can safely clear the pmap modify bit. We also
1590 * use this opportunity to clear the VPO_NOSYNC flag. If a process
1591 * takes a write fault on a MAP_NOSYNC memory area the flag will
1594 * We set valid bits inclusive of any overlap, but we can only
1595 * clear dirty bits for DEV_BSIZE chunks that are fully within
1598 pagebits = vm_page_bits(base, size);
1599 m->valid |= pagebits;
1601 if ((frag = base & (DEV_BSIZE - 1)) != 0) {
1602 frag = DEV_BSIZE - frag;
1608 pagebits = vm_page_bits(base, size & (DEV_BSIZE - 1));
1610 m->dirty &= ~pagebits;
1611 if (base == 0 && size == PAGE_SIZE) {
1612 pmap_clear_modify(m);
1613 m->oflags &= ~VPO_NOSYNC;
1618 vm_page_clear_dirty(vm_page_t m, int base, int size)
1621 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1622 m->dirty &= ~vm_page_bits(base, size);
1626 * vm_page_set_invalid:
1628 * Invalidates DEV_BSIZE'd chunks within a page. Both the
1629 * valid and dirty bits for the effected areas are cleared.
1634 vm_page_set_invalid(vm_page_t m, int base, int size)
1638 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1639 bits = vm_page_bits(base, size);
1640 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1641 if (m->valid == VM_PAGE_BITS_ALL && bits != 0)
1645 m->object->generation++;
1649 * vm_page_zero_invalid()
1651 * The kernel assumes that the invalid portions of a page contain
1652 * garbage, but such pages can be mapped into memory by user code.
1653 * When this occurs, we must zero out the non-valid portions of the
1654 * page so user code sees what it expects.
1656 * Pages are most often semi-valid when the end of a file is mapped
1657 * into memory and the file's size is not page aligned.
1660 vm_page_zero_invalid(vm_page_t m, boolean_t setvalid)
1665 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1667 * Scan the valid bits looking for invalid sections that
1668 * must be zerod. Invalid sub-DEV_BSIZE'd areas ( where the
1669 * valid bit may be set ) have already been zerod by
1670 * vm_page_set_validclean().
1672 for (b = i = 0; i <= PAGE_SIZE / DEV_BSIZE; ++i) {
1673 if (i == (PAGE_SIZE / DEV_BSIZE) ||
1674 (m->valid & (1 << i))
1677 pmap_zero_page_area(m,
1678 b << DEV_BSHIFT, (i - b) << DEV_BSHIFT);
1685 * setvalid is TRUE when we can safely set the zero'd areas
1686 * as being valid. We can do this if there are no cache consistancy
1687 * issues. e.g. it is ok to do with UFS, but not ok to do with NFS.
1690 m->valid = VM_PAGE_BITS_ALL;
1696 * Is (partial) page valid? Note that the case where size == 0
1697 * will return FALSE in the degenerate case where the page is
1698 * entirely invalid, and TRUE otherwise.
1703 vm_page_is_valid(vm_page_t m, int base, int size)
1705 int bits = vm_page_bits(base, size);
1707 VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED);
1708 if (m->valid && ((m->valid & bits) == bits))
1715 * update dirty bits from pmap/mmu. May not block.
1718 vm_page_test_dirty(vm_page_t m)
1720 if ((m->dirty != VM_PAGE_BITS_ALL) && pmap_is_modified(m)) {
1725 int so_zerocp_fullpage = 0;
1728 vm_page_cowfault(vm_page_t m)
1740 mnew = vm_page_alloc(object, pindex, VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY);
1742 vm_page_insert(m, object, pindex);
1743 vm_page_unlock_queues();
1744 VM_OBJECT_UNLOCK(object);
1746 VM_OBJECT_LOCK(object);
1747 vm_page_lock_queues();
1753 * check to see if we raced with an xmit complete when
1754 * waiting to allocate a page. If so, put things back
1758 vm_page_insert(m, object, pindex);
1759 } else { /* clear COW & copy page */
1760 if (!so_zerocp_fullpage)
1761 pmap_copy_page(m, mnew);
1762 mnew->valid = VM_PAGE_BITS_ALL;
1763 vm_page_dirty(mnew);
1764 mnew->wire_count = m->wire_count - m->cow;
1765 m->wire_count = m->cow;
1770 vm_page_cowclear(vm_page_t m)
1773 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1777 * let vm_fault add back write permission lazily
1781 * sf_buf_free() will free the page, so we needn't do it here
1786 vm_page_cowsetup(vm_page_t m)
1789 mtx_assert(&vm_page_queue_mtx, MA_OWNED);
1791 pmap_remove_write(m);
1794 #include "opt_ddb.h"
1796 #include <sys/kernel.h>
1798 #include <ddb/ddb.h>
1800 DB_SHOW_COMMAND(page, vm_page_print_page_info)
1802 db_printf("cnt.v_free_count: %d\n", cnt.v_free_count);
1803 db_printf("cnt.v_cache_count: %d\n", cnt.v_cache_count);
1804 db_printf("cnt.v_inactive_count: %d\n", cnt.v_inactive_count);
1805 db_printf("cnt.v_active_count: %d\n", cnt.v_active_count);
1806 db_printf("cnt.v_wire_count: %d\n", cnt.v_wire_count);
1807 db_printf("cnt.v_free_reserved: %d\n", cnt.v_free_reserved);
1808 db_printf("cnt.v_free_min: %d\n", cnt.v_free_min);
1809 db_printf("cnt.v_free_target: %d\n", cnt.v_free_target);
1810 db_printf("cnt.v_cache_min: %d\n", cnt.v_cache_min);
1811 db_printf("cnt.v_inactive_target: %d\n", cnt.v_inactive_target);
1814 DB_SHOW_COMMAND(pageq, vm_page_print_pageq_info)
1817 db_printf("PQ_FREE:");
1818 for (i = 0; i < PQ_NUMCOLORS; i++) {
1819 db_printf(" %d", vm_page_queues[PQ_FREE + i].lcnt);
1823 db_printf("PQ_CACHE:");
1824 for (i = 0; i < PQ_NUMCOLORS; i++) {
1825 db_printf(" %d", vm_page_queues[PQ_CACHE + i].lcnt);
1829 db_printf("PQ_ACTIVE: %d, PQ_INACTIVE: %d\n",
1830 vm_page_queues[PQ_ACTIVE].lcnt,
1831 vm_page_queues[PQ_INACTIVE].lcnt);