class Evictor

Defined at line 36 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

void Evictor ()

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

void ~Evictor ()

Defined at line 47 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 49 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 53 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 55 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 61 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 71 of file ../../zircon/kernel/vm/evictor.cc

bool IsEvictionEnabled ()

Whether any eviction can occur.

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

bool IsCompressionEnabled ()

Whether eviction should attempt to use compression.

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

EvictorStats GetGlobalStats ()

Return global eviction stats from all instantiations of the Evictor.

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

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 87 of file ../../zircon/kernel/vm/evictor.cc

void Evictor (void * ctx, TestReclaimFunction reclaim_function, TestFreePagesFunction free_pages_function)

Constructor for test code to specify custom methods to fake the reclamation.

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

EvictionTarget DebugGetEvictionTarget ()

Helpers for testing.

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

void CombineEvictionTarget (EvictionTarget target)

Combine the specified |target| with the pre-existing |eviction_target_|.

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

EvictedPageCounts EvictFromPreloadedTarget ()

Perform eviction based on the current values of |eviction_target_|. The expectation is that the

user will have set the target before calling this function with either SetEvictionTarget() or

CombineEvictionTarget(). This may acquire arbitrary vmo and aspace locks.

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

Enumerations

enum class EvictionLevel : uint8_t
Name Value
OnlyOldest 0
IncludeNewest 1

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

enum class Output : _Bool
Name Value
Print true
NoPrint false

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

enum class TriggerReason : _Bool
Name Value
OOM true
Other false

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

Records