class VmCompression
Defined at line 135 of file ../../zircon/kernel/vm/include/vm/compression.h
Top level container for performing compression and is responsible for coordinating between the
provided storage and compression strategies. Each `VmCompression` instance has its own
`CompressedRef` namespace, and references are not transferable. Aside from testing it is expected
that there be a single global instance.
This also manages the `VmCompressor` instances that provide the state machine for a VMO to do
compression. Currently only a single instance is supported limiting to one simultaneous
compression.
Public Members
static const size_t kNumLogBuckets
Public Methods
void VmCompression (fbl::RefPtr<VmCompressedStorage> storage, fbl::RefPtr<VmCompressionStrategy> strategy, size_t compression_threshold)
Constructs a compression manager using the given storage and compression strategies. The
|compression_threshold| is the number of bytes above which a compression is considered to have
failed and should not be considered worth storing.
TODO(https://fxbug.dev/42138396): Limit total amount of pages stored.
Defined at line 53 of file ../../zircon/kernel/vm/compression.cc
void ~VmCompression ()
Defined at line 68 of file ../../zircon/kernel/vm/compression.cc
fbl::RefPtr<VmCompression> CreateDefault ()
Construct a VmCompression instance using default options for the storage and compression
strategies.
Defined at line 236 of file ../../zircon/kernel/vm/compression.cc
CompressResult Compress (const void * page_src, zx_instant_mono_ticks_t now)
Defined at line 74 of file ../../zircon/kernel/vm/compression.cc
void Decompress (CompressedRef ref, void * page_dest, uint32_t * metadata_dest, zx_instant_mono_ticks_t now)
Decompresses and frees the provided reference into |page_dest| and |metadata_dest|. This cannot
fail and always produces kPageSize worth of data. After calling this the reference is no longer
valid.
The |now| parameter is compared with the value given in |Compress| to determine how long this
page was store for.
Note that the temporary reference may be passed into here, however the same locking
requirements as |MoveReference| must be observed.
Defined at line 139 of file ../../zircon/kernel/vm/compression.cc
CompressResult Compress (const void * page_src)
Wrapper that passes current_mono_ticks() as |now|
Defined at line 166 of file ../../zircon/kernel/vm/include/vm/compression.h
void Free (CompressedRef ref)
Free the compressed reference without decompressing it.
Note that the temporary reference may be passed into here, however the same locking
requirements as |MoveReference| must be observed.
Defined at line 175 of file ../../zircon/kernel/vm/compression.cc
void Decompress (CompressedRef ref, void * page_dest, uint32_t * metadata_dest)
Wrapper that passes current_mono_ticks() as |now|
Defined at line 181 of file ../../zircon/kernel/vm/include/vm/compression.h
uint32_t GetMetadata (CompressedRef ref)
Metadata manipulations need to disable analysis. The caller is required to hold the lock for the
VMO who created the reference, but we can't refer to that lock here.
Defined at line 186 of file ../../zircon/kernel/vm/compression.cc
void SetMetadata (CompressedRef ref, uint32_t metadata)
Metadata manipulations need to disable analysis. The caller is required to hold the lock for the
VMO who created the reference, but we can't refer to that lock here.
Defined at line 195 of file ../../zircon/kernel/vm/compression.cc
CompressorGuard AcquireCompressor ()
Retrieve a reference to a VmCompressor, wrapped in the RAII CompressorGuard. Once the
compressor is finished with it can be destroyed, which will release it for re-use.
This method may block until a compressor becomes available and callers should be prepared for
extended wait times.
The returned CompressorGuard must not outlive this object.
Defined at line 48 of file ../../zircon/kernel/vm/compression.cc
ktl::optional<PageAndMetadata> MoveReference (CompressedRef ref)
Defined at line 204 of file ../../zircon/kernel/vm/include/vm/compression.h
bool IsTempReference (const CompressedRef & ref)
Returns whether or not the provided reference is a temporary reference.
See |VmCompressor| for a full explanation of temporary references.
Defined at line 214 of file ../../zircon/kernel/vm/include/vm/compression.h
void Dump ()
Perform an information dump of the internal state to the debuglog.
Defined at line 218 of file ../../zircon/kernel/vm/compression.cc
Stats GetStats ()
Defined at line 203 of file ../../zircon/kernel/vm/compression.cc