mm

package
v0.0.0-...-957f62e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2023 License: Apache-2.0, MIT Imports: 28 Imported by: 0

Documentation

Overview

Package mm provides a memory management subsystem. See README.md for a detailed overview.

Lock order:

 fs locks, except for memmap.Mappable locks
	mm.MemoryManager.metadataMu
		mm.MemoryManager.mappingMu
			Locks taken by memmap.MappingIdentity and memmap.Mappable methods other
			than Translate
				kernel.TaskSet.mu
					mm.MemoryManager.activeMu
						Locks taken by memmap.Mappable.Translate
							mm.privateRefs.mu
								platform.AddressSpace locks
									memmap.File locks
				mm.aioManager.mu
					mm.AIOContext.mu

Only mm.MemoryManager.Fork is permitted to lock mm.MemoryManager.activeMu in multiple mm.MemoryManagers, as it does so in a well-defined order (forked child first).

Index

Constants

View Source
const SpecialMappableenableLogging = false

enableLogging indicates whether reference-related events should be logged (with stack traces). This is false by default and should only be set to true for debugging purposes, as it can generate an extremely large amount of output and drastically degrade performance.

Variables

This section is empty.

Functions

func Unpin

func Unpin(prs []PinnedRange)

Unpin releases the reference held by prs.

Types

type AIOContext

type AIOContext struct {
	// contains filtered or unexported fields
}

AIOContext is a single asynchronous I/O context.

+stateify savable

func (*AIOContext) CancelPendingRequest

func (ctx *AIOContext) CancelPendingRequest()

CancelPendingRequest forgets about a request that hasn't yet completed.

func (*AIOContext) Dead

func (ctx *AIOContext) Dead() bool

Dead returns true if the context has been destroyed.

func (*AIOContext) Drain

func (ctx *AIOContext) Drain()

Drain drops all completed requests. Pending requests remain untouched.

func (*AIOContext) FinishRequest

func (ctx *AIOContext) FinishRequest(data any)

FinishRequest finishes a pending request. It queues up the data and notifies listeners.

func (*AIOContext) PopRequest

func (ctx *AIOContext) PopRequest() (any, bool)

PopRequest pops a completed request if available, this function does not do any blocking. Returns false if no request is available.

func (*AIOContext) Prepare

func (ctx *AIOContext) Prepare() error

Prepare reserves space for a new request, returning nil if available. Returns EAGAIN if the context is busy and EINVAL if the context is dead.

func (*AIOContext) StateFields

func (ctx *AIOContext) StateFields() []string

func (*AIOContext) StateLoad

func (ctx *AIOContext) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*AIOContext) StateSave

func (ctx *AIOContext) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*AIOContext) StateTypeName

func (ctx *AIOContext) StateTypeName() string

func (*AIOContext) WaitChannel

func (ctx *AIOContext) WaitChannel() chan struct{}

WaitChannel returns a channel that is notified when an AIO request is completed. Returns nil if the context is destroyed and there are no more outstanding requests.

type Dumpability

type Dumpability int

Dumpability describes if and how core dumps should be created.

const (
	// NotDumpable indicates that core dumps should never be created.
	NotDumpable Dumpability = iota

	// UserDumpable indicates that core dumps should be created, owned by
	// the current user.
	UserDumpable

	// RootDumpable indicates that core dumps should be created, owned by
	// root.
	RootDumpable
)

type MLockAllOpts

type MLockAllOpts struct {
	// If Current is true, change the memory-locking behavior of all mappings
	// to Mode. If Future is true, upgrade the memory-locking behavior of all
	// future mappings to Mode. At least one of Current or Future must be true.
	Current bool
	Future  bool
	Mode    memmap.MLockMode
}

MLockAllOpts holds options to MLockAll.

type MRemapMoveMode

type MRemapMoveMode int

MRemapMoveMode controls MRemap's moving behavior.

const (
	// MRemapNoMove prevents MRemap from moving the remapped mapping.
	MRemapNoMove MRemapMoveMode = iota

	// MRemapMayMove allows MRemap to move the remapped mapping.
	MRemapMayMove

	// MRemapMustMove requires MRemap to move the remapped mapping to
	// MRemapOpts.NewAddr, replacing any existing mappings in the remapped
	// range.
	MRemapMustMove
)

