Versions in this module Expand all Collapse all v0 v0.8.0 Dec 17, 2024 Changes in this version + const ForeachDone + const ForeachMore + const MaxNodeID + var ErrAlreadyExists = fmt.Errorf("libmem: allocation already exists") + var ErrExpiredOffer = fmt.Errorf("libmem: expired offer") + var ErrFailedOption = fmt.Errorf("libmem: failed to apply option") + var ErrInternalError = fmt.Errorf("libmem: internal error") + var ErrInvalidNode = fmt.Errorf("libmem: invalid node") + var ErrInvalidNodeMask = fmt.Errorf("libmem: invalid NodeMask") + var ErrInvalidQosClass = fmt.Errorf("libmem: invalid QoS class") + var ErrInvalidType = fmt.Errorf("libmem: invalid type") + var ErrNoMem = fmt.Errorf("libmem: insufficient available memory") + var ErrNoZone = fmt.Errorf("libmem: failed to find zone") + var ErrUnknownRequest = fmt.Errorf("libmem: unknown allocation") + func HumanReadableSize(size int64) string + func NewID() string + func RequestsByAge(r1, r2 *Request) int + func RequestsByPriority(r1, r2 *Request) int + func RequestsBySize(r1, r2 *Request) int + type Allocator struct + func NewAllocator(options ...AllocatorOption) (*Allocator, error) + func (a *Allocator) Allocate(req *Request) (NodeMask, map[string]NodeMask, error) + func (a *Allocator) AssignedZone(id string) (NodeMask, bool) + func (a *Allocator) CPUSetAffinity(cpus cpuset.CPUSet) NodeMask + func (a *Allocator) DumpConfig(context ...interface{}) + func (a *Allocator) DumpNodes(context ...interface{}) + func (a *Allocator) DumpRequests(context ...interface{}) + func (a *Allocator) DumpState(context ...interface{}) + func (a *Allocator) DumpZones(prefixFmt ...interface{}) + func (a *Allocator) ForeachNode(nodes NodeMask, fn func(*Node) bool) + func (a *Allocator) ForeachRequest(req *Request, fn func(*Request) bool) + func (a *Allocator) GetOffer(req *Request) (*Offer, error) + func (a *Allocator) Masks() *MaskCache + func (a *Allocator) Realloc(id string, affinity NodeMask, types TypeMask) (NodeMask, map[string]NodeMask, error) + func (a *Allocator) Release(id string) error + func (a *Allocator) Reset() + func (a *Allocator) SortZones(f ZoneFilter, s ...ZoneSorter) []NodeMask + func (a *Allocator) ZoneAvailable(zone NodeMask) int64 + func (a *Allocator) ZoneCapacity(zone NodeMask) int64 + func (a *Allocator) ZoneFree(zone NodeMask) int64 + func (a *Allocator) ZoneNumUsers(zone NodeMask) int + func (a *Allocator) ZoneType(zone NodeMask) TypeMask + func (a *Allocator) ZoneUsage(zone NodeMask) int64 + func (a *Allocator) ZonesByUsersSubzonesFirst(zone1, zone2 NodeMask) int + type AllocatorOption func(*Allocator) error + func WithCustomFunctions(c *CustomFunctions) AllocatorOption + func WithNodes(nodes []*Node) AllocatorOption + func WithSystemNodes(sys sysfs.System) AllocatorOption + type CustomAllocator interface + CheckOvercommit func() map[NodeMask]int64 + DefaultExpandZone func(NodeMask, TypeMask) NodeMask + DefaultHandleOvercommit func(overcommit map[NodeMask]int64) error + GetAllocator func() *Allocator + GetNodes func() []*Node + GetRequests func() []*Request + GetRequestsForZone func(NodeMask) []*Request + GetZones func() []NodeMask + MoveRequest func(id string, zone NodeMask) error + type CustomFunctions struct + ExpandZone func(zone NodeMask, types TypeMask, a CustomAllocator) NodeMask + HandleOvercommit func(overcommit map[NodeMask]int64, a CustomAllocator) error + type Distance struct + func NewDistance(id ID, vector []int) (Distance, error) + func (d *Distance) Clone() *Distance + func (d *Distance) NodesAt(dist int) NodeMask + func (d *Distance) Sorted() []int + func (d *Distance) Vector() []int + type ID = idset.ID + type MaskCache struct + func NewMaskCache(nodes ...*Node) *MaskCache + func (c *MaskCache) AvailableNodes() NodeMask + func (c *MaskCache) AvailableTypes() TypeMask + func (c *MaskCache) Clone() *MaskCache + func (c *MaskCache) Dump(prefix, header string) + func (c *MaskCache) NodesByTypes(types TypeMask) NodeMask + func (c *MaskCache) NodesWithCloseCPUs() NodeMask + func (c *MaskCache) NodesWithMem() NodeMask + func (c *MaskCache) NodesWithMovableMem() NodeMask + func (c *MaskCache) NodesWithNormalMem() NodeMask + func (c *MaskCache) NodesWithoutCloseCPUs() NodeMask + func (c *MaskCache) NodesWithoutMem() NodeMask + type Node struct + func NewNode(id ID, t Type, capa int64, normal bool, cpus cpuset.CPUSet, d []int) (*Node, error) + func (n *Node) Capacity() int64 + func (n *Node) CloseCPUs() cpuset.CPUSet + func (n *Node) Distance() *Distance + func (n *Node) DistanceTo(id ID) int + func (n *Node) ForeachDistance(fn func(int, NodeMask) bool) + func (n *Node) HasCPUs() bool + func (n *Node) HasMemory() bool + func (n *Node) ID() ID + func (n *Node) IsMovable() bool + func (n *Node) IsNormal() bool + func (n *Node) Mask() NodeMask + func (n *Node) Type() Type + type NodeMask uint64 + const AnyZone + func MustParseNodeMask(str string) NodeMask + func NewNodeMask(ids ...ID) NodeMask + func ParseNodeMask(str string) (NodeMask, error) + func (m NodeMask) And(o NodeMask) NodeMask + func (m NodeMask) AndNot(o NodeMask) NodeMask + func (m NodeMask) Clear(ids ...ID) NodeMask + func (m NodeMask) Contains(ids ...ID) bool + func (m NodeMask) ContainsAny(ids ...ID) bool + func (m NodeMask) Foreach(fn func(ID) bool) + func (m NodeMask) MemsetString() string + func (m NodeMask) Or(o NodeMask) NodeMask + func (m NodeMask) Set(ids ...ID) NodeMask + func (m NodeMask) Size() int + func (m NodeMask) Slice() []ID + func (m NodeMask) String() string + type Offer struct + func (o *Offer) Commit() (NodeMask, map[string]NodeMask, error) + func (o *Offer) IsValid() bool + func (o *Offer) NodeMask() NodeMask + func (o *Offer) Updates() map[string]NodeMask + type Priority int16 + const BestEffort + const Burstable + const Guaranteed + const NoPriority + const Preserved + const Reservation + func (p Priority) String() string + type Request struct + func Container(id, name string, qos string, limit int64, affin NodeMask) *Request + func ContainerWithStrictTypes(id, name, qos string, limit int64, affin NodeMask, types TypeMask) *Request + func ContainerWithTypes(id, name, qos string, limit int64, affin NodeMask, types TypeMask) *Request + func NewRequest(id string, limit int64, affinity NodeMask, options ...RequestOption) *Request + func PreservedContainer(id, name string, limit int64, affin NodeMask) *Request + func ReservedMemory(limit int64, nodes NodeMask, options ...RequestOption) *Request + func SortRequests(requests map[string]*Request, f RequestFilter, s ...RequestSorter) []*Request + func (r *Request) Affinity() NodeMask + func (r *Request) Created() int64 + func (r *Request) ID() string + func (r *Request) IsStrict() bool + func (r *Request) Name() string + func (r *Request) Priority() Priority + func (r *Request) Size() int64 + func (r *Request) String() string + func (r *Request) Types() TypeMask + func (r *Request) Zone() NodeMask + type RequestFilter func(*Request) bool + func RequestsWithMaxPriority(limit Priority) RequestFilter + type RequestOption func(*Request) + func WithName(name string) RequestOption + func WithPreferredTypes(types TypeMask) RequestOption + func WithPriority(p Priority) RequestOption + func WithQosClass(qosClass string) RequestOption + func WithStrictTypes(types TypeMask) RequestOption + type RequestSorter func(r1, r2 *Request) int + type Type int + const TypeDRAM + const TypeHBM + const TypePMEM + func MustParseType(str string) Type + func ParseType(str string) (Type, error) + func TypeForSysfs(sysType sysfs.MemoryType) Type + func (t *Type) UnmarshalJSON(data []byte) error + func (t Type) IsValid() bool + func (t Type) MarshalJSON() ([]byte, error) + func (t Type) Mask() TypeMask + func (t Type) String() string + func (t Type) Sysfs() sysfs.MemoryType + type TypeMask int + const TypeMaskAll + const TypeMaskDRAM + const TypeMaskHBM + const TypeMaskPMEM + func MustParseTypeMask(str string) TypeMask + func NewTypeMask(types ...Type) TypeMask + func NewTypeMaskForSysfs(sysTypes ...sysfs.MemoryType) TypeMask + func ParseTypeMask(str string) (TypeMask, error) + func (m *TypeMask) UnmarshalJSON(data []byte) error + func (m TypeMask) And(o TypeMask) TypeMask + func (m TypeMask) AndNot(o TypeMask) TypeMask + func (m TypeMask) Clear(types ...Type) TypeMask + func (m TypeMask) Contains(types ...Type) bool + func (m TypeMask) ContainsAny(types ...Type) bool + func (m TypeMask) Foreach(fn func(Type) bool) + func (m TypeMask) MarshalJSON() ([]byte, error) + func (m TypeMask) Or(o TypeMask) TypeMask + func (m TypeMask) Set(types ...Type) TypeMask + func (m TypeMask) Slice() []Type + func (m TypeMask) String() string + type Zone struct + type ZoneFilter func(NodeMask) bool + type ZoneSorter func(z1, z2 NodeMask) int