class PageQueues
Defined at line 37 of file ../../zircon/kernel/vm/include/vm/page_queues.h
Allocated pages that are part of the cow pages in a VmObjectPaged can be placed in a page queue.
The page queues provide a way to
* Classify and group pages across VMO boundaries
* Retrieve the VMO that a page is contained in (via a back reference stored in the vm_page_t)
Once a page has been placed in a page queue its queue_node becomes owned by the page queue and
must not be used until the page has been Remove'd. It is not sufficient to call list_delete on
the queue_node yourself as this operation is not atomic and needs to be performed whilst holding
the PageQueues::lock_.
Public Members
static const size_t kNumReclaim
static const size_t kNumActiveQueues
static const size_t kActiveInactiveErrorMargin
static const size_t kNumOldestQueues
static const size_t kNumIsolateQueues
static const zx_duration_mono_t kDefaultMinMruRotateTime
static const zx_duration_mono_t kDefaultMaxMruRotateTime
static const uint64_t kDefaultActiveRatioMultiplier
Public Methods
void PageQueues (const PageQueues & )
Defined at line 88 of file ../../zircon/kernel/vm/include/vm/page_queues.h
void PageQueues (PageQueues && )
Defined at line 88 of file ../../zircon/kernel/vm/include/vm/page_queues.h
PageQueues & operator= (const PageQueues & )
Defined at line 88 of file ../../zircon/kernel/vm/include/vm/page_queues.h
PageQueues & operator= (PageQueues && )
Defined at line 88 of file ../../zircon/kernel/vm/include/vm/page_queues.h
Lock<CriticalMutex> * get_lock ()
Provides access to the underlying lock, allowing _Locked variants to be called. Use of this is
highly discouraged as the underlying lock is a CriticalMutex which disables preemption.
Preferably *Array variations should be used, but this provides a higher performance mechanism
when needed.
Defined at line 158 of file ../../zircon/kernel/vm/include/vm/page_queues.h
void PageQueues ()
Defined at line 193 of file ../../zircon/kernel/vm/page_queues.cc
void ~PageQueues ()
Defined at line 205 of file ../../zircon/kernel/vm/page_queues.cc
uint64_t GetLruPagesCompressed ()
Returns a global count of all pages compressed at the point of LRU change. This is a global
method and will include stats from every PageQueues that has been instantiated.
Defined at line 191 of file ../../zircon/kernel/vm/page_queues.cc
void StartThreads (zx_duration_mono_t min_mru_rotate_time, zx_duration_mono_t max_mru_rotate_time)
Creates any threads for queue management. This needs to be done separately to construction as
there is a recursive dependency where creating threads will need to manipulate pages, which
will call back into the page queues.
Delaying thread creation is fine as these threads are purely for aging and eviction management,
which is not needed during early kernel boot.
Failure to start the threads may cause operations such as RotatePagerBackedQueues to block
indefinitely as they might attempt to offload work to a nonexistent thread. This issue is only
relevant for unittests that may wish to avoid starting the threads for some tests.
It is the responsibility of the caller to only call this once, otherwise it will panic.
Defined at line 216 of file ../../zircon/kernel/vm/page_queues.cc
void StartDebugCompressor ()
Initializes and starts the debug compression, which attempts to immediately compress a random
subset of pages added to the page queues. It is an error to call this if there is no compressor
or if not running in debug mode.
Defined at line 260 of file ../../zircon/kernel/vm/page_queues.cc
bool ReclaimIsOnlyPagerBacked ()
Returns whether or not the reclaim queues only include pager backed pages or not.
Defined at line 269 of file ../../zircon/kernel/vm/include/vm/page_queues.h
void SetActiveRatioMultiplier (uint32_t multiplier)
Sets the active ratio multiplier.
Defined at line 311 of file ../../zircon/kernel/vm/page_queues.cc
void SetLruAction (LruAction action)
Defined at line 306 of file ../../zircon/kernel/vm/page_queues.cc
Thread * DebugGetLruThread ()
Debug methods to retrieve a reference to any lru and mru threads. These are intended for use
during tests / debugging and hence bypass the lock normally needed to read these members. It is
up to the caller to know if these objects are alive or not.
Defined at line 334 of file ../../zircon/kernel/vm/include/vm/page_queues.h
Thread * DebugGetMruThread ()
Defined at line 335 of file ../../zircon/kernel/vm/include/vm/page_queues.h
void SetWired (vm_page_t * page, VmCowPages * object, uint64_t page_offset)
All Set operations places a page, which must not currently be in a page queue, into the
specified queue. The backlink information of |object| and |page_offset| must be specified and
valid. If the page is either removed from the referenced object, or moved to a different
offset, the backlink information must be updated either by calling ChangeObjectOffsetLocked, or
removing the page completely from the queues.
Defined at line 942 of file ../../zircon/kernel/vm/page_queues.cc
void SetAnonymous (vm_page_t * page, VmCowPages * object, uint64_t page_offset, bool skip_reclaim)
|skip_reclaim| controls whether reclaiming the page should be forcibly skipped regardless of
whether anonymous pages are considered reclaimable in general.
Defined at line 955 of file ../../zircon/kernel/vm/page_queues.cc
void SetReclaim (vm_page_t * page, VmCowPages * object, uint64_t page_offset)
Defined at line 999 of file ../../zircon/kernel/vm/page_queues.cc
void SetPagerBackedDirty (vm_page_t * page, VmCowPages * object, uint64_t page_offset)
Defined at line 1023 of file ../../zircon/kernel/vm/page_queues.cc
void SetAnonymousZeroFork (vm_page_t * page, VmCowPages * object, uint64_t page_offset)
Defined at line 1036 of file ../../zircon/kernel/vm/page_queues.cc
void SetHighPriority (vm_page_t * page, VmCowPages * object, uint64_t page_offset)
Defined at line 971 of file ../../zircon/kernel/vm/page_queues.cc
void MoveToWired (vm_page_t * page)
All Move operations change the queue that a page is considered to be in, but do not change the
object or offset backlink information. The page must currently be in a valid page queue.
Defined at line 947 of file ../../zircon/kernel/vm/page_queues.cc
void MoveToAnonymous (vm_page_t * page, bool skip_reclaim)
|skip_reclaim| controls whether reclaiming the page should be forcibly skipped regardless of
whether anonymous pages are considered reclaimable in general.
Defined at line 984 of file ../../zircon/kernel/vm/page_queues.cc
void MoveToReclaim (vm_page_t * page)
Defined at line 1007 of file ../../zircon/kernel/vm/page_queues.cc
void MoveToReclaimDontNeed (vm_page_t * page)
Defined at line 1015 of file ../../zircon/kernel/vm/page_queues.cc
void MoveToPagerBackedDirty (vm_page_t * page)
Defined at line 1028 of file ../../zircon/kernel/vm/page_queues.cc
void MoveToHighPriority (vm_page_t * page)
Defined at line 976 of file ../../zircon/kernel/vm/page_queues.cc
void MoveAnonymousToAnonymousZeroFork (vm_page_t * page)
If a page is presently in the anonymous (or reclaim queue, depending if anonymous pages are
reclaimable) moves it to the appropriate anonymous zero fork queue (exact queue depends on
whether zero forks are reclaimable or not). If the page is not in the anonymous queue then it
is not modified.
Defined at line 1051 of file ../../zircon/kernel/vm/page_queues.cc
void CompressFailed (vm_page_t * page)
Indicates that page has failed a compression attempted, and moves it to a separate queue to
prevent it from being considered part of the reclaim set, which makes it neither active nor
inactive. The specified page must be in the page queues, but if not presently in a reclaim
queue this method will do nothing.
TODO(https://fxbug.dev/42138396): Determine whether/how pages are moved back into the reclaim
pool and either further generalize this to support pager backed, or specialize FailedReclaim to
be explicitly only anonymous.
Defined at line 1085 of file ../../zircon/kernel/vm/page_queues.cc
void ChangeObjectOffset (vm_page_t * page, VmCowPages * object, uint64_t page_offset)
Changes the backlink information for a page and should only be called by the page owner under
its lock (that is the VMO lock). The page must currently be in a valid page queue.
Defined at line 1097 of file ../../zircon/kernel/vm/page_queues.cc
void ChangeObjectOffsetArray (vm_page_t ** pages, VmCowPages * object, uint64_t * offsets, size_t count)
Defined at line 1102 of file ../../zircon/kernel/vm/page_queues.cc
void ChangeObjectOffsetLockedList (vm_page_t * page, VmCowPages * object, uint64_t page_offset)
Externally locked variant of CHangeObjectOffset that can be used for more efficient batch
operations. In addition to the annotated lock_, the VMO lock of the owner is also required to
be held.
Defined at line 1120 of file ../../zircon/kernel/vm/page_queues.cc
void Remove (vm_page_t * page)
Removes the page from any page list and returns ownership of the queue_node.
Defined at line 1142 of file ../../zircon/kernel/vm/page_queues.cc
void RemoveArrayIntoList (vm_page_t ** page, size_t count, list_node_t * out_list)
Batched version of Remove that also places all the pages in the specified list
Defined at line 1150 of file ../../zircon/kernel/vm/page_queues.cc
void MarkAccessed (vm_page_t * page)
Tells the page queue this page has been accessed, and it should have its position in the queues
updated.
Defined at line 858 of file ../../zircon/kernel/vm/page_queues.cc
const char * string_from_age_reason (PageQueues::AgeReason reason)
Defined at line 463 of file ../../zircon/kernel/vm/page_queues.cc
void RotateReclaimQueues ()
Performs a manually requested aging event. This ignores usual aging triggers / restrictions and
waits, if necessary, for aging to be possible and then performs it.
Only for tests and debugging.
Defined at line 698 of file ../../zircon/kernel/vm/page_queues.cc
ktl::optional<VmoBacklink> PopAnonymousZeroFork ()
Moves a page from from the anonymous zero fork queue into the anonymous queue and returns
the backlink information. If the zero fork queue is empty then a nullopt is returned, otherwise
if it has_value the vmo field may be null to indicate that the vmo is running its destructor
(see VmoBacklink for more details).
Defined at line 1308 of file ../../zircon/kernel/vm/page_queues.cc
ktl::optional<VmoBacklink> PeekIsolate (size_t lowest_queue)
Looks at the isolate queues and returns backlink information of the first page found. If the
isolate queue is empty then LRU queues up to |lowest_queue| epochs from the most recent will be
processed to attempt to fill the isolate list. If no page was found a nullopt is returned,
otherwise if it has_value the vmo field may be null to indicate that the vmo is running its
destructor (see VmoBacklink for more details). If a page is returned its location in the
reclaim queue is not modified.
Defined at line 1329 of file ../../zircon/kernel/vm/page_queues.cc
ktl::optional<VmoBacklink> GetCowForLoanedPage (vm_page_t * page)
Can be called while the |page| is known to be in the loaned state. This method checks if it is
in the page queues, and if so returns a reference to the cow pages that owns it.
The page must be 'owned' by the caller, in so far as the page->state() is guaranteed to not be
changing.
Defined at line 1422 of file ../../zircon/kernel/vm/page_queues.cc
ReclaimCounts GetReclaimQueueCounts ()
Returns just the reclaim queue counts. Called from the zx_object_get_info() syscall.
Defined at line 1168 of file ../../zircon/kernel/vm/page_queues.cc
Counts QueueCounts ()
Defined at line 1201 of file ../../zircon/kernel/vm/page_queues.cc
ActiveInactiveCounts GetActiveInactiveCounts ()
Defined at line 1375 of file ../../zircon/kernel/vm/page_queues.cc
void Dump ()
Defined at line 476 of file ../../zircon/kernel/vm/page_queues.cc
void EnableAnonymousReclaim (bool zero_forks)
Enables reclamation of anonymous pages by causing them to be placed into the reclaimable queue
instead of the dedicated anonymous queue. The |zero_forks| parameter controls whether the
anonymous zero forks should also go into the general reclaimable queue or not.
Any pages already placed into the anonymous queues will be moved over, and there is no way to
disable this once enabled.
Defined at line 1397 of file ../../zircon/kernel/vm/page_queues.cc
bool DebugPageIsReclaim (const vm_page_t * page, size_t * queue)
This takes an optional output parameter that, if the function returns true, will contain the
index of the queue that the page was in.
Defined at line 1267 of file ../../zircon/kernel/vm/page_queues.cc
bool DebugPageIsReclaimIsolate (const vm_page_t * page)
Defined at line 1271 of file ../../zircon/kernel/vm/page_queues.cc
bool DebugPageIsPagerBackedDirty (const vm_page_t * page)
Defined at line 1276 of file ../../zircon/kernel/vm/page_queues.cc
bool DebugPageIsAnonymous (const vm_page_t * page)
Defined at line 1281 of file ../../zircon/kernel/vm/page_queues.cc
bool DebugPageIsAnonymousZeroFork (const vm_page_t * page)
Defined at line 1296 of file ../../zircon/kernel/vm/page_queues.cc
bool DebugPageIsAnyAnonymous (const vm_page_t * page)
Defined at line 1304 of file ../../zircon/kernel/vm/page_queues.cc
bool DebugPageIsWired (const vm_page_t * page)
Defined at line 1288 of file ../../zircon/kernel/vm/page_queues.cc
bool DebugPageIsHighPriority (const vm_page_t * page)
Defined at line 1292 of file ../../zircon/kernel/vm/page_queues.cc
void DisableAging ()
Controls to enable and disable the active aging system. These must be called alternately and
not in parallel. That is, it is an error to call DisableAging twice without calling EnableAging
in between. Similar for EnableAging.
Defined at line 408 of file ../../zircon/kernel/vm/page_queues.cc
void EnableAging ()
Defined at line 440 of file ../../zircon/kernel/vm/page_queues.cc
void SetAgingEvent (Event * event)
Register an Event that will be signalled every time aging occurs. This can be used to know if
if PeekReclaim might now return items (due to aging having occurred) where it had previously
ceased.
Only a single Event may be registered at a time and the Event is assumed to live as long as the
PageQueues object. A nullptr can be passed in to unregister an Event, otherwise it is an error
to attempt to register over the top of an existing event.
Defined at line 1391 of file ../../zircon/kernel/vm/page_queues.cc
Enumerations
enum AgeReason
| Name | Value |
|---|---|
| Timeout | 0 |
| ActiveRatio | 1 |
| Manual | 2 |
Used to identify the reason that aging is triggered, mostly for debugging and informational
purposes.
Defined at line 162 of file ../../zircon/kernel/vm/include/vm/page_queues.h
enum LruAction
| Name | Value |
|---|---|
| None | 0 |
| EvictOnly | 1 |
| CompressOnly | 2 |
| EvictAndCompress | 3 |
Describes any action to take when processing the LRU queue. This is applied to pages that would
otherwise have to be moved from the old LRU queue into the isolate queue.
Defined at line 309 of file ../../zircon/kernel/vm/include/vm/page_queues.h