type MRemapOpts

type MRemapOpts struct {
	// Move controls whether MRemap moves the remapped mapping to a new address.
	Move MRemapMoveMode

	// NewAddr is the new address for the remapping. NewAddr is ignored unless
	// Move is MMRemapMustMove.
	NewAddr hostarch.Addr
}

MRemapOpts specifies options to MRemap.

type MSyncOpts

type MSyncOpts struct {
	// Sync has the semantics of MS_SYNC.
	Sync bool

	// Invalidate has the semantics of MS_INVALIDATE.
	Invalidate bool
}

MSyncOpts holds options to MSync.

type MapsCallbackFunc

type MapsCallbackFunc func(start, end hostarch.Addr, permissions hostarch.AccessType, private string, offset uint64, devMajor, devMinor uint32, inode uint64, path string)

MapsCallbackFunc has all the parameters required for populating an entry of /proc/[pid]/maps.

type MemoryManager

type MemoryManager struct {
	// contains filtered or unexported fields
}

MemoryManager implements a virtual address space.

+stateify savable

func NewMemoryManager

func NewMemoryManager(p platform.Platform, mfp pgalloc.MemoryFileProvider, sleepForActivation bool) *MemoryManager

NewMemoryManager returns a new MemoryManager with no mappings and 1 user.

func (*MemoryManager) Activate

func (mm *MemoryManager) Activate(ctx context.Context) error

Activate ensures this MemoryManager has a platform.AddressSpace.

The caller must not hold any locks when calling Activate.

When this MemoryManager is no longer needed by a task, it should call Deactivate to release the reference.

func (*MemoryManager) AddressSpace

func (mm *MemoryManager) AddressSpace() platform.AddressSpace

AddressSpace returns the platform.AddressSpace bound to mm.

Preconditions: The caller must have called mm.Activate().

func (*MemoryManager) ArgvEnd

func (mm *MemoryManager) ArgvEnd() hostarch.Addr

ArgvEnd returns the end of the application argument vector.

There is no guarantee that this value is sensible w.r.t. ArgvStart.

func (*MemoryManager) ArgvStart

func (mm *MemoryManager) ArgvStart() hostarch.Addr

ArgvStart returns the start of the application argument vector.

There is no guarantee that this value is sensible w.r.t. ArgvEnd.

func (*MemoryManager) Auxv

func (mm *MemoryManager) Auxv() arch.Auxv

Auxv returns the current map of auxiliary vectors.

func (*MemoryManager) Brk

func (mm *MemoryManager) Brk(ctx context.Context, addr hostarch.Addr) (hostarch.Addr, error)

Brk implements the semantics of Linux's brk(2), except that it returns an error on failure.

func (*MemoryManager) BrkSetup

func (mm *MemoryManager) BrkSetup(ctx context.Context, addr hostarch.Addr)

BrkSetup sets mm's brk address to addr and its brk size to 0.

func (*MemoryManager) CheckIORange

func (mm *MemoryManager) CheckIORange(addr hostarch.Addr, length int64) (hostarch.AddrRange, bool)

CheckIORange is similar to hostarch.Addr.ToRange, but applies bounds checks consistent with Linux's arch/x86/include/asm/uaccess.h:access_ok().

Preconditions: length >= 0.

func (*MemoryManager) CompareAndSwapUint32

func (mm *MemoryManager) CompareAndSwapUint32(ctx context.Context, addr hostarch.Addr, old, new uint32, opts usermem.IOOpts) (uint32, error)

CompareAndSwapUint32 implements usermem.IO.CompareAndSwapUint32.

func (*MemoryManager) CopyIn

func (mm *MemoryManager) CopyIn(ctx context.Context, addr hostarch.Addr, dst []byte, opts usermem.IOOpts) (int, error)

CopyIn implements usermem.IO.CopyIn.

func (*MemoryManager) CopyInTo

func (mm *MemoryManager) CopyInTo(ctx context.Context, ars hostarch.AddrRangeSeq, dst safemem.Writer, opts usermem.IOOpts) (int64, error)

CopyInTo implements usermem.IO.CopyInTo.

func (*MemoryManager) CopyOut

