Documentation
¶
Overview ¶
Package zirconvm is a Go port of the page layer of Zircon's VM, which is replacing the pager's own (plans/zircon-pager-port-2026-10-05.md). It copies Zircon's structure, functions and logic. It keeps Zircon's byte offsets, with the pager's page size, 4 KiB or 2 MiB, in place of Zircon's constant kPageSize. Where it departs from Zircon, a comment beside the line says why.
Zircon's walks return zx_status_t from their callbacks: ZX_ERR_NEXT to go on, ZX_ERR_STOP to end the walk without failing it, and any other status to fail it. Here a callback returns nil to go on, ErrStop to stop, and any other error to fail the walk.
Zircon checks its invariants with DEBUG_ASSERT and ASSERT. Both panic here, in every build.
Index ¶
- Constants
- Variables
- func IsValidExternalFailureCode(status error) bool
- func IsValidInternalFailureCode(status error) bool
- func RequestLen(request *PageRequest) uint64
- func RequestOffset(request *PageRequest) uint64
- type ActiveInactiveCounts
- type AgeReason
- type AttributionCounts
- type BatchInserter
- type CanOverwriteSlot
- type CompressKind
- type CompressResult
- type CompressedStorage
- type Compression
- func (c *Compression) AcquireCompressor() CompressorGuard
- func (c *Compression) Compress(ctx context.Context, src []byte) CompressResult
- func (c *Compression) Decompress(ctx context.Context, ref ReferenceValue, dst []byte) (uint32, error)
- func (c *Compression) DecompressReserved(ctx context.Context, ref ReferenceValue, dst []byte) (uint32, ReferenceValue, error)
- func (c *Compression) Free(ref ReferenceValue)
- func (c *Compression) GetMetadata(ref ReferenceValue) uint32
- func (c *Compression) GetStats() CompressionStats
- func (c *Compression) IsTempReference(ref ReferenceValue) bool
- func (c *Compression) MoveReference(ref ReferenceValue) (PageAndMetadata, bool)
- func (c *Compression) Reserve() (ReferenceValue, bool)
- func (c *Compression) SetMetadata(ref ReferenceValue, metadata uint32)
- type CompressionStats
- type CompressionStrategy
- type Compressor
- func (c *Compressor) Arm() error
- func (c *Compressor) Compress(ctx context.Context)
- func (c *Compressor) Finalize()
- func (c *Compressor) Free(ref ReferenceValue)
- func (c *Compressor) IsIdle() bool
- func (c *Compressor) IsTempReference(ref ReferenceValue) bool
- func (c *Compressor) IsTempReferenceInUse() bool
- func (c *Compressor) ReturnTempReference(ref ReferenceValue)
- func (c *Compressor) Start(src PageAndMetadata) ReferenceValue
- func (c *Compressor) TakeCompressionResult() CompressResult
- type CompressorGuard
- type Counts
- type CowPages
- func (c *CowPages) AddNewPageLocked(offset uint64, page *VmPage, overwrite CanOverwriteSlot, zero bool, ...) (PageOrMarker[VmPage], error)
- func (c *CowPages) AddNewPagesLocked(startOffset uint64, pages []*VmPage, overwrite CanOverwriteSlot, zero bool, ...) error
- func (c *CowPages) CanEvict() bool
- func (c *CowPages) CommitRangeLocked(ctx context.Context, r CowRange, deferred *DeferredOps, ...) (uint64, error)
- func (c *CowPages) CreateCloneLocked(typ SnapshotType, requireUnidirectional bool, r CowRange) (*CowPages, error)
- func (c *CowPages) DebugGetPage(offset uint64) *VmPage
- func (c *CowPages) DebugGetPageCountLocked() uint64
- func (c *CowPages) DebugGetPageLocked(offset uint64) *VmPage
- func (c *CowPages) DebugGetParent() *CowPages
- func (c *CowPages) DebugGetPopulatedSlotsCount() int64
- func (c *CowPages) DebugIsEmpty(offset uint64) bool
- func (c *CowPages) DebugIsMarker(offset uint64) bool
- func (c *CowPages) DebugIsPage(offset uint64) bool
- func (c *CowPages) DebugIsReference(offset uint64) bool
- func (c *CowPages) DebugLookupDepthLocked() int
- func (c *CowPages) DebugLookupReadable(r CowRange, fn func(offset uint64, page *VmPage) error) error
- func (c *CowPages) DebugValidateContinuousAttribution() bool
- func (c *CowPages) DecommitRange(r CowRange) error
- func (c *CowPages) DecompressInRange(ctx context.Context, r CowRange) error
- func (c *CowPages) DedupZeroPage(page *VmPage, offset uint64) bool
- func (c *CowPages) DetachSource()
- func (c *CowPages) DirtyPages(ctx context.Context, r CowRange, allocList *[]*VmPage) error
- func (c *CowPages) EnumerateDirtyRangesLocked(r CowRange, fn func(offset, length uint64, isZero bool) error) error
- func (c *CowPages) FailPageRequestsLocked(r CowRange, status error) error
- func (c *CowPages) GetAttributedMemoryInRangeLocked(r CowRange) AttributionCounts
- func (c *CowPages) GetLookupCursorLocked(r CowRange) (*LookupCursor, error)
- func (c *CowPages) HeapAllocationBytesLocked() uint64
- func (c *CowPages) HeldPageLocked(offset uint64) *VmPage
- func (c *CowPages) Lock() *sync.Mutex
- func (c *CowPages) LookupLocked(r CowRange, fn func(offset uint64, page *VmPage) error) error
- func (c *CowPages) LookupReadableLocked(r CowRange, fn func(offset uint64, page *VmPage) error) error
- func (c *CowPages) MaybeDeadTransition() *CowPages
- func (c *CowPages) PageLocked(offset uint64) *VmPage
- func (c *CowPages) PageSize() uint64
- func (c *CowPages) PageWouldReadZeroLocked(pageOffset uint64) bool
- func (c *CowPages) ProcessPagesForSupply(ctx context.Context, pages *PageSpliceList[VmPage]) error
- func (c *CowPages) PromoteRangeForReclamation(r CowRange) error
- func (c *CowPages) ProtectRangeFromReclamation(ctx context.Context, r CowRange, setAlwaysNeed, ignoreErrors bool) error
- func (c *CowPages) QueryPagerVmoStatsLocked(reset bool) (bool, error)
- func (c *CowPages) RangeChangeUpdateLocked(r CowRange, op RangeChangeOp, deferred *DeferredOps)
- func (c *CowPages) ReadWritebackLocked(ctx context.Context, offset uint64, buf []byte) error
- func (c *CowPages) ReclaimPage(ctx context.Context, page *VmPage, offset uint64, action EvictionAction, ...) (ReclaimSuccess, ReclaimFailure)
- func (c *CowPages) ReclaimRangeForEviction(offset, length uint64, action EvictionAction) (ReclaimSuccess, ReclaimFailure)
- func (c *CowPages) ReclamationEventCountLocked() uint64
- func (c *CowPages) RemovePageLocked(offset uint64, page *VmPage) bool
- func (c *CowPages) SizeLocked() uint64
- func (c *CowPages) SupplyPagesLocked(r CowRange, pages *PageSpliceList[VmPage], options SupplyOptions, ...) error
- func (c *CowPages) TakePages(ctx context.Context, r CowRange, spliceOffset uint64, ...) (uint64, error)
- func (c *CowPages) TransitionToAliveLocked()
- func (c *CowPages) WritebackAbandonLocked(ctx context.Context, r CowRange, deferred *DeferredOps) error
- func (c *CowPages) WritebackBeginLocked(r CowRange, isZeroRange bool) error
- func (c *CowPages) WritebackEndLocked(r CowRange) error
- func (c *CowPages) WritebackProtectLocked(r CowRange) error
- func (c *CowPages) ZeroPagesLocked(ctx context.Context, r CowRange, dirtyTrack bool, deferred *DeferredOps, ...) (uint64, error)
- type CowRange
- type Cursor
- type DeferredOps
- type DirtyState
- type Event
- type EvictedPageCounts
- type EvictionAction
- type EvictionHint
- type EvictionLevel
- type EvictionResult
- type EvictionTarget
- type Evictor
- func (e *Evictor[R]) DisableEviction()
- func (e *Evictor[R]) EnableEviction(useCompression bool)
- func (e *Evictor[R]) EvictAsynchronous(ctx context.Context, minMemToFree, freeMemTarget uint64, level EvictionLevel, ...)
- func (e *Evictor[R]) EvictFromExternalTarget(ctx context.Context, request R, target EvictionTarget) (EvictionResult, error)
- func (e *Evictor[R]) EvictSynchronous(ctx context.Context, request R, minMemToFree, freeMemTarget uint64, ...) (EvictionResult, error)
- func (e *Evictor[R]) IsCompressionEnabled() bool
- func (e *Evictor[R]) IsEvictionEnabled() bool
- func (e *Evictor[R]) Stats() EvictorStats
- type EvictorStats
- type FreePagesFunction
- type Freer
- type IntervalDirtyState
- type IntervalHandling
- type IntervalType
- type LookupCursor
- func (lc *LookupCursor) ClearAllocList()
- func (lc *LookupCursor) DisableMarkAccessed()
- func (lc *LookupCursor) DisableZeroFork()
- func (lc *LookupCursor) GiveAllocList(list *[]*VmPage)
- func (lc *LookupCursor) IfExistPages(willWrite bool, maxPages uint64, pages []*VmPage) uint64
- func (lc *LookupCursor) MaybePage(willWrite bool) *VmPage
- func (lc *LookupCursor) Release()
- func (lc *LookupCursor) RequireOwnedPage(ctx context.Context, willWrite bool, maxRequestPages uint64, ...) (RequireResult, error)
- func (lc *LookupCursor) RequirePage(ctx context.Context, willWrite bool, maxRequestPages uint64, ...) (RequireResult, error)
- func (lc *LookupCursor) RequireReadPage(ctx context.Context, maxRequestPages uint64, deferred *DeferredOps, ...) (RequireResult, error)
- func (lc *LookupCursor) SkipMissingPages() uint64
- type Mapping
- type MultiPageRequest
- type Node
- type ObjectPaged
- func CreateExternal(node *Node, src *PageSource, size uint64) (*ObjectPaged, error)
- func CreateIdentityRoot(node *Node, src *PageSource, size uint64) (*ObjectPaged, error)
- func CreateObjectPaged(node *Node, size uint64) (*ObjectPaged, error)
- func CreateRegionLayer(node *Node, src *PageSource, size uint64, roots RootResolver) (*ObjectPaged, error)
- func (o *ObjectPaged) AddMapping(m Mapping)
- func (o *ObjectPaged) CommitRange(ctx context.Context, offset, length uint64) error
- func (o *ObjectPaged) CowPages() *CowPages
- func (o *ObjectPaged) CreateClone(typ SnapshotType, offset, size uint64) (*ObjectPaged, error)
- func (o *ObjectPaged) DebugGetCowPages() *CowPages
- func (o *ObjectPaged) DebugGetPage(offset uint64) *VmPage
- func (o *ObjectPaged) DecommitRange(offset, length uint64) error
- func (o *ObjectPaged) Destroy()
- func (o *ObjectPaged) DetachSource()
- func (o *ObjectPaged) DirtyPages(ctx context.Context, offset, length uint64) error
- func (o *ObjectPaged) EnumerateDirtyRanges(offset, length uint64, fn func(offset, length uint64, isZero bool) error) error
- func (o *ObjectPaged) FailPageRequests(offset, length uint64, status error) error
- func (o *ObjectPaged) GetAttributedMemory() AttributionCounts
- func (o *ObjectPaged) GetAttributedMemoryInRange(offset, length uint64) AttributionCounts
- func (o *ObjectPaged) GetPage(ctx context.Context, offset uint64, pfFlags uint, ...) (*VmPage, error)
- func (o *ObjectPaged) GetPageBlocking(ctx context.Context, offset uint64, pfFlags uint) (*VmPage, error)
- func (o *ObjectPaged) HintRange(ctx context.Context, offset, length uint64, hint EvictionHint) error
- func (o *ObjectPaged) IsResizable() bool
- func (o *ObjectPaged) Lookup(offset, length uint64, fn func(offset uint64, page *VmPage) error) error
- func (o *ObjectPaged) LookupContiguous(offset, length uint64) (*VmPage, error)
- func (o *ObjectPaged) PrefetchRange(ctx context.Context, offset, length uint64) error
- func (o *ObjectPaged) QueryPagerVmoStats(reset bool) (bool, error)
- func (o *ObjectPaged) RangeChangeUpdate(r CowRange, op RangeChangeOp)
- func (o *ObjectPaged) Read(ctx context.Context, buf []byte, offset uint64) error
- func (o *ObjectPaged) ReadWriteback(ctx context.Context, buf []byte, offset uint64) error
- func (o *ObjectPaged) ReclamationEventCount() uint64
- func (o *ObjectPaged) RemoveMapping(m Mapping)
- func (o *ObjectPaged) RemovePage(offset uint64, page *VmPage) bool
- func (o *ObjectPaged) Size() uint64
- func (o *ObjectPaged) SplitAwaitingClean(offset uint64, copied *VmPage) error
- func (o *ObjectPaged) SupplyPages(ctx context.Context, offset, length uint64, pages *PageSpliceList[VmPage], ...) error
- func (o *ObjectPaged) TakePages(ctx context.Context, offset, length uint64, pages *PageSpliceList[VmPage]) error
- func (o *ObjectPaged) Write(ctx context.Context, buf []byte, offset uint64) error
- func (o *ObjectPaged) WritebackAbandon(ctx context.Context, offset, length uint64) error
- func (o *ObjectPaged) WritebackBegin(offset, length uint64, isZeroRange bool) error
- func (o *ObjectPaged) WritebackEnd(offset, length uint64) error
- func (o *ObjectPaged) WritebackProtect(offset, length uint64) error
- func (o *ObjectPaged) ZeroRange(ctx context.Context, offset, length uint64) error
- func (o *ObjectPaged) ZeroRangeUntracked(ctx context.Context, offset, length uint64) error
- type Output
- type PageAndMetadata
- type PageList
- func (pl *PageList[P]) AddZeroInterval(start, end uint64, state IntervalDirtyState) error
- func (pl *PageList[P]) AnyOwnedPagesOrIntervalsInRange(start, end uint64) bool
- func (pl *PageList[P]) AnyPagesOrIntervalsInRange(start, end uint64) bool
- func (pl *PageList[P]) Clear()
- func (pl *PageList[P]) ClipIntervalEnd(intervalEnd, length uint64) error
- func (pl *PageList[P]) ClipIntervalStart(intervalStart, length uint64) error
- func (pl *PageList[P]) ForEveryPage(fn func(p *PageOrMarker[P], offset uint64) error) error
- func (pl *PageList[P]) ForEveryPageAndContiguousRunInRange(compare func(p *PageOrMarker[P], offset uint64) bool, ...) error
- func (pl *PageList[P]) ForEveryPageAndGapInRange(pageFn func(p *PageOrMarker[P], offset uint64) error, ...) error
- func (pl *PageList[P]) ForEveryPageAndGapInRangeMutable(pageFn func(p PageOrMarkerRef[P], offset uint64) error, ...) error
- func (pl *PageList[P]) ForEveryPageInCursorRange(fn func(p *PageOrMarker[P], offset uint64) error, cursor Cursor[P], end uint64) error
- func (pl *PageList[P]) ForEveryPageInRange(fn func(p *PageOrMarker[P], offset uint64) error, start, end uint64) error
- func (pl *PageList[P]) ForEveryPageInRangeMutable(fn func(p PageOrMarkerRef[P], offset uint64) error, start, end uint64) error
- func (pl *PageList[P]) ForEveryPageMutable(fn func(p PageOrMarkerRef[P], offset uint64) error) error
- func (pl *PageList[P]) HasNoPageOrRef() bool
- func (pl *PageList[P]) HasNoPageRefOrMarker() bool
- func (pl *PageList[P]) HeapAllocationBytes() uint64
- func (pl *PageList[P]) IsEmpty() bool
- func (pl *PageList[P]) IsOffsetInZeroInterval(offset uint64) bool
- func (pl *PageList[P]) Lookup(offset uint64) *PageOrMarker[P]
- func (pl *PageList[P]) LookupMutable(offset uint64) PageOrMarkerRef[P]
- func (pl *PageList[P]) LookupMutableCursor(offset uint64) Cursor[P]
- func (pl *PageList[P]) LookupNearestMutableCursor(offset uint64) Cursor[P]
- func (pl *PageList[P]) LookupOrAllocate(offset uint64, handling IntervalHandling) (*PageOrMarker[P], bool)
- func (pl *PageList[P]) MaxSize() uint64
- func (pl *PageList[P]) MergeRangeOnto(migrate func(src, dst *PageOrMarker[P], otherOffset uint64), ...)
- func (pl *PageList[P]) NewBatchInserter() *BatchInserter[P]
- func (pl *PageList[P]) OverwriteZeroInterval(oldStartOffset, oldEndOffset, newStartOffset, newEndOffset uint64, ...) error
- func (pl *PageList[P]) PageSize() uint64
- func (pl *PageList[P]) PopulateSlotsInInterval(start, end uint64) error
- func (pl *PageList[P]) RemoveAllContent(free func(content PageOrMarker[P]))
- func (pl *PageList[P]) RemoveContent(offset uint64) PageOrMarker[P]
- func (pl *PageList[P]) RemovePages(fn func(p *PageOrMarker[P], offset uint64) error, start, end uint64) error
- func (pl *PageList[P]) RemovePagesAndIterateGaps(pageFn func(p *PageOrMarker[P], offset uint64) error, ...) error
- func (pl *PageList[P]) ReplacePageWithZeroInterval(offset uint64, state IntervalDirtyState) *P
- func (pl *PageList[P]) ReturnEmptySlot(offset uint64)
- func (pl *PageList[P]) ReturnIntervalSlot(offset uint64)
- type PageOrMarker
- func (s *PageOrMarker[P]) DecrementMarkerShareCount()
- func (s PageOrMarker[P]) GetMarkerShareCount() uint32
- func (s PageOrMarker[P]) GetZeroIntervalAwaitingCleanLength() uint64
- func (s PageOrMarker[P]) GetZeroIntervalDirtyState() IntervalDirtyState
- func (s *PageOrMarker[P]) IncrementMarkerShareCount()
- func (s PageOrMarker[P]) IsEmpty() bool
- func (s PageOrMarker[P]) IsInterval() bool
- func (s PageOrMarker[P]) IsIntervalEnd() bool
- func (s PageOrMarker[P]) IsIntervalSlot() bool
- func (s PageOrMarker[P]) IsIntervalStart() bool
- func (s PageOrMarker[P]) IsIntervalZero() bool
- func (s PageOrMarker[P]) IsMarker() bool
- func (s PageOrMarker[P]) IsPage() bool
- func (s PageOrMarker[P]) IsPageOrRef() bool
- func (s PageOrMarker[P]) IsParentContent() bool
- func (s PageOrMarker[P]) IsReference() bool
- func (s PageOrMarker[P]) IsZeroIntervalClean() bool
- func (s PageOrMarker[P]) IsZeroIntervalDirty() bool
- func (s PageOrMarker[P]) IsZeroIntervalUntracked() bool
- func (s PageOrMarker[P]) Page() *P
- func (s PageOrMarker[P]) Reference() ReferenceValue
- func (s *PageOrMarker[P]) ReleasePage() *P
- func (s *PageOrMarker[P]) ReleaseReference() ReferenceValue
- func (s *PageOrMarker[P]) Set(content PageOrMarker[P])
- func (s *PageOrMarker[P]) SetMarkerShareCount(shareCount uint32)
- func (s *PageOrMarker[P]) SetZeroIntervalAwaitingCleanLength(length uint64)
- func (s *PageOrMarker[P]) Swap(other PageOrMarker[P]) PageOrMarker[P]
- func (s *PageOrMarker[P]) SwapPageForReference(ref ReferenceValue) *P
- func (s *PageOrMarker[P]) SwapReferenceForPage(p *P) ReferenceValue
- func (s *PageOrMarker[P]) SwapReferenceForReference(ref ReferenceValue) ReferenceValue
- func (s *PageOrMarker[P]) Take() PageOrMarker[P]
- type PageOrMarkerRef
- func (r PageOrMarkerRef[P]) DecrementMarkerShareCount()
- func (r PageOrMarkerRef[P]) Get() PageOrMarker[P]
- func (r PageOrMarkerRef[P]) GetMarkerShareCount() uint32
- func (r PageOrMarkerRef[P]) IncrementMarkerShareCount()
- func (r PageOrMarkerRef[P]) SetZeroIntervalAwaitingCleanLength(length uint64)
- func (r PageOrMarkerRef[P]) SwapContent(content PageOrMarker[P]) PageOrMarker[P]
- func (r PageOrMarkerRef[P]) SwapPageForReference(ref ReferenceValue) *P
- func (r PageOrMarkerRef[P]) SwapReferenceForPage(p *P) ReferenceValue
- func (r PageOrMarkerRef[P]) SwapReferenceForReference(ref ReferenceValue) ReferenceValue
- func (r PageOrMarkerRef[P]) Valid() bool
- type PageProvider
- type PageQueueNode
- type PageQueues
- func (pq *PageQueues[P, O]) AgeOnAccess()
- func (pq *PageQueues[P, O]) Backlink(page P) (VmoBacklink[P, O], bool)
- func (pq *PageQueues[P, O]) ChangeObjectOffset(page P, object O, pageOffset uint64)
- func (pq *PageQueues[P, O]) ChangeObjectOffsetArray(pages []P, object O, offsets []uint64)
- func (pq *PageQueues[P, O]) CompressFailed(page P)
- func (pq *PageQueues[P, O]) DebugPageIsAnonymous(page P) bool
- func (pq *PageQueues[P, O]) DebugPageIsAnonymousZeroFork(page P) bool
- func (pq *PageQueues[P, O]) DebugPageIsAnyAnonymous(page P) bool
- func (pq *PageQueues[P, O]) DebugPageIsFailedReclaim(page P) bool
- func (pq *PageQueues[P, O]) DebugPageIsHighPriority(page P) bool
- func (pq *PageQueues[P, O]) DebugPageIsPagerBackedDirty(page P) bool
- func (pq *PageQueues[P, O]) DebugPageIsReclaim(page P) (bool, uint64)
- func (pq *PageQueues[P, O]) DebugPageIsReclaimIsolate(page P) bool
- func (pq *PageQueues[P, O]) DebugPageIsWired(page P) bool
- func (pq *PageQueues[P, O]) DisableAging()
- func (pq *PageQueues[P, O]) EnableAging()
- func (pq *PageQueues[P, O]) EnableAnonymousReclaim(zeroForks bool)
- func (pq *PageQueues[P, O]) GetActiveInactiveCounts() ActiveInactiveCounts
- func (pq *PageQueues[P, O]) GetReclaimQueueCounts() ReclaimCounts
- func (pq *PageQueues[P, O]) HarvestedCount() int
- func (pq *PageQueues[P, O]) IsHarvested(page P) bool
- func (pq *PageQueues[P, O]) IsPageReclaimable(page P) bool
- func (pq *PageQueues[P, O]) LastAgeReason() AgeReason
- func (pq *PageQueues[P, O]) MarkAccessed(page P)
- func (pq *PageQueues[P, O]) MoveAnonymousToAnonymousZeroFork(page P)
- func (pq *PageQueues[P, O]) MoveToAnonymous(page P, skipReclaim bool)
- func (pq *PageQueues[P, O]) MoveToHarvested(page P) bool
- func (pq *PageQueues[P, O]) MoveToHighPriority(page P)
- func (pq *PageQueues[P, O]) MoveToPagerBackedDirty(page P)
- func (pq *PageQueues[P, O]) MoveToReclaim(page P)
- func (pq *PageQueues[P, O]) MoveToReclaimDontNeed(page P)
- func (pq *PageQueues[P, O]) MoveToWired(page P)
- func (pq *PageQueues[P, O]) Pages() iter.Seq[P]
- func (pq *PageQueues[P, O]) PeekAnonymousZeroForkWhere(accept func(P) bool) (VmoBacklink[P, O], bool)
- func (pq *PageQueues[P, O]) PeekDontNeedWhere(accept func(P) bool) (VmoBacklink[P, O], bool)
- func (pq *PageQueues[P, O]) PeekIsolate(lowestQueue uint64) (VmoBacklink[P, O], bool)
- func (pq *PageQueues[P, O]) PeekIsolateWhere(lowestQueue uint64, accept func(P) bool) (VmoBacklink[P, O], bool)
- func (pq *PageQueues[P, O]) PeekUnharvestedWhere(n int, accept func(P) bool) []VmoBacklink[P, O]
- func (pq *PageQueues[P, O]) PopAnonymousZeroFork() (VmoBacklink[P, O], bool)
- func (pq *PageQueues[P, O]) QueueCounts() Counts
- func (pq *PageQueues[P, O]) ReclaimIsOnlyPagerBacked() bool
- func (pq *PageQueues[P, O]) Remove(page P)
- func (pq *PageQueues[P, O]) RemoveArrayIntoList(pages []P, out *[]P)
- func (pq *PageQueues[P, O]) RotateReclaimQueues()
- func (pq *PageQueues[P, O]) SecondChances() uint64
- func (pq *PageQueues[P, O]) SetActiveRatioMultiplier(multiplier uint32)
- func (pq *PageQueues[P, O]) SetAnonymous(page P, object O, pageOffset uint64, skipReclaim bool)
- func (pq *PageQueues[P, O]) SetAnonymousZeroFork(page P, object O, pageOffset uint64)
- func (pq *PageQueues[P, O]) SetHighPriority(page P, object O, pageOffset uint64)
- func (pq *PageQueues[P, O]) SetPagerBackedDirty(page P, object O, pageOffset uint64)
- func (pq *PageQueues[P, O]) SetReclaim(page P, object O, pageOffset uint64)
- func (pq *PageQueues[P, O]) SetWired(page P, object O, pageOffset uint64)
- type PageRequest
- type PageRequestType
- type PageSource
- func (s *PageSource) AppendOutstanding(dst []RequestRange, typ PageRequestType, start, end uint64) []RequestRange
- func (s *PageSource) Close()
- func (s *PageSource) DebugIsPageOk(page *VmPage, offset uint64) bool
- func (s *PageSource) Detach()
- func (s *PageSource) GetPages(offset, length uint64, request *PageRequest) error
- func (s *PageSource) IsDetached() bool
- func (s *PageSource) OnPagesDirtied(offset, length uint64)
- func (s *PageSource) OnPagesFailed(offset, length uint64, status error)
- func (s *PageSource) OnPagesSupplied(offset, length uint64)
- func (s *PageSource) Properties() PageSourceProperties
- func (s *PageSource) RequestDirtyTransition(request *PageRequest, offset, length uint64) error
- func (s *PageSource) SendPages(offset, length uint64, request *PageRequest) (sent bool, sentLen uint64, err error)
- func (s *PageSource) ShouldTrapDirtyTransitions() bool
- func (s *PageSource) SupportsPageRequestType(typ PageRequestType) bool
- type PageSourceProperties
- type PageSourceType
- type PageSpliceList
- func (s *PageSpliceList[P]) AddPagesFrom(merge func(src, dst *PageOrMarker[P], offset uint64), source *PageList[P], ...)
- func (s *PageSpliceList[P]) Finalize()
- func (s *PageSpliceList[P]) Free()
- func (s *PageSpliceList[P]) Initialize(length uint64)
- func (s *PageSpliceList[P]) Insert(offset uint64, content PageOrMarker[P]) error
- func (s *PageSpliceList[P]) IsEmpty() bool
- func (s *PageSpliceList[P]) IsFinalized() bool
- func (s *PageSpliceList[P]) IsInitialized() bool
- func (s *PageSpliceList[P]) IsProcessed() bool
- func (s *PageSpliceList[P]) MutatePages(fn func(slot PageOrMarkerRef[P], offset uint64) error, start uint64) error
- func (s *PageSpliceList[P]) Pop() PageOrMarker[P]
- func (s *PageSpliceList[P]) Position() uint64
- func (s *PageSpliceList[P]) RemovePagesAndIterateGaps(pageFn func(content PageOrMarker[P], offset uint64) error, ...) error
- func (s *PageSpliceList[P]) Reuse()
- type PagerProxy
- func (p *PagerProxy) ClearAsyncRequest(request *PageRequest)
- func (p *PagerProxy) DebugIsPageOk(*VmPage, uint64) bool
- func (p *PagerProxy) Holds(request *PageRequest) bool
- func (p *PagerProxy) OnClose()
- func (p *PagerProxy) OnDetach()
- func (p *PagerProxy) Properties() PageSourceProperties
- func (p *PagerProxy) SendAsyncRequest(request *PageRequest)
- func (p *PagerProxy) SwapAsyncRequest(old, newReq *PageRequest)
- func (p *PagerProxy) WaitOnEvent(ctx context.Context, event *Event) error
- func (p *PagerProxy) Waits() PagerWaits
- type PagerWaits
- type Pmm
- type QueueObject
- type QueuedPage
- type RangeChangeOp
- type ReclaimAttempt
- type ReclaimCounts
- type ReclaimFailure
- type ReclaimFunction
- type ReclaimSuccess
- type ReclaimType
- type ReferenceValue
- type RequestRange
- type RequireResult
- type RootResolver
- type SentinelType
- type SnapshotType
- type SpillStorage
- func (s *SpillStorage[K]) Available() int
- func (s *SpillStorage[K]) CompressedData(ctx context.Context, ref ReferenceValue, dst []byte) (int, uint32, error)
- func (s *SpillStorage[K]) Free(ref ReferenceValue)
- func (s *SpillStorage[K]) GetMemoryUsage() StorageMemoryUsage
- func (s *SpillStorage[K]) GetMetadata(ref ReferenceValue) uint32
- func (s *SpillStorage[K]) HasVersion(key K) bool
- func (s *SpillStorage[K]) Holds(ref ReferenceValue) bool
- func (s *SpillStorage[K]) Publish(ref ReferenceValue, key K) bool
- func (s *SpillStorage[K]) ReadVersion(ctx context.Context, key K, dst []byte) (bool, error)
- func (s *SpillStorage[K]) Release(ctx context.Context) error
- func (s *SpillStorage[K]) Reserve() (ReferenceValue, bool)
- func (s *SpillStorage[K]) SetMetadata(ref ReferenceValue, metadata uint32)
- func (s *SpillStorage[K]) Store(ctx context.Context, data []byte) (ReferenceValue, error)
- func (s *SpillStorage[K]) StoreReserved(ctx context.Context, refs []ReferenceValue, data []byte) (int, error)
- func (s *SpillStorage[K]) Unstore(ref ReferenceValue)
- func (s *SpillStorage[K]) Versions() int
- func (s *SpillStorage[K]) WriteVersion(ctx context.Context, key K, data []byte) (bool, error)
- type StorageMemoryUsage
- type StoreAsIs
- type StrategyResult
- type SupplyOptions
- type TriggerReason
- type VmPage
- type VmPageQueues
- type VmoBacklink
Constants ¶
const ( // PfFlagWrite is VMM_PF_FLAG_WRITE: the access writes. PfFlagWrite uint = 1 << 0 // PfFlagHwFault is VMM_PF_FLAG_HW_FAULT: the hardware asks for the page. PfFlagHwFault uint = 1 << 5 // PfFlagSwFault is VMM_PF_FLAG_SW_FAULT: software asks for the page. PfFlagSwFault uint = 1 << 6 // PfFlagFaultMask is either fault. PfFlagFaultMask = PfFlagHwFault | PfFlagSwFault )
The page fault flags GetPage takes, from fault.h.
const ( // NumReclaim is kNumReclaim, the number of reclaim queues. NumReclaim = 8 // NumActiveQueues is kNumActiveQueues: the newest reclaim queues, whose // pages are active and never peeked for reclaim. NumActiveQueues = 2 )
const MaxSpillPages = 1<<(32-ReferenceAlignBits) - 1
MaxSpillPages is the most allocations a SpillStorage can hand out: every id a reference holds once shifted past the alignment bits, but the one the temporary reference is. Zircon's slot storage bounds its ids the same way.
const NodePages = pageFanOut
NodePages is kPageFanOut, the number of slots in one node.
const ReferenceAlignBits = 3
ReferenceAlignBits is the number of low bits of a reference that must be zero.
Variables ¶
var ( // ErrShouldWait is ZX_ERR_SHOULD_WAIT: a page request was filled out and // the caller should wait on it and try again. ErrShouldWait = errors.New("zirconvm: should wait") // ErrOutOfRange is ZX_ERR_OUT_OF_RANGE. ErrOutOfRange = errors.New("zirconvm: out of range") // ErrInvalidArgs is ZX_ERR_INVALID_ARGS. ErrInvalidArgs = errors.New("zirconvm: invalid arguments") // ErrNotFound is ZX_ERR_NOT_FOUND. ErrNotFound = errors.New("zirconvm: not found") // ErrBadState is ZX_ERR_BAD_STATE. ErrBadState = errors.New("zirconvm: bad state") // ErrNotSupported is ZX_ERR_NOT_SUPPORTED. ErrNotSupported = errors.New("zirconvm: not supported") // ErrAlreadyExists is ZX_ERR_ALREADY_EXISTS. ErrAlreadyExists = errors.New("zirconvm: already exists") // ErrIO is ZX_ERR_IO. ErrIO = errors.New("zirconvm: I/O error") // ErrIODataIntegrity is ZX_ERR_IO_DATA_INTEGRITY. ErrIODataIntegrity = errors.New("zirconvm: data integrity error") // ErrNoSpace is ZX_ERR_NO_SPACE. ErrNoSpace = errors.New("zirconvm: no space") // ErrBufferTooSmall is ZX_ERR_BUFFER_TOO_SMALL. ErrBufferTooSmall = errors.New("zirconvm: buffer too small") )
The statuses Zircon's VM returns, as errors.
var ErrNoMemory = errors.New("zirconvm: no slot for the offset")
ErrNoMemory is Zircon's ZX_ERR_NO_MEMORY: a slot could not be had. A Go allocation does not fail, so here it means only an offset at or past the page list's MaxSize.
var ErrStop = errors.New("zirconvm: stop")
ErrStop ends a walk early without failing it. It is Zircon's ZX_ERR_STOP.
Functions ¶
func IsValidExternalFailureCode ¶
IsValidExternalFailureCode reports whether a provider may fail a request with status.
func IsValidInternalFailureCode ¶
IsValidInternalFailureCode reports whether the kernel side may fail a request with status.
func RequestLen ¶
func RequestLen(request *PageRequest) uint64
RequestLen is the length of a request the provider owns.
func RequestOffset ¶
func RequestOffset(request *PageRequest) uint64
RequestOffset is the offset of a request the provider owns.
Types ¶
type ActiveInactiveCounts ¶
type ActiveInactiveCounts struct{ Active, Inactive int }
ActiveInactiveCounts are the reclaimable pages that are active and that are not.
type AgeReason ¶
type AgeReason int
AgeReason is PageQueues::AgeReason: why the queues aged.
const ( // AgeReasonActiveRatio is ActiveRatio: the allowed ratio of active to // inactive pages was exceeded. AgeReasonActiveRatio AgeReason = iota // AgeReasonManual is Manual: an explicit RotateReclaimQueues. AgeReasonManual // AgeReasonAccess is not Zircon's; it takes the place of Timeout. A fault // made or marked a page accessed, and AgeOnAccess aged the queues for it. AgeReasonAccess )
type AttributionCounts ¶
type AttributionCounts struct {
UncompressedBytes uint64
CompressedBytes uint64
PrivateUncompressedBytes uint64
PrivateCompressedBytes uint64
ScaledUncompressedBytes uint64
ScaledCompressedBytes uint64
}
AttributionCounts is the memory attributed to an object, Zircon's vm::AttributionCounts. Zircon scales shared pages by fractional bytes; only hidden nodes share pages and the port has none, so every count here is whole bytes and the scaled counts equal the private ones.
func PrivateAttributionCounts ¶
func PrivateAttributionCounts(uncompressed, compressed uint64) AttributionCounts
PrivateAttributionCounts is make_private_attribution_counts: counts of an object with private content only.
func (AttributionCounts) TotalBytes ¶
func (a AttributionCounts) TotalBytes() uint64
TotalBytes is all the bytes counted.
func (AttributionCounts) TotalPrivateBytes ¶
func (a AttributionCounts) TotalPrivateBytes() uint64
TotalPrivateBytes is the bytes no other object shares.
type BatchInserter ¶
type BatchInserter[P any] struct { // contains filtered or unexported fields }
BatchInserter is LookupOrAllocate with NoIntervals for offsets near each other: in the same node or the next ones. While it is in use nothing else may change the list, or Reset must be called before it is used again.
func (*BatchInserter[P]) LookupOrAllocate ¶
func (b *BatchInserter[P]) LookupOrAllocate(offset uint64) *PageOrMarker[P]
LookupOrAllocate is PageList.LookupOrAllocate with NoIntervals. It is correct for any offset, and faster when each is near the one before.
func (*BatchInserter[P]) Reset ¶
func (b *BatchInserter[P]) Reset()
Reset makes the inserter safe to use again after the list was changed.
type CanOverwriteSlot ¶
type CanOverwriteSlot uint8
CanOverwriteSlot is which content an added page may replace.
const ( // OverwriteEmpty overwrites only empty slots. OverwriteEmpty CanOverwriteSlot = iota // OverwriteEmptyOrParent also overwrites parent content markers. OverwriteEmptyOrParent // OverwriteZeroMarkerOrInterval also overwrites zero markers and zero // intervals. OverwriteZeroMarkerOrInterval // OverwritePageOrRef overwrites anything. OverwritePageOrRef )
type CompressKind ¶
type CompressKind uint8
CompressKind is which of Zircon's variant a result holds.
const ( // CompressedToRef is a compressed reference, or for a strategy a length. CompressedToRef CompressKind = iota // CompressedToZero is Zircon's ZeroTag: the page was zeros. CompressedToZero // CompressFailed is Zircon's FailTag: the page could not be compressed // or kept. CompressFailed )
type CompressResult ¶
type CompressResult struct {
Kind CompressKind
Ref ReferenceValue
Src PageAndMetadata
}
CompressResult is the result of a compression, Zircon's VmCompressor::CompressResult: a reference, ZeroTag, or FailTag with the page that was to be compressed.
type CompressedStorage ¶
type CompressedStorage interface {
// Store keeps data, the compressed bytes, and returns a reference to
// them. Zircon passes the buffer page and may get a page back; here the
// storage copies the bytes it keeps. It fails where the storage has no
// room, which is Zircon's nullopt, or where it cannot write.
Store(ctx context.Context, data []byte) (ReferenceValue, error)
// Free gives back what a reference holds, and the reference.
Free(ref ReferenceValue)
// CompressedData reads the bytes a reference holds into dst and returns
// their length and the reference's metadata. Zircon returns a pointer to
// the bytes, which cannot fail; reading a file can.
CompressedData(ctx context.Context, ref ReferenceValue, dst []byte) (int, uint32, error)
// GetMetadata and SetMetadata are the metadata kept with a reference.
GetMetadata(ref ReferenceValue) uint32
SetMetadata(ref ReferenceValue, metadata uint32)
// GetMemoryUsage is what the storage holds.
GetMemoryUsage() StorageMemoryUsage
// D5: Reserve takes a reference that holds nothing yet, or reports
// false where the storage has no room left.
Reserve() (ReferenceValue, bool)
// D5: StoreReserved writes the bytes of refs, which Reserve made, one
// page apart in data; only the last may be shorter than a page. It needs
// no room. It returns how many writes it took.
StoreReserved(ctx context.Context, refs []ReferenceValue, data []byte) (int, error)
// D5: Unstore drops the bytes a reference holds and keeps the
// reference, for a page that holds it again.
Unstore(ref ReferenceValue)
}
CompressedStorage keeps compressed pages, Zircon's VmCompressedStorage. Instances may be used concurrently. The storage is a file here, so what reads or writes it takes a context, and can fail.
type Compression ¶
type Compression struct {
// contains filtered or unexported fields
}
Compression compresses pages into a storage, Zircon's VmCompression. Each one has its own references, which do not move to another.
func NewCompression ¶
func NewCompression(pmm Pmm, pageSize uint64, storage CompressedStorage, strategy CompressionStrategy, threshold uint64) *Compression
NewCompression compresses pages of pageSize bytes from pmm into storage with strategy. A page that does not compress to threshold bytes or fewer is not kept.
func (*Compression) AcquireCompressor ¶
func (c *Compression) AcquireCompressor() CompressorGuard
AcquireCompressor takes the one compressor.
func (*Compression) Compress ¶
func (c *Compression) Compress(ctx context.Context, src []byte) CompressResult
Compress compresses a page's bytes into new storage.
func (*Compression) Decompress ¶
func (c *Compression) Decompress(ctx context.Context, ref ReferenceValue, dst []byte) (uint32, error)
Decompress decompresses a reference into dst and frees it, and returns its metadata. Zircon's cannot fail; reading the storage can, and then the reference is left as it was.
func (*Compression) DecompressReserved ¶
func (c *Compression) DecompressReserved(ctx context.Context, ref ReferenceValue, dst []byte) (uint32, ReferenceValue, error)
DecompressReserved decompresses a reference into dst for a page that is to hold its reservation (D5): the reference itself, which keeps its place and holds no bytes from here, or for the temporary reference the reservation of the page being compressed, which goes with the bytes. It returns the metadata and the reservation.
func (*Compression) Free ¶
func (c *Compression) Free(ref ReferenceValue)
Free frees a reference without decompressing it.
func (*Compression) GetMetadata ¶
func (c *Compression) GetMetadata(ref ReferenceValue) uint32
GetMetadata is a reference's metadata. The caller holds the lock of the object that holds the reference.
func (*Compression) GetStats ¶
func (c *Compression) GetStats() CompressionStats
GetStats is the compression's statistics.
func (*Compression) IsTempReference ¶
func (c *Compression) IsTempReference(ref ReferenceValue) bool
IsTempReference reports whether ref is the compressor's temporary reference.
func (*Compression) MoveReference ¶
func (c *Compression) MoveReference(ref ReferenceValue) (PageAndMetadata, bool)
MoveReference turns the temporary reference back into a page, by copying it to the compressor's spare page. Any other reference is left as it is. It must be called where a reference moves in or out of a page list.
func (*Compression) Reserve ¶
func (c *Compression) Reserve() (ReferenceValue, bool)
Reserve takes a reservation for a page about to be dirty (D5), or reports false where the storage has no room left.
func (*Compression) SetMetadata ¶
func (c *Compression) SetMetadata(ref ReferenceValue, metadata uint32)
SetMetadata sets a reference's metadata. The caller holds the lock of the object that holds the reference.
type CompressionStats ¶
type CompressionStats struct {
MemoryUsage StorageMemoryUsage
TotalPageCompressionAttempts uint64
FailedPageCompressionAttempts uint64
TotalPageDecompressions uint64
CompressedPageEvictions uint64
}
CompressionStats is VmCompression::Stats, without the decompression age buckets: see the timestamp above.
type CompressionStrategy ¶
type CompressionStrategy interface {
// Compress compresses src into dst, which is limit bytes long, and
// returns the compressed length, or StrategyZero if src is all zeros, or
// StrategyFail if it does not fit.
Compress(src, dst []byte, limit uint64) StrategyResult
// Decompress decompresses src, a page compressed, into dst.
Decompress(src, dst []byte)
}
CompressionStrategy compresses and decompresses a page, Zircon's VmCompressionStrategy.
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
Compressor is one compression in progress, Zircon's VmCompressor. The object that owns a page lends it to the compressor and holds the compressor's temporary reference in its slot meanwhile, so the page can be compressed with the object's lock dropped. Anyone who finds the temporary reference can decompress it, which copies the page. Back under the lock the owner swaps the temporary reference for the result, if it is still there.
func (*Compressor) Arm ¶
func (c *Compressor) Arm() error
Arm makes the compressor ready to start, allocating its spare page.
func (*Compressor) Compress ¶
func (c *Compressor) Compress(ctx context.Context)
Compress compresses the page, with no lock held: into the page's own reservation where it holds one (D5).
func (*Compressor) Finalize ¶
func (c *Compressor) Finalize()
Finalize ends the compression once the temporary reference is no longer in use, so the compressor can be armed again.
func (*Compressor) Free ¶
func (c *Compressor) Free(ref ReferenceValue)
Free frees a reference Compress made that turned out not to be needed. Where Compress wrote into the page's reservation (D5), only the bytes are dropped: the reservation stays with whoever holds the page now.
func (*Compressor) IsIdle ¶
func (c *Compressor) IsIdle() bool
IsIdle reports whether no compression is in progress.
func (*Compressor) IsTempReference ¶
func (c *Compressor) IsTempReference(ref ReferenceValue) bool
IsTempReference reports whether ref is this compressor's temporary reference.
func (*Compressor) IsTempReferenceInUse ¶
func (c *Compressor) IsTempReferenceInUse() bool
IsTempReferenceInUse reports whether the temporary reference is lent out.
func (*Compressor) ReturnTempReference ¶
func (c *Compressor) ReturnTempReference(ref ReferenceValue)
ReturnTempReference gives the temporary reference back. The page stays until Finalize, since Compress may still be reading it.
func (*Compressor) Start ¶
func (c *Compressor) Start(src PageAndMetadata) ReferenceValue
Start takes the page to compress and returns the temporary reference to put in its slot. The caller may change the metadata from here until it takes the result.
func (*Compressor) TakeCompressionResult ¶
func (c *Compressor) TakeCompressionResult() CompressResult
TakeCompressionResult takes the result of the compression, with the metadata the owner last set. Only the holder of the object's lock may.
type CompressorGuard ¶
type CompressorGuard struct {
// contains filtered or unexported fields
}
CompressorGuard holds the compressor, Zircon's VmCompression::CompressorGuard.
func (CompressorGuard) Release ¶
func (g CompressorGuard) Release()
Release gives the compressor back, which must not be in the middle of a compression. It is the guard's destructor.
type Counts ¶
type Counts struct {
Reclaim [NumReclaim]int
ReclaimIsolate int
PagerBackedDirty int
Anonymous int
Wired int
AnonymousZeroFork int
FailedReclaim int
HighPriority int
}
Counts are the pages in each queue, Zircon's PageQueues::Counts. Reclaim is by age, the newest first.
type CowPages ¶
type CowPages struct {
// contains filtered or unexported fields
}
CowPages holds an object's pages in a page list and knows its parent, Zircon's VmCowPages. The port keeps the snapshot-on-write child only: no hidden nodes, no full or modified snapshots, no slices or references (plan: Zircon's objects and ours). An object is either a region's layer, whose page source is the pager and whose lookups fall through to identity roots through its RootResolver, or an identity root, or an anonymous object.
func (*CowPages) AddNewPageLocked ¶
func (c *CowPages) AddNewPageLocked(offset uint64, page *VmPage, overwrite CanOverwriteSlot, zero bool, deferred *DeferredOps) (PageOrMarker[VmPage], error)
AddNewPageLocked adds a newly allocated page at offset, zeroed if zero. On an error the caller keeps the page. What the slot held is returned.
func (*CowPages) AddNewPagesLocked ¶
func (c *CowPages) AddNewPagesLocked(startOffset uint64, pages []*VmPage, overwrite CanOverwriteSlot, zero bool, deferred *DeferredOps) error
AddNewPagesLocked adds pages from startOffset on. The object takes the pages whatever happens.
func (*CowPages) CommitRangeLocked ¶
func (c *CowPages) CommitRangeLocked(ctx context.Context, r CowRange, deferred *DeferredOps, pageRequest *MultiPageRequest) (uint64, error)
CommitRangeLocked commits r, which is page aligned and in the object, returning how much it committed. With content to read it returns ErrShouldWait with pageRequest to wait on, having committed what it could.
func (*CowPages) CreateCloneLocked ¶
func (c *CowPages) CreateCloneLocked(typ SnapshotType, requireUnidirectional bool, r CowRange) (*CowPages, error)
CreateCloneLocked makes a clone of r of the kind asked for, which must be one a snapshot-on-write child can be: SnapshotOnWrite, or SnapshotModified of an object with no parent, which has nothing modified to snapshot. A full snapshot, or a modified one of a child, needs a hidden parent and is refused. The new object shares the tree's lock and is not yet alive.
func (*CowPages) DebugGetPage ¶
DebugGetPage is the page at offset, or nil.
func (*CowPages) DebugGetPageCountLocked ¶
DebugGetPageCountLocked counts the pages and references held.
func (*CowPages) DebugGetPageLocked ¶
DebugGetPageLocked is DebugGetPage with the lock held.
func (*CowPages) DebugGetParent ¶
DebugGetParent is the object's parent, for tests.
func (*CowPages) DebugGetPopulatedSlotsCount ¶
DebugGetPopulatedSlotsCount is the tracked count of populated slots.
func (*CowPages) DebugIsEmpty ¶
DebugIsEmpty reports whether nothing is at offset.
func (*CowPages) DebugIsMarker ¶
DebugIsMarker reports whether a zero marker is at offset.
func (*CowPages) DebugIsPage ¶
DebugIsPage reports whether a page is at offset.
func (*CowPages) DebugIsReference ¶
DebugIsReference reports whether a compressed reference is at offset. Zircon's tests read this through attribution counts.
func (*CowPages) DebugLookupDepthLocked ¶
DebugLookupDepthLocked counts the parents up to the root.
func (*CowPages) DebugLookupReadable ¶
func (c *CowPages) DebugLookupReadable(r CowRange, fn func(offset uint64, page *VmPage) error) error
DebugLookupReadable is LookupReadableLocked with the lock taken.
func (*CowPages) DebugValidateContinuousAttribution ¶
DebugValidateContinuousAttribution checks the tracked count against the page list.
func (*CowPages) DecommitRange ¶
DecommitRange frees the pages in r, which then read as zero. An object whose empty slots do not read zero, a child or one a pager backs, does not support it.
func (*CowPages) DecompressInRange ¶
DecompressInRange decompresses every reference the object owns in r, committing nothing else.
func (*CowPages) DedupZeroPage ¶
DedupZeroPage replaces page at offset with zeros if it holds only zeros. It fails for a page not the object's at offset, and for a page not Clean of an object that tracks dirty pages.
func (*CowPages) DetachSource ¶
func (c *CowPages) DetachSource()
DetachSource detaches the page source, so later faults fail, and frees the pages that can be read again: everything but pages not Clean, which the pager may still write back, and what a checkpoint holds.
func (*CowPages) DirtyPages ¶
DirtyPages makes every page in r Dirty, as the pager's answer to a DIRTY request: markers and zero intervals become new zero pages first. It is all or nothing, since the pager may be reserving space by it.
func (*CowPages) EnumerateDirtyRangesLocked ¶
func (c *CowPages) EnumerateDirtyRangesLocked(r CowRange, fn func(offset, length uint64, isZero bool) error) error
EnumerateDirtyRangesLocked calls fn on every run of pages in r not Clean, AwaitingClean included, and on every dirty zero interval as a zero range.
func (*CowPages) FailPageRequestsLocked ¶
FailPageRequestsLocked fails the outstanding requests in r with status. It changes nothing in the object.
func (*CowPages) GetAttributedMemoryInRangeLocked ¶
func (c *CowPages) GetAttributedMemoryInRangeLocked(r CowRange) AttributionCounts
GetAttributedMemoryInRangeLocked is the memory attributed to the object in r.
func (*CowPages) GetLookupCursorLocked ¶
func (c *CowPages) GetLookupCursorLocked(r CowRange) (*LookupCursor, error)
GetLookupCursorLocked is a cursor over r, which is page aligned and in the object.
func (*CowPages) HeapAllocationBytesLocked ¶
HeapAllocationBytesLocked is the memory the page list takes.
func (*CowPages) HeldPageLocked ¶
HeldPageLocked is the page a checkpoint holds at offset beside the page list (D1), nil where it holds none there.
func (*CowPages) Lock ¶
Lock is the object's lock, for callers that need to hold it across a Locked method.
func (*CowPages) LookupLocked ¶
LookupLocked calls fn on every page in r, with its offset.
func (*CowPages) LookupReadableLocked ¶
func (c *CowPages) LookupReadableLocked(r CowRange, fn func(offset uint64, page *VmPage) error) error
LookupReadableLocked calls fn on every page that reads in r, wherever it is held, with the offset it reads at here.
func (*CowPages) MaybeDeadTransition ¶
MaybeDeadTransition makes the object dead if nothing reaches it any more, and returns its parent, which may then need the same. Zircon locks the parent and a sibling here; the tree shares one lock.
func (*CowPages) PageLocked ¶
PageLocked is the page the object holds at offset, nil where it holds none: a lookup of its own page list, not of what reads there. The pager looks up an identity root's pages with it, a root having no parent.
func (*CowPages) PageWouldReadZeroLocked ¶
PageWouldReadZeroLocked reports whether an offset holds no page and would read as zero.
func (*CowPages) ProcessPagesForSupply ¶
ProcessPagesForSupply turns the references in pages into pages, for an object a page source backs, which holds pages only.
func (*CowPages) PromoteRangeForReclamation ¶
PromoteRangeForReclamation moves the clean pages a pager backs in r to the don't-need queue, to be reclaimed first. Only pages present are moved.
func (*CowPages) ProtectRangeFromReclamation ¶
func (c *CowPages) ProtectRangeFromReclamation(ctx context.Context, r CowRange, setAlwaysNeed, ignoreErrors bool) error
ProtectRangeFromReclamation looks up every page of r, reading absent ones, which marks them accessed, and sets their always_need hint if setAlwaysNeed. With ignoreErrors a page that fails is skipped; otherwise the first error ends it.
func (*CowPages) QueryPagerVmoStatsLocked ¶
QueryPagerVmoStatsLocked reports whether the object was modified since the last reset, and resets that if reset.
func (*CowPages) RangeChangeUpdateLocked ¶
func (c *CowPages) RangeChangeUpdateLocked(r CowRange, op RangeChangeOp, deferred *DeferredOps)
RangeChangeUpdateLocked applies op to every mapping of r: this object's now, its clones' through deferred. Without deferred only RemoveWrite may be asked for, which clones need not see as they map nothing writable.
func (*CowPages) ReadWritebackLocked ¶
ReadWritebackLocked reads into buf, from offset, what a writeback in progress holds: what the checkpoint holds beside the page list, or else the AwaitingClean page or zero interval in it. It is what an upload reads, which D1 keeps the bytes of the pause. An offset no writeback holds is ErrBadState. offset is page rounded and buf whole pages.
func (*CowPages) ReclaimPage ¶
func (c *CowPages) ReclaimPage(ctx context.Context, page *VmPage, offset uint64, action EvictionAction, compressor *Compressor) (ReclaimSuccess, ReclaimFailure)
ReclaimPage tries to reclaim page at offset. An object that can evict evicts the node's worth of pages around it, unless the page is not Clean, when with a compressor it is compressed (D2). An anonymous object compresses with compressor, which must have just been armed. On a failure the page is touched, so it stops being a candidate.
func (*CowPages) ReclaimRangeForEviction ¶
func (c *CowPages) ReclaimRangeForEviction(offset, length uint64, action EvictionAction) (ReclaimSuccess, ReclaimFailure)
ReclaimRangeForEviction evicts the Clean pages in the isolate queues in [offset, offset+len). If none could be evicted, and every failure was a page not isolated, the range was accessed: EvictAccessed.
func (*CowPages) ReclamationEventCountLocked ¶
ReclamationEventCountLocked counts the object's reclamations.
func (*CowPages) RemovePageLocked ¶
RemovePageLocked takes page out of the object at offset, from the page list or from what a checkpoint holds beside it (D1), and out of the page queues, whatever its dirty state, without freeing it, and reports whether it was there. It is not Zircon's. A page at a frame has no bytes in this process (NewFramePage), so the pager whose Pmm made it moves its bytes itself: it spills a page it evicts, compares one it settles and moves one it retires into an identity root by taking it out here, and then gives it back or supplies it elsewhere. Its offset is left empty, as an eviction leaves it: a READ of it is the pager's to answer.
func (*CowPages) SizeLocked ¶
SizeLocked is the object's size.
func (*CowPages) SupplyPagesLocked ¶
func (c *CowPages) SupplyPagesLocked(r CowRange, pages *PageSpliceList[VmPage], options SupplyOptions, deferred *DeferredOps) error
SupplyPagesLocked puts the content of pages in r. A pager's supply fills only offsets with no content, freeing what it does not use; a transfer overwrites. Gaps in the splice list are zeros, as markers.
func (*CowPages) TakePages ¶
func (c *CowPages) TakePages(ctx context.Context, r CowRange, spliceOffset uint64, pages *PageSpliceList[VmPage], pageRequest *MultiPageRequest) (uint64, error)
TakePages moves the content of r into pages, at spliceOffset, leaving r zero, and returns how much it took. An object a page source backs cannot give its pages away. Content seen from a parent is copied in to be taken, which may return ErrShouldWait with pageRequest to wait on, having taken what it could.
func (*CowPages) TransitionToAliveLocked ¶
func (c *CowPages) TransitionToAliveLocked()
TransitionToAliveLocked makes a new object usable.
func (*CowPages) WritebackAbandonLocked ¶
func (c *CowPages) WritebackAbandonLocked(ctx context.Context, r CowRange, deferred *DeferredOps) error
WritebackAbandonLocked gives back the pages of a writeback in r that will not end, because its publication failed or the region was unsealed (D4): AwaitingClean pages, spilled pages and zero intervals are Dirty again, what the checkpoint held beside the page list goes, and mappings of r are revoked. Zircon has no abandon.
func (*CowPages) WritebackBeginLocked ¶
WritebackBeginLocked makes the Dirty pages and dirty zero intervals in r AwaitingClean, and takes write access away from r's mappings. With isZeroRange only intervals are taken: the pager means to write zeros, and a page dirtied meanwhile must not be cleaned by it. What a checkpoint held beside the page list in r from an earlier writeback is dropped: the range is taken again (D1).
func (*CowPages) WritebackEndLocked ¶
WritebackEndLocked makes the AwaitingClean pages in r Clean, and removes the zero intervals cleaned, or clips the part cleaned. What the checkpoint held beside the page list in r is freed: it landed (D1).
func (*CowPages) WritebackProtectLocked ¶
WritebackProtectLocked takes write access away from every mapping of r, so a store faults and is seen. It is the range protection D3 issues in the pause; the walk behind it is WritebackBeginLocked.
func (*CowPages) ZeroPagesLocked ¶
func (c *CowPages) ZeroPagesLocked(ctx context.Context, r CowRange, dirtyTrack bool, deferred *DeferredOps, pageRequest *MultiPageRequest) (uint64, error)
ZeroPagesLocked makes r read as zeros, freeing pages where it can. With dirtyTrack, zeros in an object a pager backs start Dirty. It returns how much it zeroed, which may be some even on an error.
type CowRange ¶
type CowRange struct{ Offset, Len uint64 }
CowRange is a range of a CowPages, Zircon's VmCowRange.
func (CowRange) IsBoundedBy ¶
IsBoundedBy reports whether the range is within [0, limit), without overflowing: Zircon's InRange.
func (CowRange) TrimmedFromStart ¶
TrimmedFromStart is the range less its first amount bytes.
func (CowRange) WithLength ¶
WithLength is the range from the same offset with a new length.
type Cursor ¶
type Cursor[P any] struct { // contains filtered or unexported fields }
Cursor walks consecutive slots of a page list, Empty ones included, and stops where the slots stop being consecutive. It is Zircon's VMPLCursor. Nothing may be removed from the list while a cursor is in use; inserting is safe. The zero Cursor is not valid; a list's Lookup*Cursor methods make them.
func (*Cursor[P]) Current ¶
func (c *Cursor[P]) Current() *PageOrMarker[P]
Current is the slot the cursor is at, which may be Empty, or nil when the cursor is no longer valid. The caller tracks the offset by counting Steps, and must only read the slot.
func (*Cursor[P]) CurrentRef ¶
func (c *Cursor[P]) CurrentRef() PageOrMarkerRef[P]
CurrentRef is Current with a PageOrMarkerRef, which is not Valid when the cursor is not.
func (*Cursor[P]) ForEveryContiguous ¶
func (c *Cursor[P]) ForEveryContiguous(fn func(p *PageOrMarker[P]) error) error
ForEveryContiguous calls fn on every slot from the cursor on while they are consecutive. It is a loop of Current and Step.
type DeferredOps ¶
type DeferredOps struct {
// contains filtered or unexported fields
}
DeferredOps is the work an operation leaves for after the object's lock is dropped, Zircon's VmCowPages::DeferredOps: the range change of the object's clones, and the freeing of pages. For a hierarchy a page source backs it also holds the source's lock across the operation, which serializes every change to the hierarchy.
func NewDeferredOps ¶
func NewDeferredOps(self *CowPages) *DeferredOps
NewDeferredOps is the deferred work of an operation on self, which must be made before self's lock is taken. Finish runs it after the lock is dropped.
func (*DeferredOps) Finish ¶
func (d *DeferredOps) Finish()
Finish runs the deferred work, with the object's lock not held: Zircon's destructor. The pages are freed after the range change and before the page source's lock is dropped.
type DirtyState ¶
type DirtyState uint8
DirtyState is the dirty state of a page, VmCowPages::DirtyState.
The transitions between the three tracked states can roughly be summarized as follows:
- A page starts off as Clean when supplied.
- A write transitions the page from Clean to Dirty.
- A writeback begin moves the Dirty page to AwaitingClean.
- A writeback end moves the AwaitingClean page to Clean.
- A write that comes in while the writeback is in progress does not move the AwaitingClean page back to Dirty, as Zircon's does: the AwaitingClean page stays with the checkpoint and the write gets a Dirty copy (D1, see dirty.go).
const ( // Untracked is a page that does not track dirty state, a page of an // object no user pager backs. Untracked DirtyState = iota // Clean is a page whose contents are what was supplied. Clean // Dirty is a page modified since it was supplied, to be written back. Dirty // AwaitingClean is a page a writeback is writing back. AwaitingClean )
func (DirtyState) String ¶
func (s DirtyState) String() string
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is an auto-unsignaling event with a status, Zircon's AutounsignalEvent: a signal wakes one wait and is then consumed.
type EvictedPageCounts ¶
type EvictedPageCounts struct {
// PagerBacked were evicted from objects a pager backs.
PagerBacked uint64
// Compressed were evicted from anonymous objects by compression.
Compressed uint64
}
EvictedPageCounts are the pages an eviction freed, by how.
func (EvictedPageCounts) Total ¶
func (c EvictedPageCounts) Total() uint64
Total is non_loaned_total: with no loaned pages, every page freed.
type EvictionAction ¶
type EvictionAction uint8
EvictionAction says whether reclamation follows the always_need hint.
const ( // FollowHint does not evict a page hinted always needed. FollowHint EvictionAction = iota // IgnoreHint evicts it anyway. IgnoreHint )
type EvictionHint ¶
type EvictionHint uint8
EvictionHint is a hint on how to reclaim a range, VmObject::EvictionHint.
const ( // DontNeed reclaims the range first. DontNeed EvictionHint = iota // AlwaysNeed protects the range from reclamation. AlwaysNeed )
type EvictionLevel ¶
type EvictionLevel uint8
EvictionLevel is a rough control of how old a page must be to be evicted.
const ( // OnlyOldest evicts only from the oldest queues, and follows the // always_need hint. OnlyOldest EvictionLevel = iota // IncludeNewest evicts from every queue that is not active, and ignores // the hint. IncludeNewest )
type EvictionResult ¶
type EvictionResult struct {
Counts EvictedPageCounts
FreeTargetReached bool
}
EvictionResult is what an eviction did and why it stopped: the pages it evicted, which can be more or fewer than asked for, and whether the free target was reached.
type EvictionTarget ¶
type EvictionTarget struct {
Pending bool
// FreePagesTarget is the free page count to reach.
FreePagesTarget uint64
// MinPagesToFree is how many pages to evict at least, however many are
// free.
MinPagesToFree uint64
Level EvictionLevel
PrintCounts bool
OOMTrigger bool
}
EvictionTarget is what an eviction is to reach. Different goroutines can set a target and evict, so it is kept behind a lock.
type Evictor ¶
type Evictor[R any] struct { // contains filtered or unexported fields }
Evictor frees pages to meet targets, synchronously for a caller or asynchronously on its own goroutine. R is what a synchronous eviction is for; an asynchronous one is for R's zero value.
func NewEvictor ¶
NewEvictor is an evictor of node's pages: it reclaims from the node's page queues, with the node's compression, and counts the node's pmm's free pages. Eviction is off until EnableEviction.
func NewEvictorWith ¶
func NewEvictorWith[R any](pageSize uint64, reclaim ReclaimFunction[R], freePages FreePagesFunction) *Evictor[R]
NewEvictorWith is an evictor of pages of pageSize bytes that reclaims with reclaim and counts free pages with freePages. It is Zircon's constructor for tests to fake the reclamation; the pager, whose pages are not a node's, uses it too. Eviction is off until EnableEviction.
func (*Evictor[R]) DisableEviction ¶
func (e *Evictor[R]) DisableEviction()
DisableEviction stops every eviction, and the eviction goroutine if there is one, waiting for it to end. It must not run beside another DisableEviction or an EnableEviction.
func (*Evictor[R]) EnableEviction ¶
EnableEviction lets evictions happen, compressing if useCompression. Departure: Zircon starts the eviction thread here; the goroutine is started by the first asynchronous request instead.
func (*Evictor[R]) EvictAsynchronous ¶
func (e *Evictor[R]) EvictAsynchronous(ctx context.Context, minMemToFree, freeMemTarget uint64, level EvictionLevel, output Output)
EvictAsynchronous asks the eviction goroutine to evict until free memory is freeMemTarget bytes and at least minMemToFree bytes have been freed, and returns at once. Requests made before the goroutine gets to them combine: the minimums add, and the free targets and levels take the larger. The goroutine stops when the target is met or nothing more can be reclaimed, and clears the target.
Departure: the first request starts the goroutine, with ctx's values and without its cancellation. Zircon starts its thread in EnableEviction.
func (*Evictor[R]) EvictFromExternalTarget ¶
func (e *Evictor[R]) EvictFromExternalTarget(ctx context.Context, request R, target EvictionTarget) (EvictionResult, error)
EvictFromExternalTarget evicts for request to target, which is used for this eviction only and leaves the evictor's own target alone.
func (*Evictor[R]) EvictSynchronous ¶
func (e *Evictor[R]) EvictSynchronous(ctx context.Context, request R, minMemToFree, freeMemTarget uint64, level EvictionLevel, output Output, reason TriggerReason) (EvictionResult, error)
EvictSynchronous evicts for request until free memory is freeMemTarget bytes and at least minMemToFree bytes have been freed. level is a rough control of how old a page must be to be evicted. It reports what it evicted and whether the free target was reached.
func (*Evictor[R]) IsCompressionEnabled ¶
IsCompressionEnabled reports whether eviction may compress.
func (*Evictor[R]) IsEvictionEnabled ¶
IsEvictionEnabled reports whether any eviction can happen.
func (*Evictor[R]) Stats ¶
func (e *Evictor[R]) Stats() EvictorStats
Stats are the pages this evictor's evictions freed. It is GetGlobalStats, for one evictor.
type EvictorStats ¶
type EvictorStats struct {
PagerBackedOOM, PagerBackedOther uint64
CompressionOOM, CompressionOther uint64
}
EvictorStats are the pages every eviction of one evictor freed, by how and whether it was for an out of memory condition.
type FreePagesFunction ¶
type FreePagesFunction func() uint64
FreePagesFunction counts the free pages the targets are measured against.
type Freer ¶
type Freer[P any] interface { FreePage(page *P) FreeReference(ref ReferenceValue) }
Freer gives back what a slot owned: a page to where pages come from, and a reference to the storage it refers to. Zircon frees into the kernel's one pmm and one page compression. A process here runs a pager per page size, each with its own arena and spill file, so a splice list is given its Freer.
type IntervalDirtyState ¶
type IntervalDirtyState uint32
IntervalDirtyState is the dirty state of a zero interval, as VmCowPages::DirtyState is of a page. AwaitingClean is not a state here: an interval whose start carries a nonzero AwaitingClean length is AwaitingClean for that length, which splits and merges more easily.
const ( IntervalUntracked IntervalDirtyState = iota IntervalClean IntervalDirty )
func (IntervalDirtyState) String ¶
func (s IntervalDirtyState) String() string
type IntervalHandling ¶
type IntervalHandling uint8
IntervalHandling is how LookupOrAllocate treats an offset in an interval.
const ( // NoIntervals says the list holds no intervals, so every slot may be // changed on its own and no check is made. NoIntervals IntervalHandling = iota // CheckForInterval reports whether the offset is in an interval, and // returns a slot only if it can be changed on its own. CheckForInterval // SplitInterval splits an interval around the offset, so the slot it // returns may be changed freely. See lookupOrAllocateCheckForInterval. SplitInterval )
type IntervalType ¶
type IntervalType uint32
IntervalType is what a sparse interval is of. Zircon supports one.
const IntervalZero IntervalType = 0
IntervalZero is a range of zero pages.
type LookupCursor ¶
type LookupCursor struct {
// contains filtered or unexported fields
}
LookupCursor returns successive pages over a range of an object, Zircon's VmCowPages::LookupCursor. The object's lock must be held from GetLookupCursorLocked to the cursor's last use, and the lock of the owner of a page returned stays held until the next operation on the cursor.
By default a new zero page is a zero fork and a page returned is marked accessed; DisableZeroFork and DisableMarkAccessed turn these off. An allocation list given with GiveAllocList serves allocations first.
func (*LookupCursor) ClearAllocList ¶
func (lc *LookupCursor) ClearAllocList()
ClearAllocList takes the allocation list back. Pages left in it are the caller's to free.
func (*LookupCursor) DisableMarkAccessed ¶
func (lc *LookupCursor) DisableMarkAccessed()
DisableMarkAccessed stops pages returned being marked accessed.
func (*LookupCursor) DisableZeroFork ¶
func (lc *LookupCursor) DisableZeroFork()
DisableZeroFork stops new zero pages being queued as zero forks.
func (*LookupCursor) GiveAllocList ¶
func (lc *LookupCursor) GiveAllocList(list *[]*VmPage)
GiveAllocList gives the cursor pages to allocate from first. ClearAllocList must be called before the cursor is released.
func (*LookupCursor) IfExistPages ¶
func (lc *LookupCursor) IfExistPages(willWrite bool, maxPages uint64, pages []*VmPage) uint64
IfExistPages fills pages with up to maxPages contiguous pages usable as they are, and moves past them. It returns how many.
func (*LookupCursor) MaybePage ¶
func (lc *LookupCursor) MaybePage(willWrite bool) *VmPage
MaybePage is the current page if it is usable as it is, or nil, and moves on either way.
func (*LookupCursor) Release ¶
func (lc *LookupCursor) Release()
Release drops the lock of the owner of the last page returned. Zircon's destructor does it.
func (*LookupCursor) RequireOwnedPage ¶
func (lc *LookupCursor) RequireOwnedPage(ctx context.Context, willWrite bool, maxRequestPages uint64, deferred *DeferredOps, pageRequest *MultiPageRequest) (RequireResult, error)
RequireOwnedPage is the page at the current offset, owned by the target: content elsewhere is copied in, references decompressed, zeros forked, and absent content asked for, returning ErrShouldWait with pageRequest to wait on. If willWrite, the page is made ready to write, which may make a dirty request. On success the cursor moves on.
func (*LookupCursor) RequirePage ¶
func (lc *LookupCursor) RequirePage(ctx context.Context, willWrite bool, maxRequestPages uint64, deferred *DeferredOps, pageRequest *MultiPageRequest) (RequireResult, error)
RequirePage is RequireOwnedPage to write and RequireReadPage to read.
func (*LookupCursor) RequireReadPage ¶
func (lc *LookupCursor) RequireReadPage(ctx context.Context, maxRequestPages uint64, deferred *DeferredOps, pageRequest *MultiPageRequest) (RequireResult, error)
RequireReadPage is the page that reads at the current offset, which may be the zero page or a parent's page. Absent content is asked for, returning ErrShouldWait with pageRequest to wait on. On success the cursor moves on.
func (*LookupCursor) SkipMissingPages ¶
func (lc *LookupCursor) SkipMissingPages() uint64
SkipMissingPages moves past pages MaybePage would not return, and returns how many.
type Mapping ¶
type Mapping interface {
// RangeChangeUpdate applies op to the mapping's pages of [offset,
// offset+len) of the object. It is called with the object's lock held.
RangeChangeUpdate(offset, length uint64, op RangeChangeOp)
}
Mapping is a mapping of an object, which range changes reach. Zircon's VmMapping updates hardware page tables under the object's lock; the pager's mappings are a VMM's, reached by commands (plan: The mapping protocol), so here a mapping is an interface.
type MultiPageRequest ¶
type MultiPageRequest struct {
// contains filtered or unexported fields
}
MultiPageRequest is the one request a lookup may make, of whichever kind it needs, Zircon's MultiPageRequest. Zircon's anonymous request waits for the pmm to have pages; a Pmm here fails or succeeds at once, so it is not kept.
func NewMultiPageRequest ¶
func NewMultiPageRequest() *MultiPageRequest
NewMultiPageRequest is a request not yet in use.
func (*MultiPageRequest) CancelRequests ¶
func (m *MultiPageRequest) CancelRequests()
CancelRequests withdraws any request in use.
func (*MultiPageRequest) ReadRequest ¶
func (m *MultiPageRequest) ReadRequest() *PageRequest
ReadRequest is the read request a lookup made, which is active. Zircon's page fault handler waits on it; the pager, which is in the faulting process, asks its provider whether it was sent (PagerProxy.Holds), answers it where it was, and waits on it where it waits on another.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is what Zircon's VM reaches through globals: Pmm::Node(), its page queues and its page compression. Go has no such globals here, so every object carries the Node it was made on.
func NewNode ¶
func NewNode(pmm Pmm, pageSize uint64, compression *Compression) *Node
NewNode is a node over pmm, whose pages are pageSize bytes, with its own page queues. compression may be nil: Zircon's Pmm::Node(). GetPageCompression() is null when no compression is configured.
func (*Node) AgeDirtyPages ¶
func (n *Node) AgeDirtyPages()
AgeDirtyPages puts the node's Dirty and AwaitingClean pages of objects a pager backs in the reclaim queues, beside its Clean ones, where Zircon keeps them in the dirty queue, which does not age. It is D2's queue: such a page can be spilled here, so an evictor takes it in the order accesses touched it, whatever its state. The node's objects then evict it themselves no more than Zircon's do (ReclaimRangeForEviction takes only Clean pages): it is the pager whose Pmm made the page that spills it. It is set before any page is queued.
func (*Node) Compression ¶
func (n *Node) Compression() *Compression
Compression is the node's page compression, or nil.
func (*Node) FreePage ¶
FreePage gives a page back to the node's pmm. With FreeReference it makes the node the Freer a splice list of its pages frees through.
func (*Node) FreeReference ¶
func (n *Node) FreeReference(ref ReferenceValue)
FreeReference frees a compressed reference to the node's compression.
func (*Node) PageQueues ¶
func (n *Node) PageQueues() *VmPageQueues
PageQueues are the node's page queues.
type ObjectPaged ¶
type ObjectPaged struct {
// contains filtered or unexported fields
}
ObjectPaged is an object a mapping maps, Zircon's VmObjectPaged: a CowPages and the mappings of it. Slices and references are not ported, so an object always sees the whole of its CowPages.
func CreateExternal ¶
func CreateExternal(node *Node, src *PageSource, size uint64) (*ObjectPaged, error)
CreateExternal is an object src backs: VmObjectPaged::CreateExternal.
func CreateIdentityRoot ¶
func CreateIdentityRoot(node *Node, src *PageSource, size uint64) (*ObjectPaged, error)
CreateIdentityRoot is an identity root: an object a pager backs whose pages are Clean and never change, which regions' lookups fall through to. It is ours (plan: Zircon's objects and ours).
func CreateObjectPaged ¶
func CreateObjectPaged(node *Node, size uint64) (*ObjectPaged, error)
CreateObjectPaged is an anonymous object of size bytes: VmObjectPaged:: Create.
func CreateRegionLayer ¶
func CreateRegionLayer(node *Node, src *PageSource, size uint64, roots RootResolver) (*ObjectPaged, error)
CreateRegionLayer is a region's layer: an object the pager backs, which tracks its pages dirty, and whose offsets it holds no content for read the identity root roots names. It is ours (plan: Zircon's objects and ours).
func (*ObjectPaged) AddMapping ¶
func (o *ObjectPaged) AddMapping(m Mapping)
AddMapping makes m a mapping of the object.
func (*ObjectPaged) CommitRange ¶
func (o *ObjectPaged) CommitRange(ctx context.Context, offset, length uint64) error
CommitRange commits [offset, offset+len), waiting for any pages to be supplied.
func (*ObjectPaged) CowPages ¶
func (o *ObjectPaged) CowPages() *CowPages
CowPages is the VmCowPages the object sees: Zircon's cow_pages_locked(), which a region's resolver names an identity root by and the pager locks to look a root's pages up.
func (*ObjectPaged) CreateClone ¶
func (o *ObjectPaged) CreateClone(typ SnapshotType, offset, size uint64) (*ObjectPaged, error)
CreateClone is a clone of [offset, offset+size). Only SnapshotOnWrite is ported.
func (*ObjectPaged) DebugGetCowPages ¶
func (o *ObjectPaged) DebugGetCowPages() *CowPages
DebugGetCowPages is the object's CowPages, for tests.
func (*ObjectPaged) DebugGetPage ¶
func (o *ObjectPaged) DebugGetPage(offset uint64) *VmPage
DebugGetPage is the page at offset, or nil.
func (*ObjectPaged) DecommitRange ¶
func (o *ObjectPaged) DecommitRange(offset, length uint64) error
DecommitRange frees the pages of [offset, offset+len).
func (*ObjectPaged) Destroy ¶
func (o *ObjectPaged) Destroy()
Destroy is the object's destructor, which Go does not have: the CowPages is let go, and dies with its parents as far as nothing else reaches them.
func (*ObjectPaged) DetachSource ¶
func (o *ObjectPaged) DetachSource()
DetachSource detaches the object's page source.
func (*ObjectPaged) DirtyPages ¶
func (o *ObjectPaged) DirtyPages(ctx context.Context, offset, length uint64) error
DirtyPages makes [offset, offset+len) Dirty, as the pager's answer to a DIRTY request.
func (*ObjectPaged) EnumerateDirtyRanges ¶
func (o *ObjectPaged) EnumerateDirtyRanges(offset, length uint64, fn func(offset, length uint64, isZero bool) error) error
EnumerateDirtyRanges calls fn on every run of [offset, offset+len) not Clean.
func (*ObjectPaged) FailPageRequests ¶
func (o *ObjectPaged) FailPageRequests(offset, length uint64, status error) error
FailPageRequests fails the outstanding requests of [offset, offset+len).
func (*ObjectPaged) GetAttributedMemory ¶
func (o *ObjectPaged) GetAttributedMemory() AttributionCounts
GetAttributedMemory is the memory attributed to the whole object.
func (*ObjectPaged) GetAttributedMemoryInRange ¶
func (o *ObjectPaged) GetAttributedMemoryInRange(offset, length uint64) AttributionCounts
GetAttributedMemoryInRange is the memory attributed to [offset, offset+len), trimmed to the object.
func (*ObjectPaged) GetPage ¶
func (o *ObjectPaged) GetPage(ctx context.Context, offset uint64, pfFlags uint, pageRequest *MultiPageRequest) (*VmPage, error)
GetPage is the page at offset. Without a fault flag only a page usable as it is is returned, or ErrNotFound; with one, absent content is asked for, returning ErrShouldWait with pageRequest to wait on.
func (*ObjectPaged) GetPageBlocking ¶
func (o *ObjectPaged) GetPageBlocking(ctx context.Context, offset uint64, pfFlags uint) (*VmPage, error)
GetPageBlocking is GetPage that waits for any request and goes again.
func (*ObjectPaged) HintRange ¶
func (o *ObjectPaged) HintRange(ctx context.Context, offset, length uint64, hint EvictionHint) error
HintRange applies an eviction hint to [offset, offset+len). Only objects a pager backs take hints; others ignore them.
func (*ObjectPaged) IsResizable ¶
func (o *ObjectPaged) IsResizable() bool
IsResizable reports whether the object may be resized. Resizing is not ported.
func (*ObjectPaged) Lookup ¶
func (o *ObjectPaged) Lookup(offset, length uint64, fn func(offset uint64, page *VmPage) error) error
Lookup calls fn on every page the object holds in [offset, offset+len).
func (*ObjectPaged) LookupContiguous ¶
func (o *ObjectPaged) LookupContiguous(offset, length uint64) (*VmPage, error)
LookupContiguous is the page at offset if every page of [offset, offset+len) is held and contiguous. Only a contiguous object, not ported, may ask for more than one page.
func (*ObjectPaged) PrefetchRange ¶
func (o *ObjectPaged) PrefetchRange(ctx context.Context, offset, length uint64) error
PrefetchRange brings [offset, offset+len) in: read from the pager for an object a pager backs, decompressed otherwise.
func (*ObjectPaged) QueryPagerVmoStats ¶
func (o *ObjectPaged) QueryPagerVmoStats(reset bool) (bool, error)
QueryPagerVmoStats reports whether the object was modified, and resets that if reset.
func (*ObjectPaged) RangeChangeUpdate ¶
func (o *ObjectPaged) RangeChangeUpdate(r CowRange, op RangeChangeOp)
RangeChangeUpdate applies op to r of every mapping of the object and its clones that see it, as a range change from the object's own changes does.
func (*ObjectPaged) ReadWriteback ¶
ReadWriteback reads what a writeback in progress holds of whole pages from offset into buf: the bytes of its pause (D1).
func (*ObjectPaged) ReclamationEventCount ¶
func (o *ObjectPaged) ReclamationEventCount() uint64
ReclamationEventCount counts the object's reclamations.
func (*ObjectPaged) RemoveMapping ¶
func (o *ObjectPaged) RemoveMapping(m Mapping)
RemoveMapping takes m off the object's mappings.
func (*ObjectPaged) RemovePage ¶
func (o *ObjectPaged) RemovePage(offset uint64, page *VmPage) bool
RemovePage is RemovePageLocked, taking the object's lock.
func (*ObjectPaged) SplitAwaitingClean ¶
func (o *ObjectPaged) SplitAwaitingClean(offset uint64, copied *VmPage) error
SplitAwaitingClean is D1's split for a store whose copy the pager made: a page at a frame has no bytes in this process (NewFramePage), so the pager whose Pmm made the AwaitingClean page at offset copies its bytes into copied itself, and copied becomes the Dirty page at offset while the AwaitingClean page goes to what the checkpoint holds beside the page list. It is not Zircon's, whose split is a store's that copies here (splitAwaitingCleanLocked). Anything but an AwaitingClean page at offset is ErrBadState, and copied is then still the caller's.
func (*ObjectPaged) SupplyPages ¶
func (o *ObjectPaged) SupplyPages(ctx context.Context, offset, length uint64, pages *PageSpliceList[VmPage], options SupplyOptions) error
SupplyPages puts pages in [offset, offset+len).
func (*ObjectPaged) TakePages ¶
func (o *ObjectPaged) TakePages(ctx context.Context, offset, length uint64, pages *PageSpliceList[VmPage]) error
TakePages moves the content of [offset, offset+len) into pages, which it initializes, leaving the range zero.
func (*ObjectPaged) WritebackAbandon ¶
func (o *ObjectPaged) WritebackAbandon(ctx context.Context, offset, length uint64) error
WritebackAbandon gives back the pages of a writeback of [offset, offset+len) that will not end (D4).
func (*ObjectPaged) WritebackBegin ¶
func (o *ObjectPaged) WritebackBegin(offset, length uint64, isZeroRange bool) error
WritebackBegin begins a writeback of [offset, offset+len).
func (*ObjectPaged) WritebackEnd ¶
func (o *ObjectPaged) WritebackEnd(offset, length uint64) error
WritebackEnd ends a writeback of [offset, offset+len).
func (*ObjectPaged) WritebackProtect ¶
func (o *ObjectPaged) WritebackProtect(offset, length uint64) error
WritebackProtect takes write access away from [offset, offset+len): the range protection of a pause (D3).
func (*ObjectPaged) ZeroRange ¶
func (o *ObjectPaged) ZeroRange(ctx context.Context, offset, length uint64) error
ZeroRange makes [offset, offset+len) read as zeros, Dirty in an object a pager backs.
func (*ObjectPaged) ZeroRangeUntracked ¶
func (o *ObjectPaged) ZeroRangeUntracked(ctx context.Context, offset, length uint64) error
ZeroRangeUntracked makes whole pages read as zeros that are not dirty tracked.
type PageAndMetadata ¶
PageAndMetadata is a page with the metadata that goes with it, Zircon's VmCompressor::PageAndMetadata.
type PageList ¶
type PageList[P any] struct { // contains filtered or unexported fields }
PageList is a VMO's pages by offset, Zircon's VmPageList. It is a tree of nodes of kPageFanOut slots each, keyed by the node's base offset, and holds only nodes with at least one slot that is not Empty.
Zircon's tree is its own lib/btree, whose iterators the list and its cursors step from node to node. This one is github.com/google/btree, which has no iterators: a step to the next or previous node is a search from the current node's offset. That finds the same node. The tree's search calls its ordering through a function value at every level, so the nodes are also kept by offset in a map, which finds a node that is there without a search: a lookup of a slot whose node exists, and a step to the node beside.
func NewPageList ¶
NewPageList is an empty page list over pages of pageSize bytes, which is a power of two.
func (*PageList[P]) AddZeroInterval ¶
func (pl *PageList[P]) AddZeroInterval(start, end uint64, state IntervalDirtyState) error
AddZeroInterval adds a zero interval over [start, end), which must hold nothing, in the given dirty state. It joins intervals beside it in the same state.
func (*PageList[P]) AnyOwnedPagesOrIntervalsInRange ¶
AnyOwnedPagesOrIntervalsInRange is AnyPagesOrIntervalsInRange skipping ParentContent markers, which stand for content the parent owns.
func (*PageList[P]) AnyPagesOrIntervalsInRange ¶
AnyPagesOrIntervalsInRange reports whether any slot in [start, end) holds a page, reference or marker, or whether the range is part of an interval.
func (*PageList[P]) Clear ¶
func (pl *PageList[P]) Clear()
Clear removes every node. It panics if a slot still holds a page or a reference, which would be lost.
func (*PageList[P]) ClipIntervalEnd ¶
ClipIntervalEnd moves an interval's end from intervalEnd to intervalEnd-length. The interval is longer than length.
func (*PageList[P]) ClipIntervalStart ¶
ClipIntervalStart moves an interval's start from intervalStart to intervalStart+length. The interval is longer than length.
func (*PageList[P]) ForEveryPage ¶
func (pl *PageList[P]) ForEveryPage(fn func(p *PageOrMarker[P], offset uint64) error) error
ForEveryPage calls fn on every slot of the list that is not Empty, in order of offset. fn must only read the slot.
func (*PageList[P]) ForEveryPageAndContiguousRunInRange ¶
func (pl *PageList[P]) ForEveryPageAndContiguousRunInRange(compare func(p *PageOrMarker[P], offset uint64) bool, pageFn func(p *PageOrMarker[P], offset uint64) error, runFn func(start, end uint64, isInterval bool) error, start, end uint64) error
ForEveryPageAndContiguousRunInRange calls pageFn on every slot in [start, end) that compare accepts, and runFn on every run of consecutive such slots with whether the run is an interval. An interval is a run of its own and is never joined to pages or markers beside it, and its part in the range is a run only if compare accepts both its start and its end, wherever they lie. pageFn and compare must only read the slot.
func (*PageList[P]) ForEveryPageAndGapInRange ¶
func (pl *PageList[P]) ForEveryPageAndGapInRange(pageFn func(p *PageOrMarker[P], offset uint64) error, gapFn func(start, end uint64) error, start, end uint64) error
ForEveryPageAndGapInRange calls pageFn on every slot in [start, end) that is not Empty, and gapFn on every run of Empty slots between them that is not inside an interval. pageFn must only read the slot.
func (*PageList[P]) ForEveryPageAndGapInRangeMutable ¶
func (pl *PageList[P]) ForEveryPageAndGapInRangeMutable(pageFn func(p PageOrMarkerRef[P], offset uint64) error, gapFn func(start, end uint64) error, start, end uint64) error
ForEveryPageAndGapInRangeMutable is ForEveryPageAndGapInRange with a PageOrMarkerRef.
func (*PageList[P]) ForEveryPageInCursorRange ¶
func (pl *PageList[P]) ForEveryPageInCursorRange(fn func(p *PageOrMarker[P], offset uint64) error, cursor Cursor[P], end uint64) error
ForEveryPageInCursorRange is ForEveryPageInRange from a valid cursor's offset. Unlike it, it returns ErrStop when fn stopped the walk.
func (*PageList[P]) ForEveryPageInRange ¶
func (pl *PageList[P]) ForEveryPageInRange(fn func(p *PageOrMarker[P], offset uint64) error, start, end uint64) error
ForEveryPageInRange calls fn on every slot in [start, end) that is not Empty. fn must only read the slot.
func (*PageList[P]) ForEveryPageInRangeMutable ¶
func (pl *PageList[P]) ForEveryPageInRangeMutable(fn func(p PageOrMarkerRef[P], offset uint64) error, start, end uint64) error
ForEveryPageInRangeMutable is ForEveryPageInRange with a PageOrMarkerRef.
func (*PageList[P]) ForEveryPageMutable ¶
func (pl *PageList[P]) ForEveryPageMutable(fn func(p PageOrMarkerRef[P], offset uint64) error) error
ForEveryPageMutable is ForEveryPage with a PageOrMarkerRef, which allows the limited changes it allows.
func (*PageList[P]) HasNoPageOrRef ¶
HasNoPageOrRef reports whether the list owns no page or reference, nothing that must be given back.
func (*PageList[P]) HasNoPageRefOrMarker ¶
HasNoPageRefOrMarker is HasNoPageOrRef that counts a marker too.
func (*PageList[P]) HeapAllocationBytes ¶
HeapAllocationBytes is the memory the list's nodes take. Zircon counts its tree's own nodes from the tree; google/btree does not report them, so this counts each page list node and its entry in the tree. The map of nodes beside the tree is not counted, as Zircon's tree has none.
func (*PageList[P]) IsEmpty ¶
IsEmpty reports whether the list holds no page, reference, marker or interval.
func (*PageList[P]) IsOffsetInZeroInterval ¶
IsOffsetInZeroInterval reports whether offset is in a zero interval.
func (*PageList[P]) Lookup ¶
func (pl *PageList[P]) Lookup(offset uint64) *PageOrMarker[P]
Lookup is the slot at offset, or nil if no node holds it. A slot it returns may be Empty. The caller must only read it, as Zircon's const pointer allows; it is valid until a Remove, Take or Merge changes the list.
func (*PageList[P]) LookupMutable ¶
func (pl *PageList[P]) LookupMutable(offset uint64) PageOrMarkerRef[P]
LookupMutable is Lookup with a PageOrMarkerRef, which is not Valid when no node holds the offset. Other changes need LookupOrAllocate.
func (*PageList[P]) LookupMutableCursor ¶
LookupMutableCursor is a cursor at offset, which is not valid when no node holds it.
func (*PageList[P]) LookupNearestMutableCursor ¶
LookupNearestMutableCursor is a cursor at the first slot at or after offset that a node holds, if there is one.
func (*PageList[P]) LookupOrAllocate ¶
func (pl *PageList[P]) LookupOrAllocate(offset uint64, handling IntervalHandling) (*PageOrMarker[P], bool)
LookupOrAllocate is the slot at offset, allocating its node if need be, and whether the offset is in an interval. It returns no slot only for an offset at or past MaxSize, or for one in an interval that handling does not allow splitting.
The slot may be changed freely, except that a slot that was not Empty must not be made Empty: RemoveContent does that. A slot that was Empty and is left Empty must be given back with ReturnEmptySlot, so no empty node stays.
func (*PageList[P]) MaxSize ¶
MaxSize is VmPageList::MAX_SIZE: no slot is at or past it, so the end of every node fits in an offset.
func (*PageList[P]) MergeRangeOnto ¶
func (pl *PageList[P]) MergeRangeOnto(migrate func(src, dst *PageOrMarker[P], otherOffset uint64), other *PageList[P], offset, endOffset uint64)
MergeRangeOnto moves [offset, endOffset) of this list onto other, with offset here at 0 there. For every slot in the range that is not Empty, migrate is called with the slot and its slot in other. Zircon returns false when it cannot allocate a node in other; a Go allocation does not fail, so this returns nothing.
func (*PageList[P]) NewBatchInserter ¶
func (pl *PageList[P]) NewBatchInserter() *BatchInserter[P]
NewBatchInserter is a BatchInserter over the list.
func (*PageList[P]) OverwriteZeroInterval ¶
func (pl *PageList[P]) OverwriteZeroInterval(oldStartOffset, oldEndOffset, newStartOffset, newEndOffset uint64, newState IntervalDirtyState) error
OverwriteZeroInterval overwrites all or part of a zero interval with a new zero interval [newStart, newEnd] in newState, splitting the old one in two if need be. oldStart and oldEnd are the old interval's start and end sentinels; either one may be math.MaxUint64 when not given.
- To overwrite all of it, both are given, and equal newStart and newEnd. The new interval replaces the old.
- To overwrite its start, oldStart is given and equals newStart, and oldEnd is not. The old interval then starts at newEnd + pageSize.
- To overwrite its end, oldEnd is given and equals newEnd, and oldStart is not. The old interval then ends at newStart - pageSize.
- Overwriting the middle is not allowed: oldStart is newStart, or oldEnd is newEnd, or both.
func (*PageList[P]) PopulateSlotsInInterval ¶
PopulateSlotsInInterval makes every offset in [start, end), which is in an interval, a Slot of its own, so that none of them fails a later lookup and each can be replaced with a page. It is the split of lookupOrAllocateCheckForInterval at every offset of the range, without a tree search for each.
func (*PageList[P]) RemoveAllContent ¶
func (pl *PageList[P]) RemoveAllContent(free func(content PageOrMarker[P]))
RemoveAllContent moves every slot's content to free, which owns it from then on, and leaves the list empty.
func (*PageList[P]) RemoveContent ¶
func (pl *PageList[P]) RemoveContent(offset uint64) PageOrMarker[P]
RemoveContent moves out whatever is at offset, which is Empty if nothing is.
func (*PageList[P]) RemovePages ¶
func (pl *PageList[P]) RemovePages(fn func(p *PageOrMarker[P], offset uint64) error, start, end uint64) error
RemovePages calls fn on every slot in [start, end) that is not Empty. fn may change the slot and take its page, and nodes it leaves empty are freed.
func (*PageList[P]) RemovePagesAndIterateGaps ¶
func (pl *PageList[P]) RemovePagesAndIterateGaps(pageFn func(p *PageOrMarker[P], offset uint64) error, gapFn func(start, end uint64) error, start, end uint64) error
RemovePagesAndIterateGaps is RemovePages that also calls gapFn on the gaps, as ForEveryPageAndGapInRange does.
func (*PageList[P]) ReplacePageWithZeroInterval ¶
func (pl *PageList[P]) ReplacePageWithZeroInterval(offset uint64, state IntervalDirtyState) *P
ReplacePageWithZeroInterval puts a zero interval in place of the page at offset, and returns the page, which the caller now owns.
func (*PageList[P]) ReturnEmptySlot ¶
ReturnEmptySlot gives back a slot LookupOrAllocate just returned Empty and that is still Empty, so a node it allocated is freed.
func (*PageList[P]) ReturnIntervalSlot ¶
ReturnIntervalSlot gives back an interval Slot that PopulateSlotsInInterval or a split made and that was not used, so it joins the interval it came from.
type PageOrMarker ¶
type PageOrMarker[P any] struct { // contains filtered or unexported fields }
PageOrMarker is the content of one slot of a page list, Zircon's VmPageOrMarker. It is in one of six states:
- Empty: it holds nothing.
- Page: it holds a page, which it owns until ReleasePage is called.
- Reference: it holds a reference to content elsewhere, which it owns until ReleaseReference is called.
- Marker: it is not a page, but it is not empty either. A marker says the page was deduplicated to zero, where Empty says the parent holds the content.
- Interval: the slot is part of a sparse interval. An interval has a Start sentinel and an End sentinel, and every offset between them is empty. An interval of one page is a Slot sentinel, which is both.
- ParentContent: there may be content for the slot, but the parent's page list must be checked for it. How it differs from Empty is up to the VMO.
The page list tries to keep two invariants, as Zircon's does. A node is never wholly empty: it has at least one slot that is not Empty. And an interval spans as much as it can: no two intervals sit side by side that one interval could represent.
The zero value is Empty. Slots are read by value, as Zircon reads them through a const pointer; a slot is changed through a *PageOrMarker that LookupOrAllocate or a removing walk hands out, or through a PageOrMarkerRef.
func MarkerWithShareCount ¶
func MarkerWithShareCount[P any](shareCount uint32) PageOrMarker[P]
MarkerWithShareCount is a zero marker shared shareCount times.
func Page ¶
func Page[P any](p *P) PageOrMarker[P]
Page is a slot holding p, which must not be nil: a nil page is Empty.
func ParentContent ¶
func ParentContent[P any]() PageOrMarker[P]
ParentContent says the parent's page list may hold the content.
func Reference ¶
func Reference[P any](ref ReferenceValue) PageOrMarker[P]
Reference is a slot holding ref.
func (*PageOrMarker[P]) DecrementMarkerShareCount ¶
func (s *PageOrMarker[P]) DecrementMarkerShareCount()
DecrementMarkerShareCount shares a marker once less. Its count must not be zero.
func (PageOrMarker[P]) GetMarkerShareCount ¶
func (s PageOrMarker[P]) GetMarkerShareCount() uint32
GetMarkerShareCount is how many times a marker is shared.
func (PageOrMarker[P]) GetZeroIntervalAwaitingCleanLength ¶
func (s PageOrMarker[P]) GetZeroIntervalAwaitingCleanLength() uint64
GetZeroIntervalAwaitingCleanLength is how much of a zero interval, from its start, is AwaitingClean. The slot must be a start or a single slot.
func (PageOrMarker[P]) GetZeroIntervalDirtyState ¶
func (s PageOrMarker[P]) GetZeroIntervalDirtyState() IntervalDirtyState
GetZeroIntervalDirtyState is a zero interval's dirty state.
func (*PageOrMarker[P]) IncrementMarkerShareCount ¶
func (s *PageOrMarker[P]) IncrementMarkerShareCount()
IncrementMarkerShareCount shares a marker once more.
func (PageOrMarker[P]) IsEmpty ¶
func (s PageOrMarker[P]) IsEmpty() bool
IsEmpty reports whether the slot holds nothing.
func (PageOrMarker[P]) IsInterval ¶
func (s PageOrMarker[P]) IsInterval() bool
IsInterval reports whether the slot is an interval sentinel.
func (PageOrMarker[P]) IsIntervalEnd ¶
func (s PageOrMarker[P]) IsIntervalEnd() bool
IsIntervalEnd reports whether the slot ends an interval of several pages.
func (PageOrMarker[P]) IsIntervalSlot ¶
func (s PageOrMarker[P]) IsIntervalSlot() bool
IsIntervalSlot reports whether the slot is an interval of one page.
func (PageOrMarker[P]) IsIntervalStart ¶
func (s PageOrMarker[P]) IsIntervalStart() bool
IsIntervalStart reports whether the slot starts an interval of several pages.
func (PageOrMarker[P]) IsIntervalZero ¶
func (s PageOrMarker[P]) IsIntervalZero() bool
IsIntervalZero reports whether the slot is a sentinel of a zero interval.
func (PageOrMarker[P]) IsMarker ¶
func (s PageOrMarker[P]) IsMarker() bool
IsMarker reports whether the slot is a zero marker.
func (PageOrMarker[P]) IsPage ¶
func (s PageOrMarker[P]) IsPage() bool
IsPage reports whether the slot holds a page.
func (PageOrMarker[P]) IsPageOrRef ¶
func (s PageOrMarker[P]) IsPageOrRef() bool
IsPageOrRef reports whether the slot holds a page or a reference, the two kinds of content it owns.
func (PageOrMarker[P]) IsParentContent ¶
func (s PageOrMarker[P]) IsParentContent() bool
IsParentContent reports whether the slot defers to the parent.
func (PageOrMarker[P]) IsReference ¶
func (s PageOrMarker[P]) IsReference() bool
IsReference reports whether the slot holds a reference.
func (PageOrMarker[P]) IsZeroIntervalClean ¶
func (s PageOrMarker[P]) IsZeroIntervalClean() bool
IsZeroIntervalClean reports whether a zero interval is Clean.
func (PageOrMarker[P]) IsZeroIntervalDirty ¶
func (s PageOrMarker[P]) IsZeroIntervalDirty() bool
IsZeroIntervalDirty reports whether a zero interval is Dirty.
func (PageOrMarker[P]) IsZeroIntervalUntracked ¶
func (s PageOrMarker[P]) IsZeroIntervalUntracked() bool
IsZeroIntervalUntracked reports whether a zero interval is Untracked.
func (PageOrMarker[P]) Page ¶
func (s PageOrMarker[P]) Page() *P
Page is the slot's page. The slot must hold one.
func (PageOrMarker[P]) Reference ¶
func (s PageOrMarker[P]) Reference() ReferenceValue
Reference is the slot's reference. The slot must hold one.
func (*PageOrMarker[P]) ReleasePage ¶
func (s *PageOrMarker[P]) ReleasePage() *P
ReleasePage moves the page out of the slot and leaves it Empty.
func (*PageOrMarker[P]) ReleaseReference ¶
func (s *PageOrMarker[P]) ReleaseReference() ReferenceValue
ReleaseReference moves the reference out of the slot and leaves it Empty.
func (*PageOrMarker[P]) Set ¶
func (s *PageOrMarker[P]) Set(content PageOrMarker[P])
Set moves content into the slot, Zircon's move assignment. The slot must not hold a page or a reference, which would be lost.
func (*PageOrMarker[P]) SetMarkerShareCount ¶
func (s *PageOrMarker[P]) SetMarkerShareCount(shareCount uint32)
SetMarkerShareCount sets how many times a marker is shared.
func (*PageOrMarker[P]) SetZeroIntervalAwaitingCleanLength ¶
func (s *PageOrMarker[P]) SetZeroIntervalAwaitingCleanLength(length uint64)
SetZeroIntervalAwaitingCleanLength sets how much of a zero interval, from its start, is AwaitingClean. The slot must be a start or a single slot.
func (*PageOrMarker[P]) Swap ¶
func (s *PageOrMarker[P]) Swap(other PageOrMarker[P]) PageOrMarker[P]
Swap puts other in the slot and returns what the slot held.
func (*PageOrMarker[P]) SwapPageForReference ¶
func (s *PageOrMarker[P]) SwapPageForReference(ref ReferenceValue) *P
SwapPageForReference replaces the slot's page with ref and returns the page.
func (*PageOrMarker[P]) SwapReferenceForPage ¶
func (s *PageOrMarker[P]) SwapReferenceForPage(p *P) ReferenceValue
SwapReferenceForPage replaces the slot's reference with p and returns the reference.
func (*PageOrMarker[P]) SwapReferenceForReference ¶
func (s *PageOrMarker[P]) SwapReferenceForReference(ref ReferenceValue) ReferenceValue
SwapReferenceForReference replaces the slot's reference with ref and returns the old one.
func (*PageOrMarker[P]) Take ¶
func (s *PageOrMarker[P]) Take() PageOrMarker[P]
Take moves the content out of the slot and leaves it Empty. It is Zircon's move out of a VmPageOrMarker.
type PageOrMarkerRef ¶
type PageOrMarkerRef[P any] struct { // contains filtered or unexported fields }
PageOrMarkerRef is a slot that may be changed only in limited ways: from one kind of content to another, and in its dirty state and share count. It is Zircon's VmPageOrMarkerRef. Most walks that are not meant to empty slots hand one out.
func (PageOrMarkerRef[P]) DecrementMarkerShareCount ¶
func (r PageOrMarkerRef[P]) DecrementMarkerShareCount()
DecrementMarkerShareCount shares a marker once less.
func (PageOrMarkerRef[P]) Get ¶
func (r PageOrMarkerRef[P]) Get() PageOrMarker[P]
Get is the slot's content, to read.
func (PageOrMarkerRef[P]) GetMarkerShareCount ¶
func (r PageOrMarkerRef[P]) GetMarkerShareCount() uint32
GetMarkerShareCount is how many times a marker is shared.
func (PageOrMarkerRef[P]) IncrementMarkerShareCount ¶
func (r PageOrMarkerRef[P]) IncrementMarkerShareCount()
IncrementMarkerShareCount shares a marker once more.
func (PageOrMarkerRef[P]) SetZeroIntervalAwaitingCleanLength ¶
func (r PageOrMarkerRef[P]) SetZeroIntervalAwaitingCleanLength(length uint64)
SetZeroIntervalAwaitingCleanLength sets how much of a zero interval is AwaitingClean.
func (PageOrMarkerRef[P]) SwapContent ¶
func (r PageOrMarkerRef[P]) SwapContent(content PageOrMarker[P]) PageOrMarker[P]
SwapContent puts content, which must not be Empty, in the slot and returns what the slot held, which may be.
func (PageOrMarkerRef[P]) SwapPageForReference ¶
func (r PageOrMarkerRef[P]) SwapPageForReference(ref ReferenceValue) *P
SwapPageForReference replaces the slot's page with ref and returns the page.
func (PageOrMarkerRef[P]) SwapReferenceForPage ¶
func (r PageOrMarkerRef[P]) SwapReferenceForPage(p *P) ReferenceValue
SwapReferenceForPage replaces the slot's reference with p and returns the reference.
func (PageOrMarkerRef[P]) SwapReferenceForReference ¶
func (r PageOrMarkerRef[P]) SwapReferenceForReference(ref ReferenceValue) ReferenceValue
SwapReferenceForReference replaces the slot's reference with ref and returns the old one.
func (PageOrMarkerRef[P]) Valid ¶
func (r PageOrMarkerRef[P]) Valid() bool
Valid reports whether the reference names a slot.
type PageProvider ¶
type PageProvider interface {
Properties() PageSourceProperties
// SendAsyncRequest hands the provider a request it now owns.
SendAsyncRequest(request *PageRequest)
// ClearAsyncRequest takes a request back.
ClearAsyncRequest(request *PageRequest)
// SwapAsyncRequest gives the provider newReq in place of old.
SwapAsyncRequest(old, newReq *PageRequest)
// DebugIsPageOk checks a page the source supplied, for asserts.
DebugIsPageOk(page *VmPage, offset uint64) bool
// OnDetach and OnClose tell the provider the source is detached and
// closed.
OnDetach()
OnClose()
// WaitOnEvent waits for a request's event. Zircon's takes whether the
// wait may be suspended; a Go wait ends with its context instead.
WaitOnEvent(ctx context.Context, event *Event) error
}
PageProvider answers a page source's requests, Zircon's PageProvider.
type PageQueueNode ¶
type PageQueueNode[P any, O QueueObject] struct { // contains filtered or unexported fields }
PageQueueNode is the part of vm_page_t the page queues own while a page is in one: its queue_node, and the backlink and queue number of its object state. A page type holds one and names it with QueueNode.
type PageQueues ¶
type PageQueues[P QueuedPage[P, O], O QueueObject] struct { // contains filtered or unexported fields }
PageQueues sort the pages of every object by how they can be reclaimed, Zircon's PageQueues.
func NewPageQueues ¶
func NewPageQueues[P QueuedPage[P, O], O QueueObject](pageSize uint64) *PageQueues[P, O]
NewPageQueues is a set of empty page queues for pages of pageSize bytes, a power of two of at most 2 MiB.
func (*PageQueues[P, O]) AgeOnAccess ¶
func (pq *PageQueues[P, O]) AgeOnAccess()
AgeOnAccess is not Zircon's. It is the aging Zircon's MRU thread does, done by the pager at each fault instead of by a thread on a timer (decision 4 of the plan). The pager ages the queues by one generation after each fault it serves, so its pages are ordered by when a fault last touched them. Like the MRU thread it respects DisableAging, and like RotateReclaimQueues it makes room for itself, since there is no LRU thread.
func (*PageQueues[P, O]) Backlink ¶
func (pq *PageQueues[P, O]) Backlink(page P) (VmoBacklink[P, O], bool)
Backlink is the object and offset a queued page's backlink names, as Zircon's page->object.get_object() and get_page_offset() are, and whether the page is in a queue. The pager reaches the object of a page it is giving up by it.
func (*PageQueues[P, O]) ChangeObjectOffset ¶
func (pq *PageQueues[P, O]) ChangeObjectOffset(page P, object O, pageOffset uint64)
ChangeObjectOffset changes a queued page's backlink. Only the page's owner may call it, under the object's lock.
func (*PageQueues[P, O]) ChangeObjectOffsetArray ¶
func (pq *PageQueues[P, O]) ChangeObjectOffsetArray(pages []P, object O, offsets []uint64)
ChangeObjectOffsetArray is ChangeObjectOffset for pages[i] at offsets[i].
func (*PageQueues[P, O]) CompressFailed ¶
func (pq *PageQueues[P, O]) CompressFailed(page P)
CompressFailed moves a page in a reclaim queue to the failed reclaim queue, so it is not tried again.
func (*PageQueues[P, O]) DebugPageIsAnonymous ¶
func (pq *PageQueues[P, O]) DebugPageIsAnonymous(page P) bool
DebugPageIsAnonymous reports whether a page is in the anonymous queue.
func (*PageQueues[P, O]) DebugPageIsAnonymousZeroFork ¶
func (pq *PageQueues[P, O]) DebugPageIsAnonymousZeroFork(page P) bool
DebugPageIsAnonymousZeroFork reports whether a page is in the zero fork queue.
func (*PageQueues[P, O]) DebugPageIsAnyAnonymous ¶
func (pq *PageQueues[P, O]) DebugPageIsAnyAnonymous(page P) bool
DebugPageIsAnyAnonymous reports whether a page is in either anonymous queue.
func (*PageQueues[P, O]) DebugPageIsFailedReclaim ¶
func (pq *PageQueues[P, O]) DebugPageIsFailedReclaim(page P) bool
DebugPageIsFailedReclaim reports whether a page is in the failed reclaim queue. Zircon reads that queue's count only.
func (*PageQueues[P, O]) DebugPageIsHighPriority ¶
func (pq *PageQueues[P, O]) DebugPageIsHighPriority(page P) bool
DebugPageIsHighPriority reports whether a page is in the high priority queue.
func (*PageQueues[P, O]) DebugPageIsPagerBackedDirty ¶
func (pq *PageQueues[P, O]) DebugPageIsPagerBackedDirty(page P) bool
DebugPageIsPagerBackedDirty reports whether a page is in the dirty queue.
func (*PageQueues[P, O]) DebugPageIsReclaim ¶
func (pq *PageQueues[P, O]) DebugPageIsReclaim(page P) (bool, uint64)
DebugPageIsReclaim reports whether a page is in a reclaim queue, and which: 0 is the newest.
func (*PageQueues[P, O]) DebugPageIsReclaimIsolate ¶
func (pq *PageQueues[P, O]) DebugPageIsReclaimIsolate(page P) bool
DebugPageIsReclaimIsolate reports whether a page of an object that can evict is in the isolate queue.
func (*PageQueues[P, O]) DebugPageIsWired ¶
func (pq *PageQueues[P, O]) DebugPageIsWired(page P) bool
DebugPageIsWired reports whether a page is in the wired queue.
func (*PageQueues[P, O]) DisableAging ¶
func (pq *PageQueues[P, O]) DisableAging()
DisableAging stops aging on access until EnableAging. A manual rotation still ages. A second DisableAging without an EnableAging between panics.
func (*PageQueues[P, O]) EnableAging ¶
func (pq *PageQueues[P, O]) EnableAging()
EnableAging lets aging on access go on.
func (*PageQueues[P, O]) EnableAnonymousReclaim ¶
func (pq *PageQueues[P, O]) EnableAnonymousReclaim(zeroForks bool)
EnableAnonymousReclaim puts anonymous pages in the reclaim queues, and zero forks too if zeroForks. Pages already queued move over. It cannot be undone.
func (*PageQueues[P, O]) GetActiveInactiveCounts ¶
func (pq *PageQueues[P, O]) GetActiveInactiveCounts() ActiveInactiveCounts
GetActiveInactiveCounts counts the active and inactive reclaimable pages.
func (*PageQueues[P, O]) GetReclaimQueueCounts ¶
func (pq *PageQueues[P, O]) GetReclaimQueueCounts() ReclaimCounts
GetReclaimQueueCounts counts the reclaimable pages. The isolate queues count as oldest, since their pages are reclaimed first.
func (*PageQueues[P, O]) HarvestedCount ¶
func (pq *PageQueues[P, O]) HarvestedCount() int
HarvestedCount is how many pages the harvested isolate queue holds: pages harvested and not touched since, which the evictor takes before any page it has not harvested. It is not Zircon's.
func (*PageQueues[P, O]) IsHarvested ¶
func (pq *PageQueues[P, O]) IsHarvested(page P) bool
IsHarvested reports whether a page is in the harvested isolate queue: the evictor harvested it, and nothing has marked it accessed since. It is not Zircon's.
func (*PageQueues[P, O]) IsPageReclaimable ¶
func (pq *PageQueues[P, O]) IsPageReclaimable(page P) bool
IsPageReclaimable reports whether a page is in an isolate queue, where reclamation takes pages from. Zircon's is static and reads the queue number with an atomic load.
func (*PageQueues[P, O]) LastAgeReason ¶
func (pq *PageQueues[P, O]) LastAgeReason() AgeReason
LastAgeReason is why the queues last aged, last_age_reason_, which Zircon reports in Dump.
func (*PageQueues[P, O]) MarkAccessed ¶
func (pq *PageQueues[P, O]) MarkAccessed(page P)
MarkAccessed tells the queues the page was accessed, so it moves to the newest reclaim queue. A page in no reclaim queue does not move.
func (*PageQueues[P, O]) MoveAnonymousToAnonymousZeroFork ¶
func (pq *PageQueues[P, O]) MoveAnonymousToAnonymousZeroFork(page P)
MoveAnonymousToAnonymousZeroFork moves a page in the anonymous queue to the zero fork queue. A page in another queue does not move.
func (*PageQueues[P, O]) MoveToAnonymous ¶
func (pq *PageQueues[P, O]) MoveToAnonymous(page P, skipReclaim bool)
MoveToAnonymous moves a page to the anonymous queue.
func (*PageQueues[P, O]) MoveToHarvested ¶
func (pq *PageQueues[P, O]) MoveToHarvested(page P) bool
MoveToHarvested is not Zircon's. It moves a page PeekUnharvestedWhere returned to the tail of the harvested isolate queue, once the evictor has harvested it, and reports whether it did: a page that left the standard isolate queue since, because a fault marked it accessed, stays where it is.
func (*PageQueues[P, O]) MoveToHighPriority ¶
func (pq *PageQueues[P, O]) MoveToHighPriority(page P)
MoveToHighPriority moves a page to the high priority queue.
func (*PageQueues[P, O]) MoveToPagerBackedDirty ¶
func (pq *PageQueues[P, O]) MoveToPagerBackedDirty(page P)
MoveToPagerBackedDirty moves a page to the dirty queue.
func (*PageQueues[P, O]) MoveToReclaim ¶
func (pq *PageQueues[P, O]) MoveToReclaim(page P)
MoveToReclaim moves a page to the newest reclaim queue.
func (*PageQueues[P, O]) MoveToReclaimDontNeed ¶
func (pq *PageQueues[P, O]) MoveToReclaimDontNeed(page P)
MoveToReclaimDontNeed moves a page to the tail of the don't-need isolate queue, which is reclaimed first.
func (*PageQueues[P, O]) MoveToWired ¶
func (pq *PageQueues[P, O]) MoveToWired(page P)
MoveToWired moves a page to the wired queue.
func (*PageQueues[P, O]) Pages ¶
func (pq *PageQueues[P, O]) Pages() iter.Seq[P]
Pages walks every queued page, in no particular order. It is not Zircon's either: the pager's stats count the pages it holds by it.
func (*PageQueues[P, O]) PeekAnonymousZeroForkWhere ¶
func (pq *PageQueues[P, O]) PeekAnonymousZeroForkWhere(accept func(P) bool) (VmoBacklink[P, O], bool)
PeekAnonymousZeroForkWhere is the first page of the zero fork queue that accept takes, in the order PopAnonymousZeroFork takes them: the page put there first comes first. Unlike the pop, it leaves the page in the queue.
func (*PageQueues[P, O]) PeekDontNeedWhere ¶
func (pq *PageQueues[P, O]) PeekDontNeedWhere(accept func(P) bool) (VmoBacklink[P, O], bool)
PeekDontNeedWhere is the first page of the don't-need isolate queue that accept takes, in the order a peek takes them: the page put there first comes first.
func (*PageQueues[P, O]) PeekIsolate ¶
func (pq *PageQueues[P, O]) PeekIsolate(lowestQueue uint64) (VmoBacklink[P, O], bool)
PeekIsolate is the first page of the isolate queues. If they are empty it isolates pages from the LRU queues up to lowestQueue generations from the newest, never from the active queues. The page stays where it is.
func (*PageQueues[P, O]) PeekIsolateWhere ¶
func (pq *PageQueues[P, O]) PeekIsolateWhere(lowestQueue uint64, accept func(P) bool) (VmoBacklink[P, O], bool)
PeekIsolateWhere is PeekIsolate for the first page accept takes. Where no isolated page is taken, it isolates every page older than lowestQueue at once, rather than a batch at a time, since accept may pass over many, and looks again.
A lowestQueue below NumActiveQueues takes the pages of the active queues too, which PeekIsolate never does. Zircon's aging thread makes those pages inactive while an eviction waits. Aging here is driven by faults only (decision 4 of the plan), and a fault may be waiting for the eviction. So the peek ages the queues itself until the active pages it may take are inactive. Aging moves every page by one queue, so the order pages are taken in does not change.
func (*PageQueues[P, O]) PeekUnharvestedWhere ¶
func (pq *PageQueues[P, O]) PeekUnharvestedWhere(n int, accept func(P) bool) []VmoBacklink[P, O]
PeekUnharvestedWhere is not Zircon's. It is up to n pages of the standard isolate queue that accept takes, the oldest first, for the evictor to harvest: it takes their mappings away, keeps their bytes, and moves each one still isolated to the harvested queue with MoveToHarvested. The inactive pages of the LRU queues are isolated first, as a peek isolates them, so the active queues' pages, which faults touched last, are never harvested. The pages stay where they are.
It stands in for the accessed-bit harvest that Zircon's aging waits for. Zircon reads the accessed bits of a page's mappings and moves an accessed page out of the LRU queue before the page is isolated. The pager cannot read them, so it takes the mappings away instead, and the fault the guest's next touch takes is the accessed bit: the fault marks the page accessed, which moves it out of the isolate queues. A harvested page the evictor reaches still isolated was not touched since, as a page whose bit was clear.
func (*PageQueues[P, O]) PopAnonymousZeroFork ¶
func (pq *PageQueues[P, O]) PopAnonymousZeroFork() (VmoBacklink[P, O], bool)
PopAnonymousZeroFork moves the oldest page of the zero fork queue to the anonymous queue and returns its backlink, if the queue has a page.
func (*PageQueues[P, O]) QueueCounts ¶
func (pq *PageQueues[P, O]) QueueCounts() Counts
QueueCounts are the pages in each queue, the reclaim queues by age.
func (*PageQueues[P, O]) ReclaimIsOnlyPagerBacked ¶
func (pq *PageQueues[P, O]) ReclaimIsOnlyPagerBacked() bool
ReclaimIsOnlyPagerBacked reports whether the reclaim queues hold only pages a pager backs.
func (*PageQueues[P, O]) Remove ¶
func (pq *PageQueues[P, O]) Remove(page P)
Remove takes a page out of the queues and clears its backlink.
func (*PageQueues[P, O]) RemoveArrayIntoList ¶
func (pq *PageQueues[P, O]) RemoveArrayIntoList(pages []P, out *[]P)
RemoveArrayIntoList is Remove for every page, each then appended to out, Zircon's out_list.
func (*PageQueues[P, O]) RotateReclaimQueues ¶
func (pq *PageQueues[P, O]) RotateReclaimQueues()
RotateReclaimQueues ages every reclaimable page by one queue, processing the LRU queue first if the MRU generation cannot advance. Zircon calls it for tests and debugging. It ignores DisableAging.
func (*PageQueues[P, O]) SecondChances ¶
func (pq *PageQueues[P, O]) SecondChances() uint64
SecondChances is how many harvested pages a fault marked accessed, and so moved out of the isolate queues before the evictor took them. It is not Zircon's.
func (*PageQueues[P, O]) SetActiveRatioMultiplier ¶
func (pq *PageQueues[P, O]) SetActiveRatioMultiplier(multiplier uint32)
SetActiveRatioMultiplier sets the active ratio multiplier.
func (*PageQueues[P, O]) SetAnonymous ¶
func (pq *PageQueues[P, O]) SetAnonymous(page P, object O, pageOffset uint64, skipReclaim bool)
SetAnonymous puts a new anonymous page in its queue. skipReclaim keeps it out of the reclaim queues even if anonymous pages are reclaimable.
func (*PageQueues[P, O]) SetAnonymousZeroFork ¶
func (pq *PageQueues[P, O]) SetAnonymousZeroFork(page P, object O, pageOffset uint64)
SetAnonymousZeroFork puts a new zero fork in its queue.
func (*PageQueues[P, O]) SetHighPriority ¶
func (pq *PageQueues[P, O]) SetHighPriority(page P, object O, pageOffset uint64)
SetHighPriority puts a new page in the high priority queue.
func (*PageQueues[P, O]) SetPagerBackedDirty ¶
func (pq *PageQueues[P, O]) SetPagerBackedDirty(page P, object O, pageOffset uint64)
SetPagerBackedDirty puts a new dirty page in the dirty queue.
func (*PageQueues[P, O]) SetReclaim ¶
func (pq *PageQueues[P, O]) SetReclaim(page P, object O, pageOffset uint64)
SetReclaim puts a new page a pager backs in the newest reclaim queue.
func (*PageQueues[P, O]) SetWired ¶
func (pq *PageQueues[P, O]) SetWired(page P, object O, pageOffset uint64)
SetWired puts a new page of object in the wired queue.
type PageRequest ¶
type PageRequest struct {
// contains filtered or unexported fields
}
PageRequest is a request for pages a lookup waits on, Zircon's PageRequest.
func NewPageRequest ¶
func NewPageRequest() *PageRequest
NewPageRequest is a request not yet in use.
func (*PageRequest) CancelRequest ¶
func (r *PageRequest) CancelRequest()
CancelRequest withdraws the request if it is in use.
type PageRequestType ¶
type PageRequestType uint8
PageRequestType is page_request_type.
const ( // ReadRequest asks for a page's initial contents. ReadRequest PageRequestType = iota // DirtyRequest asks to make a clean page dirty. DirtyRequest // WritebackRequest asks to write a page back. WritebackRequest )
func RequestType ¶
func RequestType(request *PageRequest) PageRequestType
RequestType is the type of a request the provider owns.
type PageSource ¶
type PageSource struct {
// contains filtered or unexported fields
}
PageSource is the source of an object's pages, Zircon's PageSource: it turns a lookup's need for pages into requests to its provider and wakes the requests a supply or a failure resolves.
func NewPageSource ¶
func NewPageSource(provider PageProvider) *PageSource
NewPageSource is a source over provider.
func RequestSource ¶
func RequestSource(request *PageRequest) *PageSource
RequestSource is the source a request in use was made on, whether it was sent or waits on another's.
func (*PageSource) AppendOutstanding ¶
func (s *PageSource) AppendOutstanding(dst []RequestRange, typ PageRequestType, start, end uint64) []RequestRange
AppendOutstanding appends to dst the range of each outstanding request of typ that overlaps [start, end), in order, and returns the result.
Departure: Zircon's callers never look at the outstanding requests. A lookup sends its request and waits, and the user pager in another process answers it. Here the pager is in the callers' process, and a caller that reads pages itself asks first which of them a request already sent is reading, to wait on that request or to leave those pages to it.
func (*PageSource) Close ¶
func (s *PageSource) Close()
Close detaches the source and tells the provider it is closed.
func (*PageSource) DebugIsPageOk ¶
func (s *PageSource) DebugIsPageOk(page *VmPage, offset uint64) bool
DebugIsPageOk checks a page the source supplied.
func (*PageSource) Detach ¶
func (s *PageSource) Detach()
Detach cancels every outstanding request but writebacks, and tells the provider.
func (*PageSource) GetPages ¶
func (s *PageSource) GetPages(offset, length uint64, request *PageRequest) error
GetPages asks for [offset, offset+len) to be supplied and returns ErrShouldWait with request to wait on.
func (*PageSource) IsDetached ¶
func (s *PageSource) IsDetached() bool
IsDetached reports whether the source is detached from its provider.
func (*PageSource) OnPagesDirtied ¶
func (s *PageSource) OnPagesDirtied(offset, length uint64)
OnPagesDirtied resolves the dirty requests [offset, offset+len) covers.
func (*PageSource) OnPagesFailed ¶
func (s *PageSource) OnPagesFailed(offset, length uint64, status error)
OnPagesFailed fails every request [offset, offset+len) covers with status.
func (*PageSource) OnPagesSupplied ¶
func (s *PageSource) OnPagesSupplied(offset, length uint64)
OnPagesSupplied resolves the read requests [offset, offset+len) covers.
func (*PageSource) Properties ¶
func (s *PageSource) Properties() PageSourceProperties
Properties are the provider's properties.
func (*PageSource) RequestDirtyTransition ¶
func (s *PageSource) RequestDirtyTransition(request *PageRequest, offset, length uint64) error
RequestDirtyTransition asks for [offset, offset+len) to be made dirty and returns ErrShouldWait with request to wait on.
func (*PageSource) SendPages ¶
func (s *PageSource) SendPages(offset, length uint64, request *PageRequest) (sent bool, sentLen uint64, err error)
SendPages is GetPages reporting, as the source's lock held them, whether the request went to the provider and how much of the range it asks for.
Departure: Zircon's caller waits on its request and never looks at it. Here the caller answers a request it sent itself, and asks what it sent. It cannot ask after: once the lock goes, a supply of the range may complete the request, and its state is no longer the caller's to read.
func (*PageSource) ShouldTrapDirtyTransitions ¶
func (s *PageSource) ShouldTrapDirtyTransitions() bool
ShouldTrapDirtyTransitions reports whether a clean page must be asked for before it becomes dirty.
func (*PageSource) SupportsPageRequestType ¶
func (s *PageSource) SupportsPageRequestType(typ PageRequestType) bool
SupportsPageRequestType reports whether the provider answers requests of typ.
type PageSourceProperties ¶
type PageSourceProperties struct {
// IsUserPager says the provider is a user pager: it preserves content,
// supplies pages and tracks them dirty.
IsUserPager bool
// SupportsRequestType says which requests the provider answers.
SupportsRequestType [numPageRequestTypes]bool
}
PageSourceProperties are a provider's properties.
type PageSourceType ¶
type PageSourceType uint8
PageSourceType is what directly backs an object.
const ( // Anonymous is an object no page source backs. Anonymous PageSourceType = iota // Contiguous is an object a contiguous page source backs. Not ported: // kept so the type reads as Zircon's. Contiguous // UserPager is an object a user pager backs, which tracks dirty pages. UserPager )
type PageSpliceList ¶
type PageSpliceList[P any] struct { // contains filtered or unexported fields }
PageSpliceList holds the content taken from a range of a page list, gaps and markers included: Zircon's VmPageSpliceList. Every splice list goes through these states:
- It is made.
- Initialize gives it its range.
- Pages are added to it.
- Finalize ends the adding.
- Pages are popped from it. Once all are, it is processed.
- Processed, it can be dropped.
Zircon's CreateFromPageList, which only its PhysicalPageProvider uses, is not ported: physical memory is not.
func NewPageSpliceList ¶
func NewPageSpliceList[P any](pageSize uint64, freer Freer[P]) *PageSpliceList[P]
NewPageSpliceList is a splice list over pages of pageSize bytes, which gives back what it still owns through freer when it is freed.
func (*PageSpliceList[P]) AddPagesFrom ¶
func (s *PageSpliceList[P]) AddPagesFrom(merge func(src, dst *PageOrMarker[P], offset uint64), source *PageList[P], offset uint64)
AddPagesFrom takes the content of source from offset, for the list's length, into the list, which must be initialized and empty, and finalizes it. merge moves content from src to dst. Zircon returns ZX_ERR_NO_MEMORY when it cannot allocate a node, having moved some pages; a Go allocation does not fail, so this returns nothing.
func (*PageSpliceList[P]) Finalize ¶
func (s *PageSpliceList[P]) Finalize()
Finalize ends the adding of pages. It is called once, on an initialized list.
func (*PageSpliceList[P]) Free ¶
func (s *PageSpliceList[P]) Free()
Free is the splice list's destructor: it gives back every page and reference the list still holds. Go has no destructors, so the owner calls it.
func (*PageSpliceList[P]) Initialize ¶
func (s *PageSpliceList[P]) Initialize(length uint64)
Initialize gives the list its range, once, before any page is added.
func (*PageSpliceList[P]) Insert ¶
func (s *PageSpliceList[P]) Insert(offset uint64, content PageOrMarker[P]) error
Insert puts content in the list at offset. The list owns it from then on, and must not be finalized.
func (*PageSpliceList[P]) IsEmpty ¶
func (s *PageSpliceList[P]) IsEmpty() bool
IsEmpty reports whether the list holds nothing.
func (*PageSpliceList[P]) IsFinalized ¶
func (s *PageSpliceList[P]) IsFinalized() bool
IsFinalized reports whether the list is finalized and not yet processed.
func (*PageSpliceList[P]) IsInitialized ¶
func (s *PageSpliceList[P]) IsInitialized() bool
IsInitialized reports whether the list has its range and is not finalized.
func (*PageSpliceList[P]) IsProcessed ¶
func (s *PageSpliceList[P]) IsProcessed() bool
IsProcessed reports whether every slot has been popped or walked.
func (*PageSpliceList[P]) MutatePages ¶
func (s *PageSpliceList[P]) MutatePages(fn func(slot PageOrMarkerRef[P], offset uint64) error, start uint64) error
MutatePages calls fn on every slot from start to the end of the list without taking its content. The slots are not processed by it and cannot be removed. start is page rounded and below the list's length.
func (*PageSpliceList[P]) Pop ¶
func (s *PageSpliceList[P]) Pop() PageOrMarker[P]
Pop takes the next slot's content off the list, which must be finalized.
func (*PageSpliceList[P]) Position ¶
func (s *PageSpliceList[P]) Position() uint64
Position is where the list is in its range.
func (*PageSpliceList[P]) RemovePagesAndIterateGaps ¶
func (s *PageSpliceList[P]) RemovePagesAndIterateGaps(pageFn func(content PageOrMarker[P], offset uint64) error, gapFn func(start, end uint64) error) error
RemovePagesAndIterateGaps walks the list's pages and gaps from where the last walk stopped, and hands each page's content to pageFn, which owns it from then on. The list must be finalized. pageFn owns the content whatever it returns, so a slot it stops on, with ErrStop or an error, is processed and is not walked again. A gap gapFn stops on is not processed and comes back on the next walk.
func (*PageSpliceList[P]) Reuse ¶
func (s *PageSpliceList[P]) Reuse()
Reuse makes a processed list ready to be initialized again, keeping what its page list allocated. Zircon's splice lists are objects on the stack of the call that splices; a Go list is a heap object, and a pager that supplies a page per fault keeps its lists for the next supply rather than make one each time.
type PagerProxy ¶
type PagerProxy struct {
// contains filtered or unexported fields
}
PagerProxy is the provider of a page source whose pager is in this process, Zircon's PagerProxy.
Zircon's PagerProxy hands each request the source sends it to the user pager as a packet on a port. It has one packet, so it queues the requests that come while the packet is out, and sends the next when the pager has read it. The pager reads the port on threads of its own, reads the pages, and supplies or fails their range on the VMO.
Departure: no port and no packet. The pager here is in the process that makes the requests, and the caller that sent a request answers it: a fault or a prefetch reads the pages on a goroutine, its own or one it starts, and supplies or fails the request's range on the source. So every request is answered at once, on a goroutine of its own, where Zircon's are answered one packet at a time. What is kept is the proxy's account of the requests the source has handed it and not taken back, which tells a caller whether its request was sent or waits on another (Holds), and the counts of the waits on its requests. The overtime warnings, the dump, the koid and the dispatcher's close are not ported: a wait here ends with its context.
func NewPagerProxy ¶
func NewPagerProxy(trapDirty bool) *PagerProxy
NewPagerProxy is a proxy for a pager that answers read requests, and dirty requests too where trapDirty says so: Zircon's kTrapDirty option.
func (*PagerProxy) ClearAsyncRequest ¶
func (p *PagerProxy) ClearAsyncRequest(request *PageRequest)
ClearAsyncRequest gives a request back to the source.
func (*PagerProxy) DebugIsPageOk ¶
func (p *PagerProxy) DebugIsPageOk(*VmPage, uint64) bool
DebugIsPageOk accepts every page, as Zircon's does.
func (*PagerProxy) Holds ¶
func (p *PagerProxy) Holds(request *PageRequest) bool
Holds reports whether the source has sent request and not taken it back: whether its caller is the one to answer it, rather than one waiting on another's.
func (*PagerProxy) OnClose ¶
func (p *PagerProxy) OnClose()
OnClose notes that the source has closed.
func (*PagerProxy) OnDetach ¶
func (p *PagerProxy) OnDetach()
OnDetach notes that the source has detached and sends nothing more but writebacks. Zircon queues the COMPLETE packet here.
func (*PagerProxy) Properties ¶
func (p *PagerProxy) Properties() PageSourceProperties
Properties are a user pager's.
func (*PagerProxy) SendAsyncRequest ¶
func (p *PagerProxy) SendAsyncRequest(request *PageRequest)
SendAsyncRequest takes a request the source sends. Zircon queues its packet; here the caller that made it answers it.
func (*PagerProxy) SwapAsyncRequest ¶
func (p *PagerProxy) SwapAsyncRequest(old, newReq *PageRequest)
SwapAsyncRequest holds newReq where it held old.
func (*PagerProxy) WaitOnEvent ¶
func (p *PagerProxy) WaitOnEvent(ctx context.Context, event *Event) error
WaitOnEvent waits for a request's event, counting the wait as Zircon's kcounters do: every wait, those that end with the request supplied, and those that end otherwise.
func (*PagerProxy) Waits ¶
func (p *PagerProxy) Waits() PagerWaits
Waits counts the waits on this proxy's requests.
type PagerWaits ¶
type PagerWaits struct{ Total, Succeeded, Failed uint64 }
PagerWaits counts the waits on a proxy's requests: Zircon's dispatcher.pager.total_requests, succeeded_requests and failed_requests.
type Pmm ¶
type Pmm interface {
// AllocPage is a new page of the pmm's page size, whose bytes are any.
// Zircon's can fail with ZX_ERR_NO_MEMORY or ask the caller to wait with
// ZX_ERR_SHOULD_WAIT; an error here fails the operation that needed it.
AllocPage() (*VmPage, error)
// FreePage gives a page back. It is in no page queue and no object.
FreePage(*VmPage)
// ZeroPage is the one page of zeros every object reads where it holds
// zeros. It is never written and never freed.
ZeroPage() *VmPage
// CountFreePages is how many pages are free, pmm_count_free_pages, which
// an evictor's free target is measured against.
CountFreePages() uint64
}
Pmm is the physical memory manager an object allocates its pages from and frees them to, Zircon's pmm_alloc_page, pmm_free_page and vm_get_zero_page. The pager's arena takes its place (plan: Arena and residency), so here it is an interface.
type QueueObject ¶
type QueueObject interface {
comparable
// CanEvict is VmCowPages::can_evict: whether the object's pages are a
// pager's, which are evicted rather than compressed.
CanEvict() bool
}
QueueObject is what a queued page's backlink names, a VmCowPages in Zircon, where it is a void*.
type QueuedPage ¶
type QueuedPage[P any, O QueueObject] interface { comparable QueueNode() *PageQueueNode[P, O] }
QueuedPage is a page the queues can hold.
type RangeChangeOp ¶
type RangeChangeOp uint8
RangeChangeOp is what a range change does to the mappings it reaches, VmObject::RangeChangeOp.
const ( // Unmap removes the mappings. Unmap RangeChangeOp = iota // UnmapZeroPage removes mappings the caller knows are all of the zero // page. UnmapZeroPage // UnmapAndHarvest removes the mappings and harvests their accessed // bits. A userfaultfd pager cannot read the VMM's accessed bits // (decision 4), so a mapping harvests nothing here: the pager's evictor // harvests by removing the mappings of a page it keeps, and the fault // after is the bit (PageQueues.PeekUnharvestedWhere). UnmapAndHarvest // RemoveWrite makes the mappings read-only. RemoveWrite )
type ReclaimAttempt ¶
type ReclaimAttempt struct {
// Success is what was reclaimed when Failure is ReclaimSucceeded.
Success ReclaimSuccess
Failure ReclaimFailure
// Page is the page reclamation was attempted on, which the evictor
// compares with the page before it to find a reclaim that does not move
// its page. A fake leaves it nil.
Page any
}
ReclaimAttempt is one step of reclamation: how it went and the page it was attempted on. It is Zircon's pair of a VmCowReclaimResult and its page.
type ReclaimCounts ¶
type ReclaimCounts struct{ Total, Newest, Oldest int }
ReclaimCounts are the reclaimable pages, the newest and the oldest of them, Zircon's PageQueues::ReclaimCounts.
type ReclaimFailure ¶
type ReclaimFailure uint8
ReclaimFailure is VmCowReclaimFailure: why a reclamation failed.
const ( // ReclaimSucceeded is no failure. ReclaimSucceeded ReclaimFailure = iota // EvictAccessed is an eviction of pages that were not reclaimable. EvictAccessed // CompressAccessed is a compression of a page accessed meanwhile. CompressAccessed // CompressFailedReclaim is a compression that failed. CompressFailedReclaim // IncorrectPage is a page not at the offset given. IncorrectPage // ReclaimOther is any other failure. ReclaimOther )
type ReclaimFunction ¶
type ReclaimFunction[R any] func(ctx context.Context, request R, compress bool, level EvictionLevel) (ReclaimAttempt, bool, error)
ReclaimFunction is one step of reclamation for request: it reports the attempt, or false when there is nothing left to try. compress says whether the step may compress. Zircon's is a test's fake; the evictor of a Node reclaims from the node's page queues, and the pager supplies its own.
type ReclaimSuccess ¶
type ReclaimSuccess struct {
Type ReclaimType
NumPages uint64
}
ReclaimSuccess is VmCowReclaimSuccess: how a reclamation succeeded.
type ReclaimType ¶
type ReclaimType uint8
ReclaimType is how pages were reclaimed.
const ( // ReclaimEvict dropped clean pages a pager can supply again. ReclaimEvict ReclaimType = iota // ReclaimCompress compressed a page. ReclaimCompress )
type ReferenceValue ¶
type ReferenceValue struct {
// contains filtered or unexported fields
}
ReferenceValue is a reference to content held elsewhere, Zircon's VmPageOrMarker::ReferenceValue. Its low ReferenceAlignBits bits are zero, so a slot can keep its type there.
func MakeReferenceValue ¶
func MakeReferenceValue(raw uint32) ReferenceValue
MakeReferenceValue makes a reference from its value, which must be aligned.
func (ReferenceValue) Value ¶
func (r ReferenceValue) Value() uint32
Value is the reference's value.
type RequestRange ¶
type RequestRange struct{ Offset, Len uint64 }
RequestRange is the range an outstanding request asks for.
type RequireResult ¶
RequireResult is a page a Require method returns, and whether it may be written.
type RootResolver ¶
type RootResolver interface {
Locate(offset uint64) (root *CowPages, rootOffset uint64, ok bool)
Holds(root *CowPages, rootOffset uint64) bool
}
RootResolver names the identity root that holds the content of an offset of a region's layer, and the offset in it. It is the departure that replaces Zircon's walk up the parent chain for a region's layer: a region's content is a mosaic of many checkpoints, which no chain of parents describes, so Locate names the identity and the identity the root (plan: Zircon's objects and ours). ok is false where no root holds the content, and the region's own page source is asked.
Locate looks at the root under the root's lock and lets it go, and the lookup locks the root again to go down into it. A root may give the page up in between, and a lookup that went on down would ask the root's page source for it. So the lookup asks Holds, with the root's lock held, and falls through to the root only where it still holds the page; otherwise the region's own page source is asked, as where no root held it.
type SentinelType ¶
type SentinelType uint32
SentinelType is which end of a sparse interval a slot is.
const ( // SentinelSlot is an interval of a single page. SentinelSlot SentinelType = iota // SentinelStart is the first page of an interval of several. SentinelStart // SentinelEnd is the last page of an interval of several. SentinelEnd )
type SnapshotType ¶
type SnapshotType uint8
SnapshotType is the kind of clone, Zircon's SnapshotType.
const ( // SnapshotFull is a snapshot of everything, which needs a hidden parent // in Zircon. Not ported: CreateCloneLocked refuses it. SnapshotFull SnapshotType = iota // SnapshotModified snapshots what the object modified of its parent's // content. Of an object with no parent it is a snapshot-on-write child; // of one with a parent it needs a hidden parent, and is refused. SnapshotModified // SnapshotOnWrite reads the parent until the child writes, and then // copies. It is the one kind the port takes (plan: Fork sharing). SnapshotOnWrite )
type SpillStorage ¶
type SpillStorage[K comparable] struct { // contains filtered or unexported fields }
SpillStorage is the spill file as compressed storage: the storage a spilled page's reference names (plans/zircon-pager-port-2026-10-05.md, "Spill and give-back"). It takes the shape of Zircon's VmSlotPageStorage: a reference is the id of an allocation record shifted past the alignment bits, and the record says where the bytes are, how long they are, and the metadata kept for the user. Zircon's ids come from a slab allocator.
What it does not take: Zircon divides a page into 64 slots and packs compressed pages into them, with a list of pages per longest free run. Pages are stored as they are here, so an allocation is one whole page of the file, at its id times the page size, and there is nothing to pack.
What stays the pager's own (the plan's "stays ours", and D5):
- The file is truncated and its whole extent allocated when the storage is made. A spilled dirty page is the only copy of what the guest wrote, so a spill must never fail for want of disk, and the space a sparse file has not used yet is free space another writer on the node can take.
- A reservation is an allocation handed out before there are bytes to put in it (D5). Allocations are handed out lowest first, and one given back is the next handed out, so state is kept only for what has been handed out: a budget of a trillion pages costs nothing until it is used.
- The bytes are checked against a CRC32C when they are read back. The file is scratch on a local device, so the authority for what it holds is here, not in the file: a page that comes back short, zeroed or holding bytes nobody wrote is a page the device lost, and it is refused, not handed to a guest as memory it never wrote.
- A published version (plans/local-writeback-2026-10-09.md, step 1). An allocation whose bytes a checkpoint published can be kept under the key it was published as, K, instead of given back: it is then no reservation, a load reads it by its key, and whenever a reservation wants an allocation and none is free, the oldest version not read since it was last passed over is dropped and its allocation handed out. So versions take only what reservations leave, and a full budget of reservations is never refused for them.
An allocation given back keeps its blocks. Punching them would give them back to the filesystem, where another writer can take them, and the next page stored there would have nowhere to go. The stale bytes are never read: an allocation holds no bytes until it is written again.
func NewSpillStorage ¶
func NewSpillStorage[K comparable](ctx context.Context, file platform.File, pageSize uint64, budget, maxVersions int) (*SpillStorage[K], error)
NewSpillStorage makes file the storage of budget pages of pageSize bytes, which keeps at most maxVersions published versions: whatever the file held is dropped, since the spill is scratch, and its whole extent is allocated. The file must be a platform.AllocatingFile. A budget beyond MaxSpillPages, or below one, is ErrOutOfRange.
func (*SpillStorage[K]) Available ¶
func (s *SpillStorage[K]) Available() int
Available is how many more allocations may be handed out, a published version's among them.
func (*SpillStorage[K]) CompressedData ¶
func (s *SpillStorage[K]) CompressedData(ctx context.Context, ref ReferenceValue, dst []byte) (int, uint32, error)
CompressedData reads the bytes ref holds into dst and returns their length and its metadata. Bytes that do not match the checksum they were written with are ErrIODataIntegrity: the device lost them. An allocation that holds none is ErrBadState.
func (*SpillStorage[K]) Free ¶
func (s *SpillStorage[K]) Free(ref ReferenceValue)
Free gives ref back, holding nothing.
func (*SpillStorage[K]) GetMemoryUsage ¶
func (s *SpillStorage[K]) GetMemoryUsage() StorageMemoryUsage
GetMemoryUsage is what the storage holds: the pages stored, the file's extent, and the bytes stored.
func (*SpillStorage[K]) GetMetadata ¶
func (s *SpillStorage[K]) GetMetadata(ref ReferenceValue) uint32
GetMetadata is the metadata kept with ref.
func (*SpillStorage[K]) HasVersion ¶
func (s *SpillStorage[K]) HasVersion(key K) bool
HasVersion reports whether the storage keeps a published version of key.
func (*SpillStorage[K]) Holds ¶
func (s *SpillStorage[K]) Holds(ref ReferenceValue) bool
Holds reports whether ref holds bytes.
func (*SpillStorage[K]) Publish ¶
func (s *SpillStorage[K]) Publish(ref ReferenceValue, key K) bool
Publish keeps the bytes ref holds as the published version key names, instead of giving ref back. The allocation is a reservation no more, and ref names nothing from here. Where ref holds no bytes, key has a version already, or no version may be kept, it is given back as Free gives it, and Publish reports false.
func (*SpillStorage[K]) ReadVersion ¶
ReadVersion reads the published version key names into dst, a page, and reports whether there is one. The read holds no lock, so a version dropped while it is read, whose allocation may be another page's by the time the read ends, is a miss: the version must still be the same one once the read is over, and nothing hands its allocation out before it is dropped. A version whose bytes do not match their checksum is dropped, and the error is ErrIODataIntegrity: the device lost it, and the store still has it.
func (*SpillStorage[K]) Release ¶
func (s *SpillStorage[K]) Release(ctx context.Context) error
Release gives the file's space back once nothing will be stored again: it truncates the file, and every allocation holds nothing from then on, a published version's included.
func (*SpillStorage[K]) Reserve ¶
func (s *SpillStorage[K]) Reserve() (ReferenceValue, bool)
Reserve hands out an allocation that holds nothing, or reports false where the budget has none left (D5). With none free, it drops the oldest published version for its allocation.
func (*SpillStorage[K]) SetMetadata ¶
func (s *SpillStorage[K]) SetMetadata(ref ReferenceValue, metadata uint32)
SetMetadata sets the metadata kept with ref.
func (*SpillStorage[K]) Store ¶
func (s *SpillStorage[K]) Store(ctx context.Context, data []byte) (ReferenceValue, error)
Store keeps data in a new allocation, as Zircon's Store does: it fails with ErrNoSpace where the budget has none left.
func (*SpillStorage[K]) StoreReserved ¶
func (s *SpillStorage[K]) StoreReserved(ctx context.Context, refs []ReferenceValue, data []byte) (int, error)
StoreReserved writes the bytes of refs, which are in ascending order, one page apart in data; only the last may be shorter than a page. Each run of consecutive allocations is one write, and it returns how many writes it took. The allocations are recorded as holding their bytes first, as the writes need no lock (D5). Nothing here needs room: the extent is the file's already.
func (*SpillStorage[K]) Unstore ¶
func (s *SpillStorage[K]) Unstore(ref ReferenceValue)
Unstore drops the bytes ref holds, and keeps ref handed out (D5).
func (*SpillStorage[K]) Versions ¶
func (s *SpillStorage[K]) Versions() int
Versions is how many published versions the storage keeps.
func (*SpillStorage[K]) WriteVersion ¶
WriteVersion keeps data, a page, as the published version of key, in an allocation no reservation holds: a free one, one never handed out, or the oldest version's. It reports false, and writes nothing, where key has a version already, none may be kept, or every allocation is a reservation or another write's. The allocation is the write's alone until the write ends, so a caller that bounds its writes in flight and admits reservations against a budget that many allocations short of the storage's never finds a reservation refused for one.
type StorageMemoryUsage ¶
type StorageMemoryUsage struct {
// UncompressedContentBytes is the pages stored, in bytes.
UncompressedContentBytes uint64
// CompressedStorageBytes is what the storage takes to hold them.
CompressedStorageBytes uint64
// CompressedStorageUsedBytes is the bytes stored.
CompressedStorageUsedBytes uint64
}
StorageMemoryUsage is VmCompressedStorage::MemoryUsage.
type StoreAsIs ¶
type StoreAsIs struct{}
StoreAsIs is the strategy of the spill: a page is stored as it is, and a page of zeros is found, as Zircon's LZ4 strategy finds one. It takes the place of LZ4, which is not ported.
func (StoreAsIs) Compress ¶
func (StoreAsIs) Compress(src, dst []byte, limit uint64) StrategyResult
Compress copies src to dst, or reports zeros, or fails where src does not fit within limit.
func (StoreAsIs) Decompress ¶
Decompress copies src to dst.
type StrategyResult ¶
type StrategyResult struct {
Kind CompressKind
Size uint64
}
StrategyResult is what a CompressionStrategy made of a page: a length, or one of Zircon's ZeroTag and FailTag.
type SupplyOptions ¶
type SupplyOptions uint8
SupplyOptions is how pages are supplied, Zircon's SupplyOptions.
const ( // PagerSupply fills only offsets with no content, as a pager answers a // read. PagerSupply SupplyOptions = iota // TransferData overwrites whatever is there. TransferData )
type TriggerReason ¶
type TriggerReason bool
TriggerReason is why an eviction was asked for.
const ( // OOM is an eviction for an out of memory condition, which is not capped // and is counted on its own. OOM TriggerReason = true // Other is any other eviction. Other TriggerReason = false )
type VmPage ¶
type VmPage struct {
// PageQueueNode is the page's queue_node, its backlink (object and
// pageOffset) and its queue (pageQueue). See pagequeues.go.
PageQueueNode[*VmPage, *CowPages]
// Frame is where the page's bytes are, for a Pmm whose pages are not
// this process's memory: Zircon's paddr. The pager's pages are slots of
// arena files, which the guest maps (plan: Arena and residency), so its
// Pmm names the slot here and keeps no bytes in data. Nothing in this
// package looks inside it.
Frame any
// contains filtered or unexported fields
}
VmPage is a page of memory that an object holds, Zircon's vm_page_t in its OBJECT state: the fields VmCowPages and the page queues keep in it.
Zircon reaches a page's bytes through the physmap at its physical address. The pager's pages are slots of memfds (plan: Arena and residency), so here a page carries its bytes, which the Pmm that made it hands out.
func NewFramePage ¶
NewFramePage is a page whose bytes are at frame, which the Pmm that makes it names and reads. Such a page has no bytes in this process, so nothing may copy, zero or compress it here: the Pmm's owner moves its bytes itself.
func (*VmPage) DebugReservation ¶
func (p *VmPage) DebugReservation() (ReferenceValue, bool)
DebugReservation is the page's reservation, and whether it holds one.
type VmPageQueues ¶
type VmPageQueues = PageQueues[*VmPage, *CowPages]
VmPageQueues are the page queues of a Node's pages.
type VmoBacklink ¶
type VmoBacklink[P any, O QueueObject] struct { Cow O Page P Offset uint64 }
VmoBacklink is a page with the object and offset it was found at, which the caller must check again under the object's lock.