class LookupCursor
Defined at line 1733 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
Implements a cursor that allows for retrieving successive pages over a range in a VMO. The
range that is iterated is determined at construction from GetLookupCursorLocked and cannot be
modified, although it can be effectively shrunk by ceasing queries early.
The cursor is designed under the assumption that the caller is tracking, implicitly or
explicitly, how many queries have been done, and the methods do not return errors if more slots
are queried than was originally requested in the range. They will, however, assert and panic.
There are three controls provided by this object.
Zero forks: By default new zero pages will be considered zero forks and added to the zero page
scanner list, this can be disabled with |DisableZeroFork|.
Access time: By default pages that are returned will be considered accessed. This can be
changed with |DisableMarkAccessed|.
Allocation lists: By default pages will be acquired from the pmm as needed. An allocation list
can be given use |GiveAllocList|.
The VMO lock *must* be held contiguously from the call to GetLookupCursorLocked over the entire
usage of this object. Callers can assume that for any vm_page_t* that is returned that the lock
of the owner of that page is held up until the next operation performed on the cursor.
Public Methods
void ~LookupCursor ()
Defined at line 1735 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
zx::result<RequireResult> RequirePage (bool will_write, uint max_request_pages, DeferredOps & deferred, MultiPageRequest * page_request)
Returned page will be readable or writable based on the |will_write| flag.
Defined at line 1774 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
void GiveAllocList (list_node_t * alloc_list)
Provides a list of pages that can be used to service any allocations. This is useful if you
know you will be looking up multiple absent pages and want to avoid repeatedly hitting the pmm
for single pages.
If a list is provided then ClearAllocList must be called prior to the cursor being destroyed.
Defined at line 1813 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
void ClearAllocList ()
Clears any remaining allocation list. This does not free any remaining pages, and it is the
callers responsibility to check the list and free any pages.
Defined at line 1820 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
void DisableZeroFork ()
Disables placing newly allocated zero pages in the zero fork list.
Defined at line 1826 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
void DisableMarkAccessed ()
Indicates that any existing pages that are returned should not be considered accessed and have
their accessed times updated.
Defined at line 1830 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
Lock<CriticalMutex> * lock ()
Exposed for lock assertions.
Defined at line 1833 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
Lock<CriticalMutex> & lock_ref ()
Defined at line 1834 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
void LookupCursor (LookupCursor & other)
Defined at line 1838 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
void LookupCursor (LookupCursor && other)
Defined at line 1839 of file ../../zircon/kernel/vm/include/vm/vm_cow_pages.h
zx::result<RequireResult> RequireOwnedPage (bool will_write, uint max_request_pages, DeferredOps & deferred, MultiPageRequest * page_request)
Returned page must be an allocated and owned page in this VMO. As such this will never return a
reference to the zero page. |will_write| indicates if this page needs to be writable or not,
which for an owned and allocated page just involves a potential dirty request / transition.
Defined at line 3543 of file ../../zircon/kernel/vm/vm_cow_pages.cc
zx::result<RequireResult> RequireReadPage (uint max_request_pages, DeferredOps & deferred, MultiPageRequest * page_request)
Returned page will only be read from. This can return zero pages or pages from a parent VMO.
A DeferredOps is required to be passed in, even though a Read does not ever directly generate
any deferred actions, to enforce the requirement that all operations on a pager backed VMO are
serialized with the paged_vmo_lock. Having to present a DeferredOps here is a simple way to
ensure this lock is held.
Defined at line 3665 of file ../../zircon/kernel/vm/vm_cow_pages.cc
uint IfExistPages (bool will_write, uint max_pages, paddr_t * paddrs)
Walks up to |max_pages| from the current offset, filling in |paddrs| as long as there are
actual pages and, if |will_write| is true, that they can be written to. The return value is
the number of contiguous pages found and filled into |paddrs|, and the cursor is incremented
by that many pages.
Defined at line 3504 of file ../../zircon/kernel/vm/vm_cow_pages.cc
vm_page_t * MaybePage (bool will_write)
Checks the current slot for a page and returns it. This does not return zero pages and, due to
the lack of taking a page request, will not perform copy-on-write allocations or dirty
transitions. In these cases it will return nullptr even though there is content.
The internal cursor is always incremented regardless of the return value.
Defined at line 3451 of file ../../zircon/kernel/vm/vm_cow_pages.cc
uint64_t SkipMissingPages ()
Has similar properties of |MaybePage|, except it returns how many times in a row |MaybePage|
would have returned a nullptr. Regardless of the return value of this method, it is not
guaranteed that the next call to |MaybePage| will not be a nullptr. The cursor is incremented
by the number of pages returned.
Defined at line 3467 of file ../../zircon/kernel/vm/vm_cow_pages.cc
Records
Friends
class VmCowPages