func (mm *MemoryManager) CopyOut(ctx context.Context, addr hostarch.Addr, src []byte, opts usermem.IOOpts) (int, error)

CopyOut implements usermem.IO.CopyOut.

func (*MemoryManager) CopyOutFrom

func (mm *MemoryManager) CopyOutFrom(ctx context.Context, ars hostarch.AddrRangeSeq, src safemem.Reader, opts usermem.IOOpts) (int64, error)

CopyOutFrom implements usermem.IO.CopyOutFrom.

func (*MemoryManager) Deactivate

func (mm *MemoryManager) Deactivate()

Deactivate releases a reference to the MemoryManager.

func (*MemoryManager) DebugString

func (mm *MemoryManager) DebugString(ctx context.Context) string

DebugString returns a string containing information about mm for debugging.

func (*MemoryManager) DecUsers

func (mm *MemoryManager) DecUsers(ctx context.Context)

DecUsers decrements mm's user count. If the user count reaches 0, all mappings in mm are unmapped.

func (*MemoryManager) Decommit

func (mm *MemoryManager) Decommit(addr hostarch.Addr, length uint64) error

Decommit implements the semantics of Linux's madvise(MADV_DONTNEED).

func (*MemoryManager) DestroyAIOContext

func (mm *MemoryManager) DestroyAIOContext(ctx context.Context, id uint64) *AIOContext

DestroyAIOContext destroys an asynchronous I/O context. It returns the destroyed context. nil if the context does not exist.

func (*MemoryManager) DetachShm

func (mm *MemoryManager) DetachShm(ctx context.Context, addr hostarch.Addr) error

DetachShm unmaps a sysv shared memory segment.

func (*MemoryManager) Dumpability

func (mm *MemoryManager) Dumpability() Dumpability

Dumpability returns the dumpability.

func (*MemoryManager) EnableMembarrierPrivate

func (mm *MemoryManager) EnableMembarrierPrivate()

EnableMembarrierPrivate causes future calls to IsMembarrierPrivateEnabled to return true.

func (*MemoryManager) EnableMembarrierRSeq

func (mm *MemoryManager) EnableMembarrierRSeq()

EnableMembarrierRSeq causes future calls to IsMembarrierRSeqEnabled to return true.

func (*MemoryManager) EnsurePMAsExist

func (mm *MemoryManager) EnsurePMAsExist(ctx context.Context, addr hostarch.Addr, length int64, opts usermem.IOOpts) (int64, error)

EnsurePMAsExist attempts to ensure that PMAs exist for the given addr with the requested length. It returns the length to which it was able to either initialize PMAs for, or ascertain that PMAs exist for. If this length is smaller than the requested length it returns an error explaining why.

func (*MemoryManager) EnvvEnd

func (mm *MemoryManager) EnvvEnd() hostarch.Addr

EnvvEnd returns the end of the application environment vector.

There is no guarantee that this value is sensible w.r.t. EnvvStart.

func (*MemoryManager) EnvvStart

func (mm *MemoryManager) EnvvStart() hostarch.Addr

EnvvStart returns the start of the application environment vector.

There is no guarantee that this value is sensible w.r.t. EnvvEnd.

func (*MemoryManager) Executable

func (mm *MemoryManager) Executable() *vfs.FileDescription

Executable returns the executable, if available.

An additional reference will be taken in the case of a non-nil executable, which must be released by the caller.

func (*MemoryManager) FindVMAByName

func (mm *MemoryManager) FindVMAByName(ar hostarch.AddrRange, hint string) (hostarch.Addr, uint64, error)

FindVMAByName finds a vma with the specified name and returns its start address and offset.

func (*MemoryManager) Fork

func (mm *MemoryManager) Fork(ctx context.Context) (*MemoryManager, error)

Fork creates a copy of mm with 1 user, as for Linux syscalls fork() or clone() (without CLONE_VM).

func (*MemoryManager) GetSharedFutexKey

func (mm *MemoryManager) GetSharedFutexKey(ctx context.Context, addr hostarch.Addr) (futex.Key, error)

GetSharedFutexKey is used by kernel.Task.GetSharedKey.

func (*MemoryManager) HandleUserFault

func (mm *MemoryManager) HandleUserFault(ctx context.Context, addr hostarch.Addr, at hostarch.AccessType, sp hostarch.Addr) error

