class MappedVmo
Defined at line 25 of file ../../src/storage/lib/buffer/mapped_vmo.h
MappedVmo is a helper class that manages a VMO mapped into the process's address space.
Unlike fzl::ResizeableVmoMapper, MappedVmo creates the underlying VMO with the ZX_VMO_UNBOUNDED
flag. This allows the mapping to be resized (grown or shrunk) without needing to resize the VMO
itself.
When |Grow| or |Shrink| are called, only the VMAR mapping is modified. Shrinking the mapping also
decommits the unused pages in the VMO to free memory.
Public Methods
void MappedVmo ()
Defined at line 27 of file ../../src/storage/lib/buffer/mapped_vmo.h
void ~MappedVmo ()
Defined at line 28 of file ../../src/storage/lib/buffer/mapped_vmo.h
void MappedVmo (const MappedVmo & )
Defined at line 30 of file ../../src/storage/lib/buffer/mapped_vmo.h
MappedVmo & operator= (const MappedVmo & )
Defined at line 31 of file ../../src/storage/lib/buffer/mapped_vmo.h
void MappedVmo (MappedVmo && other)
Defined at line 38 of file ../../src/storage/lib/buffer/mapped_vmo.cc
MappedVmo & operator= (MappedVmo && other)
Defined at line 46 of file ../../src/storage/lib/buffer/mapped_vmo.cc
zx::result<> CreateAndMap (uint64_t size, std::string_view name)
Creates an unbounded VMO and maps it with the given initial size.
|size| must be greater than 0. It is rounded up to the nearest page size. |name| is an optional
name for the VMO.
Returns ZX_ERR_INVALID_ARGS if size is 0.
Returns ZX_ERR_BAD_STATE if the MappedVmo is already initialized.
Defined at line 58 of file ../../src/storage/lib/buffer/mapped_vmo.cc
size_t size ()
Defined at line 70 of file ../../src/storage/lib/buffer/mapped_vmo.h
void * start ()
Defined at line 71 of file ../../src/storage/lib/buffer/mapped_vmo.h
const void * start ()
Defined at line 72 of file ../../src/storage/lib/buffer/mapped_vmo.h
const zx::vmo & vmo ()
Defined at line 73 of file ../../src/storage/lib/buffer/mapped_vmo.h
zx::result<> Grow (size_t size)
Grows the mapping to the new |size|.
Since the underlying VMO is unbounded, this only resizes the mapping, not the VMO. The virtual
address of the mapping (|start()|) may change. Existing data is preserved.
|size| must be greater than or equal to the current size. It is rounded up to the nearest page
size.
Returns ZX_ERR_BAD_STATE if the MappedVmo is not initialized.
Returns ZX_ERR_INVALID_ARGS if |size| is less than the current size.
Defined at line 91 of file ../../src/storage/lib/buffer/mapped_vmo.cc
zx::result<> Shrink (size_t size)
Shrinks the mapping to the new |size|.
The excess mapping is unmapped and the corresponding pages in the VMO are decommitted. The
virtual address of the mapping (|start()|) does not change. Existing data in the remaining
portion is preserved.
|size| must be less than or equal to the current size, and greater than 0. It is rounded up to
the nearest page size.
Returns ZX_ERR_BAD_STATE if the MappedVmo is not initialized.
Returns ZX_ERR_INVALID_ARGS if |size| is greater than the current size, or if |size| is 0.
Defined at line 126 of file ../../src/storage/lib/buffer/mapped_vmo.cc