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 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 ¶
- func Unpin(prs []PinnedRange)
- type AIOContext
- type Dumpability
- type MLockAllOpts
- type MRemapMoveMode
- type MRemapOpts
- type MSyncOpts
- type MapsCallbackFunc
- type MemoryManager
- func (mm *MemoryManager) Activate(ctx context.Context) error
- func (mm *MemoryManager) AddressSpace() platform.AddressSpace
- func (mm *MemoryManager) ArgvEnd() hostarch.Addr
- func (mm *MemoryManager) ArgvStart() hostarch.Addr
- func (mm *MemoryManager) Auxv() arch.Auxv
- func (mm *MemoryManager) Brk(ctx context.Context, addr hostarch.Addr) (hostarch.Addr, error)
- func (mm *MemoryManager) BrkSetup(ctx context.Context, addr hostarch.Addr)
- func (mm *MemoryManager) CheckIORange(addr hostarch.Addr, length int64) (hostarch.AddrRange, bool)
- func (mm *MemoryManager) CompareAndSwapUint32(ctx context.Context, addr hostarch.Addr, old, new uint32, opts usermem.IOOpts) (uint32, error)
- func (mm *MemoryManager) CopyIn(ctx context.Context, addr hostarch.Addr, dst []byte, opts usermem.IOOpts) (int, error)
- func (mm *MemoryManager) CopyInTo(ctx context.Context, ars hostarch.AddrRangeSeq, dst safemem.Writer, ...) (int64, error)
- func (mm *MemoryManager) CopyOut(ctx context.Context, addr hostarch.Addr, src []byte, opts usermem.IOOpts) (int, error)
- func (mm *MemoryManager) CopyOutFrom(ctx context.Context, ars hostarch.AddrRangeSeq, src safemem.Reader, ...) (int64, error)
- func (mm *MemoryManager) Deactivate()
- func (mm *MemoryManager) DebugString(ctx context.Context) string
- func (mm *MemoryManager) DecUsers(ctx context.Context)
- func (mm *MemoryManager) Decommit(addr hostarch.Addr, length uint64) error
- func (mm *MemoryManager) DestroyAIOContext(ctx context.Context, id uint64) *AIOContext
- func (mm *MemoryManager) DetachShm(ctx context.Context, addr hostarch.Addr) error
- func (mm *MemoryManager) Dumpability() Dumpability
- func (mm *MemoryManager) EnableMembarrierPrivate()
- func (mm *MemoryManager) EnableMembarrierRSeq()
- func (mm *MemoryManager) EnsurePMAsExist(ctx context.Context, addr hostarch.Addr, length int64, opts usermem.IOOpts) (int64, error)
- func (mm *MemoryManager) EnvvEnd() hostarch.Addr
- func (mm *MemoryManager) EnvvStart() hostarch.Addr
- func (mm *MemoryManager) Executable() *vfs.FileDescription
- func (mm *MemoryManager) FindVMAByName(ar hostarch.AddrRange, name string) (hostarch.Addr, uint64, error)
- func (mm *MemoryManager) Fork(ctx context.Context) (*MemoryManager, error)
- func (mm *MemoryManager) GetSharedFutexKey(ctx context.Context, addr hostarch.Addr) (futex.Key, error)
- func (mm *MemoryManager) HandleUserFault(ctx context.Context, addr hostarch.Addr, at hostarch.AccessType, ...) error
- func (mm *MemoryManager) IncUsers() bool
- func (mm *MemoryManager) Invalidate(ar hostarch.AddrRange, opts memmap.InvalidateOpts)
- func (mm *MemoryManager) InvalidateUnsavable(ctx context.Context) error
- func (mm *MemoryManager) IsMembarrierPrivateEnabled() bool
- func (mm *MemoryManager) IsMembarrierRSeqEnabled() bool
- func (mm *MemoryManager) LoadUint32(ctx context.Context, addr hostarch.Addr, opts usermem.IOOpts) (uint32, error)
- func (mm *MemoryManager) LookupAIOContext(ctx context.Context, id uint64) (*AIOContext, bool)
- func (mm *MemoryManager) MLock(ctx context.Context, addr hostarch.Addr, length uint64, mode memmap.MLockMode) error
- func (mm *MemoryManager) MLockAll(ctx context.Context, opts MLockAllOpts) error
- func (mm *MemoryManager) MMap(ctx context.Context, opts memmap.MMapOpts) (hostarch.Addr, error)
- func (mm *MemoryManager) MProtect(addr hostarch.Addr, length uint64, realPerms hostarch.AccessType, ...) error
- func (mm *MemoryManager) MRemap(ctx context.Context, oldAddr hostarch.Addr, oldSize uint64, newSize uint64, ...) (hostarch.Addr, error)
- func (mm *MemoryManager) MSync(ctx context.Context, addr hostarch.Addr, length uint64, opts MSyncOpts) error
- func (mm *MemoryManager) MUnmap(ctx context.Context, addr hostarch.Addr, length uint64) error
- func (mm *MemoryManager) MapStack(ctx context.Context) (hostarch.AddrRange, error)
- func (mm *MemoryManager) MapsCallbackFuncForBuffer(buf *bytes.Buffer) MapsCallbackFunc
- func (mm *MemoryManager) MaxResidentSetSize() uint64
- func (mm *MemoryManager) NewAIOContext(ctx context.Context, events uint32) (uint64, error)
- func (mm *MemoryManager) NumaPolicy(addr hostarch.Addr) (linux.NumaPolicy, uint64, error)
- func (mm *MemoryManager) Pin(ctx context.Context, ar hostarch.AddrRange, at hostarch.AccessType, ...) ([]PinnedRange, error)
- func (mm *MemoryManager) ReadMapsDataInto(ctx context.Context, fn MapsCallbackFunc)
- func (mm *MemoryManager) ReadSmapsDataInto(ctx context.Context, buf *bytes.Buffer)
- func (mm *MemoryManager) ResidentSetSize() uint64
- func (mm *MemoryManager) SetArgvEnd(a hostarch.Addr)
- func (mm *MemoryManager) SetArgvStart(a hostarch.Addr)
- func (mm *MemoryManager) SetAuxv(auxv arch.Auxv)
- func (mm *MemoryManager) SetDontFork(addr hostarch.Addr, length uint64, dontfork bool) error
- func (mm *MemoryManager) SetDumpability(d Dumpability)
- func (mm *MemoryManager) SetEnvvEnd(a hostarch.Addr)
- func (mm *MemoryManager) SetEnvvStart(a hostarch.Addr)
- func (mm *MemoryManager) SetExecutable(ctx context.Context, fd *vfs.FileDescription)
- func (mm *MemoryManager) SetMmapLayout(ac *arch.Context64, r *limits.LimitSet) (arch.MmapLayout, error)
- func (mm *MemoryManager) SetNumaPolicy(addr hostarch.Addr, length uint64, policy linux.NumaPolicy, nodemask uint64) error
- func (mm *MemoryManager) SetVDSOSigReturn(addr uint64)
- func (mm *MemoryManager) SetVMAAnonName(addr hostarch.Addr, length uint64, name string, nameIsNil bool) error
- func (mm *MemoryManager) String() string
- func (mm *MemoryManager) SwapUint32(ctx context.Context, addr hostarch.Addr, new uint32, opts usermem.IOOpts) (uint32, error)
- func (mm *MemoryManager) VDSOSigReturn() uint64
- func (mm *MemoryManager) VirtualDataSize() uint64
- func (mm *MemoryManager) VirtualMemorySize() uint64
- func (mm *MemoryManager) VirtualMemorySizeRange(ar hostarch.AddrRange) uint64
- func (mm *MemoryManager) ZeroOut(ctx context.Context, addr hostarch.Addr, toZero int64, opts usermem.IOOpts) (int64, error)
- type PinnedRange
- type SpecialMappable
- func (*SpecialMappable) AddMapping(context.Context, memmap.MappingSpace, hostarch.AddrRange, uint64, bool) error
- func (*SpecialMappable) CopyMapping(context.Context, memmap.MappingSpace, hostarch.AddrRange, hostarch.AddrRange, ...) error
- func (m *SpecialMappable) DecRef(ctx context.Context)
- func (m *SpecialMappable) DeviceID() uint64
- func (m *SpecialMappable) FileRange() memmap.FileRange
- func (m *SpecialMappable) InodeID() uint64
- func (m *SpecialMappable) InvalidateUnsavable(ctx context.Context) error
- func (m *SpecialMappable) Length() uint64
- func (m *SpecialMappable) MappedName(ctx context.Context) string
- func (m *SpecialMappable) Msync(ctx context.Context, mr memmap.MappableRange) error
- func (*SpecialMappable) RemoveMapping(context.Context, memmap.MappingSpace, hostarch.AddrRange, uint64, bool)
- func (m *SpecialMappable) Translate(ctx context.Context, required, optional memmap.MappableRange, ...) ([]memmap.Translation, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (aio *AIOContext) CancelPendingRequest()
CancelPendingRequest forgets about a request that hasn't yet completed.
func (*AIOContext) Dead ¶
func (aio *AIOContext) Dead() bool
Dead returns true if the context has been destroyed.
func (*AIOContext) Drain ¶
func (aio *AIOContext) Drain()
Drain drops all completed requests. Pending requests remain untouched.
func (*AIOContext) FinishRequest ¶
func (aio *AIOContext) FinishRequest(data any)
FinishRequest finishes a pending request. It queues up the data and notifies listeners.
func (*AIOContext) PopRequest ¶
func (aio *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 (aio *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) WaitChannel ¶
func (aio *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, mf *pgalloc.MemoryFile, 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 ¶
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 ¶
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) 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, name 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) 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) 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 ¶
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 ¶
SetDontFork implements the semantics of madvise MADV_DONTFORK.
Preconditions: addr and length are page-aligned.
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) SetVMAAnonName ¶
func (mm *MemoryManager) SetVMAAnonName(addr hostarch.Addr, length uint64, name string, nameIsNil bool) error
SetVMAAnonName implements the semantics of Linux's prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME).
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.
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
func NewSpecialMappable ¶
func NewSpecialMappable(name string, mf *pgalloc.MemoryFile, 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 ¶
func (*SpecialMappable) AddMapping(context.Context, memmap.MappingSpace, hostarch.AddrRange, uint64, bool) error
AddMapping implements memmap.Mappable.AddMapping.
func (*SpecialMappable) CopyMapping ¶
func (*SpecialMappable) CopyMapping(context.Context, memmap.MappingSpace, hostarch.AddrRange, hostarch.AddrRange, uint64, bool) error
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 m.mf that stores 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) Msync ¶
func (m *SpecialMappable) Msync(ctx context.Context, mr memmap.MappableRange) error
Msync implements memmap.MappingIdentity.Msync.
func (*SpecialMappable) RemoveMapping ¶
func (*SpecialMappable) RemoveMapping(context.Context, memmap.MappingSpace, hostarch.AddrRange, uint64, bool)
RemoveMapping implements memmap.Mappable.RemoveMapping.
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.