HandleUserFault handles an application page fault. sp is the faulting application thread's stack pointer.

Preconditions: mm.as != nil.

func (*MemoryManager) IncUsers

func (mm *MemoryManager) IncUsers() bool

IncUsers increments mm's user count and returns true. If the user count is already 0, IncUsers does nothing and returns false.

func (*MemoryManager) Invalidate

func (mm *MemoryManager) Invalidate(ar hostarch.AddrRange, opts memmap.InvalidateOpts)

Invalidate implements memmap.MappingSpace.Invalidate.

func (*MemoryManager) InvalidateUnsavable

func (mm *MemoryManager) InvalidateUnsavable(ctx context.Context) error

InvalidateUnsavable invokes memmap.Mappable.InvalidateUnsavable on all Mappables mapped by mm.

func (*MemoryManager) IsMembarrierPrivateEnabled

func (mm *MemoryManager) IsMembarrierPrivateEnabled() bool

IsMembarrierPrivateEnabled returns true if mm.EnableMembarrierPrivate() has previously been called.

func (*MemoryManager) IsMembarrierRSeqEnabled

func (mm *MemoryManager) IsMembarrierRSeqEnabled() bool

IsMembarrierRSeqEnabled returns true if mm.EnableMembarrierRSeq() has previously been called.

func (*MemoryManager) LoadUint32

func (mm *MemoryManager) LoadUint32(ctx context.Context, addr hostarch.Addr, opts usermem.IOOpts) (uint32, error)

LoadUint32 implements usermem.IO.LoadUint32.

func (*MemoryManager) LookupAIOContext

func (mm *MemoryManager) LookupAIOContext(ctx context.Context, id uint64) (*AIOContext, bool)

LookupAIOContext looks up the given context. It returns false if the context does not exist.

func (*MemoryManager) MLock

func (mm *MemoryManager) MLock(ctx context.Context, addr hostarch.Addr, length uint64, mode memmap.MLockMode) error

MLock implements the semantics of Linux's mlock()/mlock2()/munlock(), depending on mode.

func (*MemoryManager) MLockAll

func (mm *MemoryManager) MLockAll(ctx context.Context, opts MLockAllOpts) error

MLockAll implements the semantics of Linux's mlockall()/munlockall(), depending on opts.

func (*MemoryManager) MMap

func (mm *MemoryManager) MMap(ctx context.Context, opts memmap.MMapOpts) (hostarch.Addr, error)

MMap establishes a memory mapping.

func (*MemoryManager) MProtect

func (mm *MemoryManager) MProtect(addr hostarch.Addr, length uint64, realPerms hostarch.AccessType, growsDown bool) error

MProtect implements the semantics of Linux's mprotect(2).

func (*MemoryManager) MRemap

func (mm *MemoryManager) MRemap(ctx context.Context, oldAddr hostarch.Addr, oldSize uint64, newSize uint64, opts MRemapOpts) (hostarch.Addr, error)

MRemap implements the semantics of Linux's mremap(2).

func (*MemoryManager) MSync

func (mm *MemoryManager) MSync(ctx context.Context, addr hostarch.Addr, length uint64, opts MSyncOpts) error

MSync implements the semantics of Linux's msync().

func (*MemoryManager) MUnmap

func (mm *MemoryManager) MUnmap(ctx context.Context, addr hostarch.Addr, length uint64) error

MUnmap implements the semantics of Linux's munmap(2).

func (*MemoryManager) MapStack

func (mm *MemoryManager) MapStack(ctx context.Context) (hostarch.AddrRange, error)

MapStack allocates the initial process stack.

func (*MemoryManager) MapsCallbackFuncForBuffer

func (mm *MemoryManager) MapsCallbackFuncForBuffer(buf *bytes.Buffer) MapsCallbackFunc

MapsCallbackFuncForBuffer creates a /proc/[pid]/maps entry including the trailing newline.

func (*MemoryManager) MaxResidentSetSize

func (mm *MemoryManager) MaxResidentSetSize() uint64

MaxResidentSetSize returns the value advertised as mm's max RSS in bytes.

func (*MemoryManager) NewAIOContext

