class PriorityChanger

Defined at line 2190 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h

PriorityChanger is a transaction object for changing the high priority count of VmCowPages

objects. The high priority count is used to manage page reclamation. This object ensures that a

DeferredOps object is created against the correct VmCowPages, which might be an ancestor of

|target_|. PriorityChanger does the following:

* Manages the lifetime of VmCowPages to ensure they last until the

priority change operation, by holding a RefPtr.

* Handles the construction of the DeferredOps object.

* Clarifies which operations need to be done within the VmCowPages lock and which need to happen

without the lock being held.

* Presents a high-level API to VmMapping and VmObjectPaged.

* Handles traversing up the VmCowPages hierarchy to ensure that high priority status is

propagated.

Callers should prefer |VmMapping::SetMemoryPriorityLocked|,

|VmMapping::SetMemoryPriorityDefaultLockedObject|, or

|VmMapping::SetMemoryPriorityHighAlreadyPositiveLockedObject|, if applicable.

To change the high priority count of a VmCowPages, you should first construct the PriorityChanger

object. Then,

* If |delta|

<

0, you must immediately call one of the Change* methods, which change the high

priority count of |target|.

* If |delta| > 0, you must call an applicable Prepare* method to set up the prerequisites for the

priority change operation, then call one of the Change* methods.

This class is not thread-safe.

Public Methods

void ~PriorityChanger ()

Defined at line 2201 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h

void PriorityChanger (const PriorityChanger & )

Defined at line 2206 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h

void PriorityChanger (PriorityChanger && )

Defined at line 2206 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h

PriorityChanger & operator= (const PriorityChanger & )

Defined at line 2206 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h

PriorityChanger & operator= (PriorityChanger && )

Defined at line 2206 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h

Lock<CriticalMutex> * lock ()

Defined at line 2208 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h

Lock<CriticalMutex> & lock_ref ()

Defined at line 2209 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h

void PriorityChanger (int64_t delta, VmCowPages * target)

Construct a priority changer for target. When delta is positive, we go towards high priority.

When it's negative, we move towards default priority.

Defined at line 4846 of file ../../zircon/kernel/vm/vm_cow_pages.cc

void PrepareHasNoLoanedPagesLocked ()

This method may be called if |target|'s root page source has no loaned pages. Prefer other

Prepare* methods as this is typically hard to reason about.

If you call this method, please leave a comment explaining how you know there are no loaned

pages in the current VmObject hierarchy.

This method must be called with |target|'s lock held.

Defined at line 4858 of file ../../zircon/kernel/vm/vm_cow_pages.cc

void PrepareIsAlreadyHighPriorityLocked ()

This method may be called if |target| already has a |high_priority_count_| > 0.

This method must be called with |target|'s lock held.

Defined at line 4867 of file ../../zircon/kernel/vm/vm_cow_pages.cc

void PrepareMayNotAlreadyBeHighPriority ()

This method must be called *without* holding |target|'s VmCowPages lock. In addition, the

caller must not hold a PriorityChanger or DeferredOps on any other VmCowPages in |target|'s

hierarchy.

Defined at line 4875 of file ../../zircon/kernel/vm/vm_cow_pages.cc

void ChangeHighPriorityCountLocked ()

Increments or decrements the priority count of this VMO. The high priority count is used to

control any page reclamation, and applies to the whole VMO, including its parents. The count is

never allowed to go negative and so callers must only subtract what they have already added.

Further, callers are required to remove any additions before the VMO is destroyed.

Defined at line 4980 of file ../../zircon/kernel/vm/vm_cow_pages.cc

void ChangeSingleHighPriorityCountLocked ()

Internal (to VmCowPages) helper for modifying just this value of high_priority_count_ without

performing any propagating.

Defined at line 4973 of file ../../zircon/kernel/vm/vm_cow_pages.cc