class Evictor

Defined at line 35 of file ../../zircon/kernel/vm/include/vm/evictor.h

Implements page evictor logic to free pages belonging to a PmmNode under memory pressure.

Eviction in this context is both direct eviction of pager backed memory and discardable VMO

memory, as well as by performing compression.

This class is thread-safe.

Public Methods

Thread * DebugGetEvictorThread ()

Debug method to retrieve any current eviction thread. Only to be used for testing / debugging

purposes. It is up to the caller to know if this objects is alive or not.

Defined at line 165 of file ../../zircon/kernel/vm/include/vm/evictor.h

void Evictor ()

Defined at line 246 of file ../../zircon/kernel/vm/evictor.cc

void ~Evictor ()

Defined at line 252 of file ../../zircon/kernel/vm/evictor.cc

void EnableEviction (bool use_compression)

Called from the scanner to enable eviction if required. Creates an eviction thread to process

asynchronous eviction requests.

By default this only enables user pager based eviction and |use_compression| can be used to

also perform compression.

Defined at line 264 of file ../../zircon/kernel/vm/evictor.cc

void DisableEviction ()

Called from the scanner to disable all eviction if needed, will shut down any in existing

eviction thread. It is a responsibility of the scanner to not have multiple concurrent calls

to this and EnableEviction.

Defined at line 287 of file ../../zircon/kernel/vm/evictor.cc

EvictionResult EvictFromExternalTarget (EvictionTarget target)

Evict from a user specified external |target| which is only used for this eviction attempt and

does not interfere with the |eviction_target_|.

Defined at line 332 of file ../../zircon/kernel/vm/evictor.cc

EvictionResult EvictSynchronous (uint64_t min_mem_to_free, uint64_t free_mem_target, EvictionLevel eviction_level, Output output, TriggerReason reason)

Performs a synchronous request to evict until free memory equals |free_mem_start| (in bytes)

and at least |min_mem_to_free| (in bytes) has been reclaimed. The return value is an

EvictionResult detailing exactly what was evicted and whether the free_mem_target was achieved.

The |eviction_level| is a rough control that maps to how old a page needs to be for being

considered for eviction. This may acquire arbitrary vmo and aspace locks.

Defined at line 409 of file ../../zircon/kernel/vm/evictor.cc

void EvictAsynchronous (uint64_t min_mem_to_free, uint64_t free_mem_target, EvictionLevel eviction_level, Output output)

Reclaim memory until free memory equals the |free_mem_target| (in bytes) and at least

|min_mem_to_free| (in bytes) has been reclaimed. Reclamation will happen asynchronously on the

eviction thread and this function returns immediately. Once the target is reached, or there is

no more memory that can be reclaimed, this process will stop and the free memory target will be

cleared. The |eviction_level| is a rough control on how hard to try and evict. Multiple calls

to EvictAsynchronous will cause all the targets to get merged by adding together

|min_mem_to_free|, taking the max of |free_mem_target| and the highest or most aggressive of

any |eviction_level|.

Defined at line 429 of file ../../zircon/kernel/vm/evictor.cc

bool IsEvictionEnabled ()

Whether any eviction can occur.

Defined at line 254 of file ../../zircon/kernel/vm/evictor.cc

bool IsCompressionEnabled ()

Whether eviction should attempt to use compression.

Defined at line 259 of file ../../zircon/kernel/vm/evictor.cc

EvictorStats GetGlobalStats ()

Return global eviction stats from all instantiations of the Evictor.

Defined at line 235 of file ../../zircon/kernel/vm/evictor.cc

Enumerations

enum EvictionLevel
Name Value
OnlyOldest 0
IncludeNewest 1

Defined at line 37 of file ../../zircon/kernel/vm/include/vm/evictor.h

enum Output
Name Value
Print true
NoPrint false

Defined at line 42 of file ../../zircon/kernel/vm/include/vm/evictor.h

enum TriggerReason
Name Value
OOM true
Other false

Defined at line 47 of file ../../zircon/kernel/vm/include/vm/evictor.h

Records

Friends

class TestPmmNode