func (mm *MemoryManager) NewAIOContext(ctx context.Context, events uint32) (uint64, error)

NewAIOContext creates a new context for asynchronous I/O.

NewAIOContext is analogous to Linux's fs/aio.c:ioctx_alloc().

func (*MemoryManager) NumaPolicy

func (mm *MemoryManager) NumaPolicy(addr hostarch.Addr) (linux.NumaPolicy, uint64, error)

NumaPolicy implements the semantics of Linux's get_mempolicy(MPOL_F_ADDR).

func (*MemoryManager) Pin

func (mm *MemoryManager) Pin(ctx context.Context, ar hostarch.AddrRange, at hostarch.AccessType, ignorePermissions bool) ([]PinnedRange, error)

Pin returns the memmap.File ranges currently mapped by addresses in ar in mm, acquiring a reference on the returned ranges which the caller must release by calling Unpin. If not all addresses are mapped, Pin returns a non-nil error. Note that Pin may return both a non-empty slice of PinnedRanges and a non-nil error.

Pin does not prevent mapped ranges from changing, making it unsuitable for most I/O. It should only be used in contexts that would use get_user_pages() in the Linux kernel.

Preconditions:

  • ar.Length() != 0.
  • ar must be page-aligned.

func (*MemoryManager) ReadMapsDataInto

func (mm *MemoryManager) ReadMapsDataInto(ctx context.Context, fn MapsCallbackFunc)

ReadMapsDataInto is called by fsimpl/proc.mapsData.Generate to implement /proc/[pid]/maps.

func (*MemoryManager) ReadSmapsDataInto

func (mm *MemoryManager) ReadSmapsDataInto(ctx context.Context, buf *bytes.Buffer)

ReadSmapsDataInto is called by fsimpl/proc.smapsData.Generate to implement /proc/[pid]/maps.

func (*MemoryManager) ResidentSetSize

func (mm *MemoryManager) ResidentSetSize() uint64

ResidentSetSize returns the value advertised as mm's RSS in bytes.

func (*MemoryManager) SetArgvEnd

func (mm *MemoryManager) SetArgvEnd(a hostarch.Addr)

SetArgvEnd sets the end of the application argument vector.

func (*MemoryManager) SetArgvStart

func (mm *MemoryManager) SetArgvStart(a hostarch.Addr)

SetArgvStart sets the start of the application argument vector.

func (*MemoryManager) SetAuxv

func (mm *MemoryManager) SetAuxv(auxv arch.Auxv)

SetAuxv sets the entire map of auxiliary vectors.

func (*MemoryManager) SetDontFork

func (mm *MemoryManager) SetDontFork(addr hostarch.Addr, length uint64, dontfork bool) error

SetDontFork implements the semantics of madvise MADV_DONTFORK.

func (*MemoryManager) SetDumpability

func (mm *MemoryManager) SetDumpability(d Dumpability)

SetDumpability sets the dumpability.

func (*MemoryManager) SetEnvvEnd

func (mm *MemoryManager) SetEnvvEnd(a hostarch.Addr)

SetEnvvEnd sets the end of the application environment vector.

func (*MemoryManager) SetEnvvStart

func (mm *MemoryManager) SetEnvvStart(a hostarch.Addr)

SetEnvvStart sets the start of the application environment vector.

func (*MemoryManager) SetExecutable

func (mm *MemoryManager) SetExecutable(ctx context.Context, fd *vfs.FileDescription)

SetExecutable sets the executable.

This takes a reference on d.

func (*MemoryManager) SetMmapLayout

func (mm *MemoryManager) SetMmapLayout(ac *arch.Context64, r *limits.LimitSet) (arch.MmapLayout, error)

SetMmapLayout initializes mm's layout from the given arch.Context64.

Preconditions: mm contains no mappings and is not used concurrently.

func (*MemoryManager) SetNumaPolicy

func (mm *MemoryManager) SetNumaPolicy(addr hostarch.Addr, length uint64, policy linux.NumaPolicy, nodemask uint64) error

SetNumaPolicy implements the semantics of Linux's mbind().

func (*MemoryManager) SetVDSOSigReturn

func (mm *MemoryManager) SetVDSOSigReturn(addr uint64)

SetVDSOSigReturn sets the address of vdso_sigreturn.

