diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -400,13 +400,13 @@ vm_page_alloc.9 \ vm_page_bits.9 \ vm_page_busy.9 \ - vm_page_deactivate.9 \ vm_page_dontneed.9 \ vm_page_aflag.9 \ vm_page_free.9 \ vm_page_grab.9 \ vm_page_insert.9 \ vm_page_lookup.9 \ + vm_page_queue.9 \ vm_page_rename.9 \ vm_page_wire.9 \ vm_set_page_size.9 \ @@ -2402,6 +2402,16 @@ vm_page_free.9 vm_page_free_zero.9 \ vm_page_free.9 vm_page_try_to_free.9 MLINKS+=vm_page_insert.9 vm_page_remove.9 +MLINKS+=vm_page_queue.9 vm_page_active.9 \ + vm_page_queue.9 vm_page_activate.9 \ + vm_page_queue.9 vm_page_deactivate.9 \ + vm_page_queue.9 vm_page_dequeue.9 \ + vm_page_queue.9 vm_page_dequeue_noreuse.9 \ + vm_page_queue.9 vm_page_enqueue.9 \ + vm_page_queue.9 vm_page_inactive.9 \ + vm_page_queue.9 vm_page_in_laundry.9 \ + vm_page_queue.9 vm_page_launder.9 \ + vm_page_queue.9 vm_page_unswappable.9 MLINKS+=vm_page_wire.9 vm_page_unwire.9 \ vm_page_wire.9 vm_page_unwire_noq.9 \ vm_page_wire.9 vm_page_wire_mapped.9 diff --git a/share/man/man9/vm_page_deactivate.9 b/share/man/man9/vm_page_deactivate.9 deleted file mode 100644 --- a/share/man/man9/vm_page_deactivate.9 +++ /dev/null @@ -1,48 +0,0 @@ -.\" -.\" Copyright (C) 2001 Chad David . All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice(s), this list of conditions and the following disclaimer as -.\" the first lines of this file unmodified other than the possible -.\" addition of one or more copyright notices. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice(s), this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY -.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY -.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -.\" DAMAGE. -.\" -.Dd July 24, 2001 -.Dt VM_PAGE_DEACTIVATE 9 -.Os -.Sh NAME -.Nm vm_page_deactivate -.Nd "deactivate a page" -.Sh SYNOPSIS -.In sys/param.h -.In vm/vm.h -.In vm/vm_page.h -.Ft void -.Fn vm_page_deactivate "vm_page_t m" -.Sh DESCRIPTION -The -.Fn vm_page_deactivate -function moves the given page to the inactive queue as long as it is -unmanaged and is not wired. -.Sh SEE ALSO -.Xr vm_page_wire 9 -.Sh AUTHORS -This manual page was written by -.An Chad David Aq Mt davidc@acns.ab.ca . diff --git a/share/man/man9/vm_page_queue.9 b/share/man/man9/vm_page_queue.9 new file mode 100644 --- /dev/null +++ b/share/man/man9/vm_page_queue.9 @@ -0,0 +1,181 @@ +.\" +.\" Copyright (C) 2001 Chad David . All rights reserved. +.\" Copyright (c) 2023 The FreeBSD Foundation +.\" +.\" Portions of this documentation were written by Mitchell Horne +.\" under sponsorship from the FreeBSD Foundation. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY +.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +.\" DAMAGE. +.\" +.Dd November 6, 2023 +.Dt VM_PAGE_QUEUE 9 +.Os +.Sh NAME +.Nm vm_page_queue , +.Nm vm_page_dequeue , +.Nm vm_page_enqueue , +.Nm vm_page_activate , +.Nm vm_page_deactivate , +.Nm vm_page_deactivate_noreuse , +.Nm vm_page_launder , +.Nm vm_page_unswappable , +.Nm vm_page_active , +.Nm vm_page_inactive , +.Nm vm_page_in_laundry +.Nd "adjust a page's pageout queue membership" +.Sh SYNOPSIS +.In sys/param.h +.In vm/vm.h +.In vm/vm_page.h +.Ft uint8_t +.Fn vm_page_queue "vm_page_t m" +.Ft void +.Fn vm_page_dequeue "vm_page_t m" +.Ft void +.Fn vm_page_enqueue "vm_page_t m" "uint8_t queue" +.Ft void +.Fn vm_page_activate "vm_page_t m" +.Ft void +.Fn vm_page_deactivate "vm_page_t m" +.Ft void +.Fn vm_page_deactivate_noreuse "vm_page_t m" +.Ft void +.Fn vm_page_launder "vm_page_t m" +.Ft void +.Fn vm_page_unswappable "vm_page_t m" +.Ft bool +.Fn vm_page_active "vm_page_t m" +.Ft bool +.Fn vm_page_inactive "vm_page_t m" +.Ft bool +.Fn vm_page_in_laundry "vm_page_t m" +.Sh DESCRIPTION +The +.Fx +VM system maintains several "pagequeues"; lists of +.Vt vm_page_t +objects which are scanned and modified by the pageout dameon as it evaluates +pages for reuse. +Together with the pageout daemon, these queues create a responsive system +approximating a least recently used (LRU) replacement policy for VM pages. +.Pp +Every +.Vt vm_page_t +in the system may belong to one pagequeue at a time, or no pagequeue at all. +.Pp +The different pagequeues are defined in +.In vm/vm_page.h , +and function as follows: +.Bl -tag -width ".Dv PQ_UNSWAPPABLE" +.It Dv PQ_NONE +The page and does not exist on any pagequeue, and cannot be paged out. +The page could be wired +.Po see +.Xr vm_page_wire 9 +.Pc , +unmanaged, +or it exists on a free list. +.It Dv PQ_ACTIVE +The active pagequeue contains pages which are in active use by the system, and +will be periodically scanned by the pageout daemon. +Pages whose contents are frequently and/or recently referenced ("active") will +remain on the active queue, while less active pages are candidates for +relocation to the inactive or laundry queues. +.It Dv PQ_INACTIVE +The inactive pagequeue contains pages which are not recently referenced. +Their contents may or may not be dirty, but dirty pages may be moved to the +laundry queue. +.It Dv PQ_LAUNDRY +The laundry pagequeue contains dirty, unreferenced pages. +A separate laundry worker thread will periodically clean (flush) these pages +and release them to the free lists. +.It Dv PQ_UNSWAPPABLE +A special subset of the laundry queue used to hold dirty, anonymous pages which +could not be written to swap space. +Its purpose is for optimization and this pagequeue should generally not be +touched. +.El +.Pp +The +.Fn vm_page_queue +function returns the index of the queue containing +.Fa m , +or +.Dv PQ_NONE . +.Pp +The +.Fn vm_page_dequeue +function removes +.Fa m +from its current page queue, leaving it unattached to any page queue. +The +.Fn vm_page_enqueue +function adds the given page +.Fa m +to the specified pagequeue, +.Fa queue . +.Pp +The +.Fn vm_page_activate +function moves, or requeues, the given page to the active queue. +.Pp +The +.Fn vm_page_deactivate +function moves, or requeues, the given page to the inactive queue. +The +.Fn vm_page_deactivate_noreuse +function behaves similarly, but requests that +.Fa m +be enqueued near the head of the list, bypassing the LRU policy. +.Pp +The +.Fn vm_page_launder +function moves the given page to the laundry queue. +.Pp +The +.Fn vm_page_unswappable +function moves the given page to the unswappable holding queue. +.Pp +The +.Fn vm_page_active , +.Fn vm_page_inactive , +and +.Fn vm_page_in_laundry +helper functions return a boolean value indicating if the specified page +.Fa m +is a member of the active, inactive, or laundry queues, respectively. +.Sh IMPLEMENTATION NOTES +The page queues described above are not necessarily global, but are instead +duplicated for each memory domain. +.Pp +The addition or removal of a page from a given pagequeue is not instantaenous; +for performance reasons some updates to pagequeues are batched and may be +deferred indefinitely. +.Sh SEE ALSO +.Xr vm_page_wire 9 +.Sh AUTHORS +This manual page was written by +.An Chad David Aq Mt davidc@acns.ab.ca +and rewritten by +.An Mitchell Horne Aq Mt mhorne@FreeBSD.org .