class PageSource

Defined at line 230 of file ../../zircon/kernel/vm/include/vm/page_source.h

Object which provides pages to a vm_object.

Public Methods

void PageSource (fbl::RefPtr<PageProvider> && page_provider)

Defined at line 33 of file ../../zircon/kernel/vm/page_source.cc

void PageSource ()

Defined at line 232 of file ../../zircon/kernel/vm/include/vm/page_source.h

zx_status_t GetPages (uint64_t offset, uint64_t len, PageRequest * req, VmoDebugInfo vmo_debug_info)

Sends a request to the backing source to provide the requested page at |offset|.

Returns ZX_ERR_NOT_FOUND if the request cannot be fulfilled.

Returns ZX_ERR_SHOULD_WAIT if the request will be asynchronously fulfilled and the caller

should wait on |req|.

Defined at line 240 of file ../../zircon/kernel/vm/include/vm/page_source.h

void FreePages (list_node * pages)

Frees |pages|.

Defined at line 348 of file ../../zircon/kernel/vm/page_source.cc

bool DebugIsPageOk (vm_page_t * page, uint64_t offset)

For asserting purposes only. This gives the PageProvider a chance to check that a page is

consistent with any rules the PageProvider has re. which pages can go where in the VmCowPages.

PhysicalPageProvider implements this to verify that page at offset makes sense with respect to

phys_base_, since VmCowPages can't do that on its own due to lack of knowledge of phys_base_

and lack of awareness of contiguous.

Defined at line 388 of file ../../zircon/kernel/vm/page_source.cc

void OnPagesSupplied (uint64_t offset, uint64_t len)

Updates the request tracking metadata to account for pages [offset, offset + len) having

been supplied to the owning vmo.

Note that the range [offset, offset + len) should not have been previously supplied. The page

request tracking in PageSource works by tracking only a fulfilled length, and not exact

fulfilled offsets, to save on memory required for metadata. So in order to prevent

over-accounting errors, the caller must ensure that they are only calling OnPagesSupplied for

newly supplied ranges.

TODO(rashaeqbal): Consider relaxing this constraint by more precise tracking of fulfilled

offsets with a bitmap. Might require capping the max permissible length of a page request.

Defined at line 93 of file ../../zircon/kernel/vm/page_source.cc

void OnPagesFailed (uint64_t offset, uint64_t len, zx_status_t error_status)

Fails outstanding page requests in the range [offset, offset + len). Events associated with the

failed page requests are signaled with the |error_status|, and any waiting threads are

unblocked.

Defined at line 222 of file ../../zircon/kernel/vm/page_source.cc

bool IsValidExternalFailureCode (zx_status_t error_status)

Returns true if |error_status| is a valid ZX_PAGER_OP_FAIL failure error code (input, specified

by user mode pager). These codes can be used with |OnPagesFailed| (and so can any failure

codes for which IsValidInternalFailureCode() returns true).

Not every error code is supported, since these errors can get returned via a zx_vmo_read() or a

zx_vmo_op_range(), if those calls resulted in a page fault. So the |error_status| should be a

supported return error code for those syscalls _and_ be an error code that we want to be

supported for the user mode pager to specify via ZX_PAGER_OP_FAIL. Currently,

IsValidExternalFailureCode(ZX_ERR_NO_MEMORY) returns false, as we don't want ZX_ERR_NO_MEMORY

to be specified via ZX_PAGER_OP_FAIL (at least so far).

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

bool IsValidInternalFailureCode (zx_status_t error_status)

Returns true if |error_status| is a valid provider failure error code, which can be used with

|OnPagesFailed|.

This returns true for every error code that IsValidExternalFailureCode() returns true for, plus

any additional error codes that are valid as an internal PageProvider status but not valid for

ZX_PAGER_OP_FAIL.

ZX_ERR_NO_MEMORY will return true, unlike IsValidExternalFailureCode(ZX_ERR_NO_MEMORY) which

returns false.

Not every error code is supported, since these errors can get returned via a zx_vmo_read() or a

zx_vmo_op_range(), if those calls resulted in a page fault. So the |error_status| should be a

supported return error code for those syscalls. An error code need not be specifiable via

ZX_PAGER_OP_FAIL for this function to return true.

Defined at line 260 of file ../../zircon/kernel/vm/page_source.cc

void OnPagesDirtied (uint64_t offset, uint64_t len)

Updates the request tracking metadata to account for pages [offset, offset + len) having

been dirtied in the owning VMO.

Note that the range [offset, offset + len) should not have been previously dirtied. The page

request tracking in PageSource works by tracking only a fulfilled length, and not exact

fulfilled offsets, to save on memory required for metadata. So in order to prevent

over-accounting errors, the caller must ensure that they are only calling OnPagesDirtied for

newly dirtied ranges.

TODO(rashaeqbal): Consider relaxing this constraint by more precise tracking of fulfilled

offsets with a bitmap. Might require capping the max permissible length of a page request.

Defined at line 98 of file ../../zircon/kernel/vm/page_source.cc

void Detach ()

Detaches the source from the VMO. All future calls into the page source will fail. All

pending read transactions are aborted. Pending flush transactions will still

be serviced.

Defined at line 45 of file ../../zircon/kernel/vm/page_source.cc

void Close ()

Closes the source. Will call Detach() if the source is not already detached. All pending

transactions will be aborted and all future calls will fail.

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

bool SupportsPageRequestType (page_request_type type)

Defined at line 300 of file ../../zircon/kernel/vm/include/vm/page_source.h

bool ShouldTrapDirtyTransitions ()

Whether transitions from clean to dirty should be trapped.

Defined at line 305 of file ../../zircon/kernel/vm/include/vm/page_source.h

zx_status_t RequestDirtyTransition (PageRequest * request, uint64_t offset, uint64_t len, VmoDebugInfo vmo_debug_info)

Request the page provider for clean pages in the range [offset, offset + len) to become dirty,

in order for a write to proceed. Returns ZX_ERR_SHOULD_WAIT if the request will be

asynchronously fulfilled; the caller should wait on |request|. Depending on the state of pages

in the range, the |request| might be generated for a range that is a subset of

[offset, offset + len).

Defined at line 314 of file ../../zircon/kernel/vm/include/vm/page_source.h

PageSourceProperties properties ()

The returned properties can assumed to be const and never change. As such the caller may cache

them.

Defined at line 342 of file ../../zircon/kernel/vm/include/vm/page_source.h

bool is_detached ()

Defined at line 351 of file ../../zircon/kernel/vm/include/vm/page_source.h

Lock<Mutex> * paged_vmo_lock ()

Method for the VmCowPages to retrieve the lock for paged VMOs.

See VmCowPages::DeferredOps.

Defined at line 358 of file ../../zircon/kernel/vm/include/vm/page_source.h

ktl::optional<zx_koid_t> GetProviderKoid ()

Retrieves any koid for the linked page provider.

Defined at line 361 of file ../../zircon/kernel/vm/include/vm/page_source.h

void Dump (uint depth, uint32_t max_items)

Prints state of the page source and any pending requests. The maximum number of requests

printed is capped by |max_items|.

Defined at line 546 of file ../../zircon/kernel/vm/page_source.cc

void DumpSelf (uint depth, uint32_t max_items)

Similar to Dump, but only dumps information about this exact object, and will not forward the

Dump request to the related PageProvider.

Defined at line 529 of file ../../zircon/kernel/vm/page_source.cc

Protected Methods

void ~PageSource ()

destructor should only be invoked from RefPtr

Defined at line 39 of file ../../zircon/kernel/vm/page_source.cc

Friends

class RefPtr