func (*MemoryManager) StateFields

func (mm *MemoryManager) StateFields() []string

func (*MemoryManager) StateLoad

func (mm *MemoryManager) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*MemoryManager) StateSave

func (mm *MemoryManager) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*MemoryManager) StateTypeName

func (mm *MemoryManager) StateTypeName() string

func (*MemoryManager) String

func (mm *MemoryManager) String() string

String implements fmt.Stringer.String.

func (*MemoryManager) SwapUint32

func (mm *MemoryManager) SwapUint32(ctx context.Context, addr hostarch.Addr, new uint32, opts usermem.IOOpts) (uint32, error)

SwapUint32 implements usermem.IO.SwapUint32.

func (*MemoryManager) VDSOSigReturn

func (mm *MemoryManager) VDSOSigReturn() uint64

VDSOSigReturn returns the address of vdso_sigreturn.

func (*MemoryManager) VirtualDataSize

func (mm *MemoryManager) VirtualDataSize() uint64

VirtualDataSize returns the size of private data segments in mm.

func (*MemoryManager) VirtualMemorySize

func (mm *MemoryManager) VirtualMemorySize() uint64

VirtualMemorySize returns the combined length in bytes of all mappings in mm.

func (*MemoryManager) VirtualMemorySizeRange

func (mm *MemoryManager) VirtualMemorySizeRange(ar hostarch.AddrRange) uint64

VirtualMemorySizeRange returns the combined length in bytes of all mappings in ar in mm.

func (*MemoryManager) ZeroOut

func (mm *MemoryManager) ZeroOut(ctx context.Context, addr hostarch.Addr, toZero int64, opts usermem.IOOpts) (int64, error)

ZeroOut implements usermem.IO.ZeroOut.

type PinnedRange

type PinnedRange struct {
	// Source is the corresponding range of addresses.
	Source hostarch.AddrRange

	// File is the mapped file.
	File memmap.File

	// Offset is the offset into File at which this PinnedRange begins.
	Offset uint64
}

PinnedRanges are returned by MemoryManager.Pin.

func (PinnedRange) FileRange

func (pr PinnedRange) FileRange() memmap.FileRange

FileRange returns the memmap.File offsets mapped by pr.

type SpecialMappable

type SpecialMappable struct {
	SpecialMappableRefs
	// contains filtered or unexported fields
}

SpecialMappable implements memmap.MappingIdentity and memmap.Mappable with semantics similar to Linux's mm/mmap.c:_install_special_mapping(), except that SpecialMappable takes ownership of the memory that it represents (_install_special_mapping() does not.)

+stateify savable

var SpecialMappableobj *SpecialMappable

obj is used to customize logging. Note that we use a pointer to T so that we do not copy the entire object when passed as a format parameter.

func NewSpecialMappable

func NewSpecialMappable(name string, mfp pgalloc.MemoryFileProvider, fr memmap.FileRange) *SpecialMappable

NewSpecialMappable returns a SpecialMappable that owns fr, which represents offsets in mfp.MemoryFile() that contain the SpecialMappable's data. The SpecialMappable will use the given name in /proc/[pid]/maps.

Preconditions: fr.Length() != 0.

func (*SpecialMappable) AddMapping

AddMapping implements memmap.Mappable.AddMapping.

func (*SpecialMappable) CopyMapping

CopyMapping implements memmap.Mappable.CopyMapping.

func (*SpecialMappable) DecRef

func (m *SpecialMappable) DecRef(ctx context.Context)

DecRef implements refs.RefCounter.DecRef.

func (*SpecialMappable) DeviceID

func (m *SpecialMappable) DeviceID() uint64

DeviceID implements memmap.MappingIdentity.DeviceID.

func (*SpecialMappable) FileRange

func (m *SpecialMappable) FileRange() memmap.FileRange

FileRange returns the offsets into MemoryFileProvider().MemoryFile() that store the SpecialMappable's contents.

func (*SpecialMappable) InodeID

func (m *SpecialMappable) InodeID() uint64

InodeID implements memmap.MappingIdentity.InodeID.

func (*SpecialMappable) InvalidateUnsavable

func (m *SpecialMappable) InvalidateUnsavable(ctx context.Context) error

