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.Mappable methods other than Translate mm.MemoryManager.activeMu Locks taken by memmap.Mappable.Translate mm.privateRefs.mu platform.AddressSpace locks memmap.File locks mm.aioManager.mu mm.AIOContext.mu kernel.TaskSet.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
- func (ctx *AIOContext) CancelPendingRequest()
- func (ctx *AIOContext) Dead() bool
- func (ctx *AIOContext) Drain()
- func (ctx *AIOContext) FinishRequest(data interface{})
- func (ctx *AIOContext) PopRequest() (interface{}, bool)
- func (ctx *AIOContext) Prepare() error
- func (ctx *AIOContext) WaitChannel() chan struct{}
- type Dumpability
- type MLockAllOpts
- type MRemapMoveMode
- type MRemapOpts
- type MSyncOpts
- 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) EnvvEnd() hostarch.Addr
- func (mm *MemoryManager) EnvvStart() hostarch.Addr
- func (mm *MemoryManager) Executable() fsbridge.File
- 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) MaxResidentSetSize() uint64
- func (mm *MemoryManager) NeedsUpdate(generation int64) bool
- 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, buf *bytes.Buffer)
- func (mm *MemoryManager) ReadMapsSeqFileData(ctx context.Context, handle seqfile.SeqHandle) ([]seqfile.SeqData, int64)
- func (mm *MemoryManager) ReadSmapsDataInto(ctx context.Context, buf *bytes.Buffer)
- func (mm *MemoryManager) ReadSmapsSeqFileData(ctx context.Context, handle seqfile.SeqHandle) ([]seqfile.SeqData, int64)
- 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, file fsbridge.File)
- func (mm *MemoryManager) SetMmapLayout(ac arch.Context, 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) 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) MemoryFileProvider() pgalloc.MemoryFileProvider
- 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 (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 interface{})
FinishRequest finishes a pending request. It queues up the data and notifies listeners.
func (*AIOContext) PopRequest ¶
func (ctx *AIOContext) PopRequest() (interface{}, 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) 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 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 ¶
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) 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() fsbridge.File
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) 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) MaxResidentSetSize ¶
func (mm *MemoryManager) MaxResidentSetSize() uint64
MaxResidentSetSize returns the value advertised as mm's max RSS in bytes.
func (*MemoryManager) NeedsUpdate ¶
func (mm *MemoryManager) NeedsUpdate(generation int64) bool
NeedsUpdate implements seqfile.SeqSource.NeedsUpdate.
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, buf *bytes.Buffer)
ReadMapsDataInto is called by fsimpl/proc.mapsData.Generate to implement /proc/[pid]/maps.
func (*MemoryManager) ReadMapsSeqFileData ¶
func (mm *MemoryManager) ReadMapsSeqFileData(ctx context.Context, handle seqfile.SeqHandle) ([]seqfile.SeqData, int64)
ReadMapsSeqFileData is called by fs/proc.mapsData.ReadSeqFileData 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) ReadSmapsSeqFileData ¶
func (mm *MemoryManager) ReadSmapsSeqFileData(ctx context.Context, handle seqfile.SeqHandle) ([]seqfile.SeqData, int64)
ReadSmapsSeqFileData is called by fs/proc.smapsData.ReadSeqFileData to implement /proc/[pid]/smaps.
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.
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, file fsbridge.File)
SetExecutable sets the executable.
This takes a reference on d.
func (*MemoryManager) SetMmapLayout ¶
func (mm *MemoryManager) SetMmapLayout(ac arch.Context, r *limits.LimitSet) (arch.MmapLayout, error)
SetMmapLayout initializes mm's layout from the given arch.Context.
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) 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 NewSharedAnonMappable ¶
func NewSharedAnonMappable(length uint64, mfp pgalloc.MemoryFileProvider) (*SpecialMappable, error)
NewSharedAnonMappable returns a SpecialMappable that implements the semantics of mmap(MAP_SHARED|MAP_ANONYMOUS) and mappings of /dev/zero.
TODO(gvisor.dev/issue/1624): Linux uses an ephemeral file created by mm/shmem.c:shmem_zero_setup(), and VFS2 does something analogous. VFS1 uses a SpecialMappable instead, incorrectly getting device and inode IDs of zero and causing memory for shared anonymous mappings to be allocated up-front instead of on first touch; this is to avoid exacerbating the fs.MountSource leak (b/143656263). Delete this function along with VFS1.
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 ¶
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 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 ¶
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.