InvalidateUnsavable implements memmap.Mappable.InvalidateUnsavable.

func (*SpecialMappable) Length

func (m *SpecialMappable) Length() uint64

Length returns the length of the SpecialMappable.

func (*SpecialMappable) MappedName

func (m *SpecialMappable) MappedName(ctx context.Context) string

MappedName implements memmap.MappingIdentity.MappedName.

func (*SpecialMappable) MemoryFileProvider

func (m *SpecialMappable) MemoryFileProvider() pgalloc.MemoryFileProvider

MemoryFileProvider returns the MemoryFileProvider whose MemoryFile stores the SpecialMappable's contents.

func (*SpecialMappable) Msync

Msync implements memmap.MappingIdentity.Msync.

func (*SpecialMappable) RemoveMapping

RemoveMapping implements memmap.Mappable.RemoveMapping.

func (*SpecialMappable) StateFields

func (m *SpecialMappable) StateFields() []string

func (*SpecialMappable) StateLoad

func (m *SpecialMappable) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*SpecialMappable) StateSave

func (m *SpecialMappable) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*SpecialMappable) StateTypeName

func (m *SpecialMappable) StateTypeName() string

func (*SpecialMappable) Translate

func (m *SpecialMappable) Translate(ctx context.Context, required, optional memmap.MappableRange, at hostarch.AccessType) ([]memmap.Translation, error)

Translate implements memmap.Mappable.Translate.

type SpecialMappableRefs

type SpecialMappableRefs struct {
	// contains filtered or unexported fields
}

Refs implements refs.RefCounter. It keeps a reference count using atomic operations and calls the destructor when the count reaches zero.

NOTE: Do not introduce additional fields to the Refs struct. It is used by many filesystem objects, and we want to keep it as small as possible (i.e., the same size as using an int64 directly) to avoid taking up extra cache space. In general, this template should not be extended at the cost of performance. If it does not offer enough flexibility for a particular object (example: b/187877947), we should implement the RefCounter/CheckedObject interfaces manually.

+stateify savable

func (*SpecialMappableRefs) DecRef

func (r *SpecialMappableRefs) DecRef(destroy func())

DecRef implements refs.RefCounter.DecRef.

Note that speculative references are counted here. Since they were added prior to real references reaching zero, they will successfully convert to real references. In other words, we see speculative references only in the following case:

A: TryIncRef [speculative increase => sees non-negative references]
B: DecRef [real decrease]
A: TryIncRef [transform speculative to real]

func (*SpecialMappableRefs) IncRef

func (r *SpecialMappableRefs) IncRef()

IncRef implements refs.RefCounter.IncRef.

func (*SpecialMappableRefs) InitRefs

func (r *SpecialMappableRefs) InitRefs()

InitRefs initializes r with one reference and, if enabled, activates leak checking.

func (*SpecialMappableRefs) LeakMessage

func (r *SpecialMappableRefs) LeakMessage() string

LeakMessage implements refs.CheckedObject.LeakMessage.

func (*SpecialMappableRefs) LogRefs

func (r *SpecialMappableRefs) LogRefs() bool

LogRefs implements refs.CheckedObject.LogRefs.

func (*SpecialMappableRefs) ReadRefs

func (r *SpecialMappableRefs) ReadRefs() int64

ReadRefs returns the current number of references. The returned count is inherently racy and is unsafe to use without external synchronization.

func (*SpecialMappableRefs) RefType

func (r *SpecialMappableRefs) RefType() string

RefType implements refs.CheckedObject.RefType.

func (*SpecialMappableRefs) StateFields

func (r *SpecialMappableRefs) StateFields() []string

func (*SpecialMappableRefs) StateLoad

func (r *SpecialMappableRefs) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*SpecialMappableRefs) StateSave

func (r *SpecialMappableRefs) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*SpecialMappableRefs) StateTypeName

func (r *SpecialMappableRefs) StateTypeName() string

func (*SpecialMappableRefs) TryIncRef

func (r *SpecialMappableRefs) TryIncRef() bool

TryIncRef implements refs.TryRefCounter.TryIncRef.

To do this safely without a loop, a speculative reference is first acquired on the object. This allows multiple concurrent TryIncRef calls to distinguish other TryIncRef calls from genuine references held.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL