Documentation ¶
Overview ¶
Package libmem implements a simple memory accounting and allocation scheme for resource management policy plugins. The primary interface to libmem is the Allocator type.
Allocator, Nodes ¶
Allocator is set up with one or more nodes. A node usually corresponds to an actual NUMA node in the system. It has some amount of associated memory. That memory has some known memory type, ordinary DRAM memory, high-capacity non-volatile/persistent PMEM memory, or high-bandwidth HBM memory. A node comes with a vector of distances which describe the cost of moving memory from the node to other nodes. A node also might have an associated set of CPU cores which are considered to be close topologically to the node's memory.
Memory Zones, Allocation Requests ¶
Allocator divides memory into zones. A memory zone is simply a set of one or more memory nodes. Memory is allocated using requests. Each request has an affinity and a type preference. Affinity states which zone the allocated memory should be close to and in the simplest case it is the set of nodes from which memory is allocated from. The type preference indicates which type or types of memory should be allocated. A type preference can be strict, in which case failing to satisfy the preference results in a failed allocation. The request also has an Priority. This tells the allocator how eagerly it can / easily it should move the allocation to other memory zones later, if some zone runs out of memory due to subsequent allocations.
Allocation Algorithm, Initial Zone Selection ¶
Allocation starts by finding an initial zone for the request. This zone is the closest zone that satisfies the type preferences of the request and has at least one node with normal memory (as opposed to movable memory). Note that for non-strict requests this zone might not have all the preferred types.
Allocation Algorithm, Overcommit Handling ¶
Once the initial zone is found, Allocator checks if any memory zone is oversubscribed or IOW is in the danger of running out of memory. A zone is considered oversubscribed if the total size of allocations that fit into the zone exceeds the total amount of memory available in the nodes of the zone. An allocation is said to fit into a zone if it is assigned to (IOW satisfied using) the zone, or another zone with a subset of the nodes of the first zone. For instance, allocations with assigned zones {0}, {2}, and {0, 2}, fully fit into {0, 1, 2, 3}, while zones {0, 4}, {2, 5}, or {0, 2, 4, 5} do not.
If any zone is oversubscribed, an overcommit handling algorithm kicks in to reduce memory usage in overcommitted nodes. Memory usage is reduced by moving allocations from the zone to a new one with a superset of nodes of the original zone. An expansion algorithm using node affinity, types and distance vectors is used to determine the superset zone. Overcommit handling prefers moving allocations with lower priority first. Allocation fails if the overcommit handler cannot resolve all overcommit.
Customizing an Allocator ¶
Allocator can be customized in multiple ways. The simplest but most limited is to set up the Allocator with a curated set of node distance vectors. Since node expansion looks at the distance vectors to decide how to expand a zone, by altering the distance vector one can change the the order and set of new nodes considered during zone expansion.
Another more involved but direct and more flexible way to customize an Allocator is to explicitly set it up with custom functions for node expansion and/or overcommit resolution. These custom functions are called whenever node expansion is necessary (initial zone selection, overcommit resolution), or when oversubscription has been detected. These custom functions get access to the built-in default implementations. Often this allows implementing exception style extra handling just for cases of special interest but otherwise rely on the default implementations.
Allocation Offers ¶
It is sometimes necessary or desirable to compare multiple allocation alternatives, especially ones with different memory affinity, before making a final allocation decision. Often this decision is based on how well a possible allocation aligns with resources from other domains, for instance with CPU cores, GPUs, or other devices.
libmem provides memory offers for this. An offer captures all details necessary to make a memory allocation without actually updating the Allocators state with those details. Multiple parallel offers can be queried at any time. An offer, but only a single offer, can then be turned into an allocation by committing it, once the best allocation alternative has been determined.
Index ¶
- Constants
- Variables
- 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
- 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
- type CustomAllocator
- type CustomFunctions
- type Distance
- type ID
- type 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
- 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
- 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
- type Priority
- type Request
- 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
- type RequestOption
- type RequestSorter
- type Type
- type TypeMask
- 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
- func (m *TypeMask) UnmarshalJSON(data []byte) error
- type Zone
- type ZoneFilter
- type ZoneSorter
Constants ¶
const ( // ForeachDone as a return value terminates iteration by a Foreach* function. ForeachDone = false // ForeachMore as a return value continues iteration by a Foreach* function. ForeachMore = !ForeachDone )
const (
// MaxNodeID is the maximum node ID that can be stored in a NodeMask.
MaxNodeID = 63
)
Variables ¶
var ( ErrFailedOption = fmt.Errorf("libmem: failed to apply option") ErrInvalidType = fmt.Errorf("libmem: invalid type") ErrInvalidNode = fmt.Errorf("libmem: invalid node") ErrInvalidNodeMask = fmt.Errorf("libmem: invalid NodeMask") ErrInvalidQosClass = fmt.Errorf("libmem: invalid QoS class") ErrExpiredOffer = fmt.Errorf("libmem: expired offer") ErrUnknownRequest = fmt.Errorf("libmem: unknown allocation") ErrAlreadyExists = fmt.Errorf("libmem: allocation already exists") ErrNoMem = fmt.Errorf("libmem: insufficient available memory") ErrNoZone = fmt.Errorf("libmem: failed to find zone") ErrInternalError = fmt.Errorf("libmem: internal error") )
Functions ¶
func HumanReadableSize ¶
HumanReadableSize returns the given size as a human-readable string.
func NewID ¶
func NewID() string
NewID returns a new internally generated ID. It is used to give default IDs for memory reservations in case one is not provided by the caller.
func RequestsByAge ¶
RequestsByAge compares requests by increasing age.
func RequestsByPriority ¶
RequestsByPriority compares requests by increasing priority.
func RequestsBySize ¶
RequestsBySize compares requests by increasing size.
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
Allocator implements a topology aware but largely policy agnostic scheme for memory accounting and allocation.
func NewAllocator ¶
func NewAllocator(options ...AllocatorOption) (*Allocator, error)
NewAllocator creates a new allocator instance and configures it with the given options.
func (*Allocator) Allocate ¶
Allocate allocates memory for the given request. It is equivalent to committing an acquired offer for the request. Allocate returns the nodes used to satisfy the request, together with any updates made to other existing allocations to fulfill the request. The caller must ensure these updates are properly enforced.
func (*Allocator) AssignedZone ¶
AssignedZone returns the assigned nodes for the given allocation and whether such an allocation was found.
func (*Allocator) CPUSetAffinity ¶
CPUSetAffinity returns the mask of closest nodes for the given cpuset.
func (*Allocator) DumpConfig ¶
func (a *Allocator) DumpConfig(context ...interface{})
func (*Allocator) DumpRequests ¶
func (a *Allocator) DumpRequests(context ...interface{})
func (*Allocator) ForeachNode ¶
ForeachNode calls the given function with each node present in the mask. It stops iterating early if the function returns false.
func (*Allocator) ForeachRequest ¶
ForeachRequest calls the given function with each active allocation in the allocator. It stops iterating early if the functions returns false.
func (*Allocator) GetOffer ¶
GetOffer returns an offer for the given request. The offer can be turned into an actual allocation by Commit(). Multiple offers can coexist for a request. Committing any offer invalidates all other offers. Allocating or releasing memory likewise invalidates all offers.
func (*Allocator) Realloc ¶
func (a *Allocator) Realloc(id string, affinity NodeMask, types TypeMask) (NodeMask, map[string]NodeMask, error)
Realloc updates an existing allocation with the given extra affinity and memory types. Realloc is semantically either expansive or no-op. In particular, Realloc cannot be used to remove assigned nodes and types from an allocation, and it cannot be used to shrink the amount of memory assigned to an allocation. A non-zero affinity and 0 types cause the types implied by affinity to be used. A non-zero types is used to filter non-matching nodes from the affinity used. A call with 0 affinity and types is a no-op. A call with both affinity and types matching the existing allocation is also a no-op. Realloc returns the updated nodes for the allocation, together with any updates made to other existing allocations to fulfill the request. The caller must ensure these updates are properly enforced.
func (*Allocator) Reset ¶
func (a *Allocator) Reset()
Reset resets the state of the allocator, releasing all allocations and invalidating all offers.
func (*Allocator) SortZones ¶
func (a *Allocator) SortZones(f ZoneFilter, s ...ZoneSorter) []NodeMask
SortZones filters zones by a filter function into a slice, then sorts the slice by chaining the given sorting functions. A nil filter function picks all zones.
func (*Allocator) ZoneAvailable ¶
ZoneAvailable returns the amount of available memory in the zone.
func (*Allocator) ZoneCapacity ¶
ZoneCapacity returns the amount of total memory in the zone.
func (*Allocator) ZoneNumUsers ¶
ZoneNumUsers returns the number of requests assigned to the zone.
func (*Allocator) ZonesByUsersSubzonesFirst ¶
ZonesByUsersSubzonesFirst compares zone by number of users.
type AllocatorOption ¶
AllocatorOption is an opaque option for an Allocator.
func WithCustomFunctions ¶
func WithCustomFunctions(c *CustomFunctions) AllocatorOption
WithCustomFunctions returns an option for overriding default algorithms in an Allocator.
func WithNodes ¶
func WithNodes(nodes []*Node) AllocatorOption
WithNodes is an option to assign the given memory nodes to an allocator.
func WithSystemNodes ¶
func WithSystemNodes(sys sysfs.System) AllocatorOption
WithSystemNodes is an option to request an allocator to perform automatic NUMA node discovery using the given sysfs instance.
type CustomAllocator ¶
type CustomAllocator interface { // CheckOvercommit checks any zone overcommit, returning the amount of spill for each. CheckOvercommit() map[NodeMask]int64 // GetRequests returns all allocations. GetRequests() []*Request // GetRequestsForZone returns all allocations for the given zone. GetRequestsForZone(NodeMask) []*Request // MoveRequest moves the given allocation to the given zone. MoveRequest(id string, zone NodeMask) error // GetZones returns all zones which have active allocations. GetZones() []NodeMask // GetNodes returns all nodes known to the allocator. GetNodes() []*Node // DefaultExpandZone is the default implementation for zone expansion. DefaultExpandZone(NodeMask, TypeMask) NodeMask // DefaultHandleOvercommit is the default implementation for overcommit handling. DefaultHandleOvercommit(overcommit map[NodeMask]int64) error // GetAllocator returns the underlying customized allocator. GetAllocator() *Allocator }
CustomAllocator is the interface custom functions use to interact with the Allocator they customize.
type CustomFunctions ¶
type CustomFunctions struct { // ExpandZone returns the extra nodes to expand the given zone for the // given memory types. Zone expansion happens either when resolving // overcommit of the given zone to figure out where to move allocations, // or to satisfy the requested memory types for an allocation request, // if the preferred affinity is not enough to do so. DefaultExpandZone // in CustomAllocator provides a default implementation. ExpandZone func(zone NodeMask, types TypeMask, a CustomAllocator) NodeMask // HandleOvercommit takes care of reducing memory usage in overcommitted // zones. Such zones have less capacity than the total consumption by all // active allocations. The given CustomAllocator provides functions for // overcommit handling, for instance MoveRequest() for moving allocations // to other zones and CheckOvercommit() for re-checking overcommit after // moves. DefaultHandleOvercommit in CustomAllocator provides a default // implementation. HandleOvercommit func(overcommit map[NodeMask]int64, a CustomAllocator) error }
CustomFunctions can be used to provide custom implementations which override default algorithms in an Allocator. Use the WithCustomFunctions option to pass custom functions to an Allocator.
type Distance ¶
type Distance struct {
// contains filtered or unexported fields
}
Distance represents distance of a memory node from other nodes.
func NewDistance ¶
NewDistance creates a new Distance from the given distance vector.
type MaskCache ¶
type MaskCache struct {
// contains filtered or unexported fields
}
MaskCache caches oft-used memory type and node masks for an Allocator.
func NewMaskCache ¶
NewMaskCache returns a new cache with the given nodes added.
func (*MaskCache) AvailableNodes ¶
AvailableNodes returns all nodes added to the cache.
func (*MaskCache) AvailableTypes ¶
AvailableTypes returns all available types from the cache. A type considered available if at least one node with non-zero amount of attached memory of the type was added to the cache.
func (*MaskCache) NodesByTypes ¶
NodesByTypes the nodes with given type of memory attached from the cache. Note that if any of the given types is unavailable NodesByTypes returns an empty NodeMask even if other types of memory in the TypeMask is available.
func (*MaskCache) NodesWithCloseCPUs ¶
NodesWithCloseCPUs returns all nodes which have a non-empty set of close CPUs from the cache.
func (*MaskCache) NodesWithMem ¶
NodesWithMem returns all nodes with any memory attached from the cache.
func (*MaskCache) NodesWithMovableMem ¶
NodesWithMovableMem returns all nodes with movable memory attached from the cache.
func (*MaskCache) NodesWithNormalMem ¶
NodesWithNormalMem returns all nodes with normal, non-movable memory attached from the cache.
func (*MaskCache) NodesWithoutCloseCPUs ¶
NodesWithoutCloseCPUs returns all nodes which have no close CPUs from the cache.
func (*MaskCache) NodesWithoutMem ¶
NodesWithMem returns all nodes with no memory attached from the cache.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a memory node with some amount and type of attached memory.
func (*Node) DistanceTo ¶
DistanceTo returns the distance of the node to the given node.
func (*Node) ForeachDistance ¶
ForeachDistance calls the given function for each distance in the distance vector in increasing order, skipping the first distance to the node itself, until the function returns false, or ForeachDone. Iteration continues if the returned value is true, or ForeachMore. At each iteration the function is called with the current distance and the set of nodes at that distance.
type NodeMask ¶
type NodeMask uint64
NodeMask represents a set of node IDs as a bit mask.
const (
AnyZone NodeMask = 0
)
func MustParseNodeMask ¶
MustParseNodeMask parses the given string representation of a NodeMask. It panicks on failure.
func NewNodeMask ¶
NewNodeMask returns a NodeMask with the given ids.
func ParseNodeMask ¶
ParseNodeMask parses the given string representation of a NodeMask.
func (NodeMask) AndNot ¶
AndNot returns a NodeMask with all IDs which are present in m but not in o.
func (NodeMask) ContainsAny ¶
ContainsAny returns true if any of the given IDs are present in the NodeMask.
func (NodeMask) Foreach ¶
Foreach calls the given function for each ID set in the NodeMask until the function returns false, or ForeachDone. Iteration continues if the returned value is true, or ForeachMore.
func (NodeMask) MemsetString ¶
MemsetString returns a linux memory set-compatible string representation of the NodeMask. This string is suitable to be used with the cpuset cgroup controller for pinning processes to memory nodes.
func (NodeMask) Or ¶
Or returns a NodeMask with all IDs which are present at least in one of the NodeMasks.
type Offer ¶
type Offer struct {
// contains filtered or unexported fields
}
Offer represents a possible memory allocation for a request. Valid offers can be committed and turned into actual allocations. Allocating memory or releasing memory invalidates all uncommitted offers.
type Priority ¶
type Priority int16
Priority describes the priority of a request. Its is used to choose which requests should be reassigned to another memory zone when a zone runs out of memory (is overcommitted) by affinity based assignments alone. Priority is always relative to other requests. Default priorities are provided for the well-known QoS classes (BestEffort, Burstable, Guaranteed).
const ( NoPriority Priority = 0 // moved around freely BestEffort Priority = 0 // ditto, do your worst Burstable Priority = (1 << 10) // move if necessary Guaranteed Priority = (1 << 14) // try avoid moving this Preserved Priority = (1 << 15) - 2 // try avoid moving this... harder Reservation Priority = (1 << 15) - 1 // immovable )
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request represents a memory allocation request.
func Container ¶
Container is a convenience function to create a request for a container of a particular QoS class. The QoS class is used to set the priority for the request.
func ContainerWithStrictTypes ¶
func ContainerWithStrictTypes(id, name, qos string, limit int64, affin NodeMask, types TypeMask) *Request
ContainerWithStrictTypes is a convenience function to create a request with strict memory type preference for a container of a particular QoS class. The QoS class is used to set the priority for the request.
func ContainerWithTypes ¶
ContainerWithTypes is a convenience function to create a request with a memory type preference for a container of a particular QoS class. The QoS class is used to set the priority for the request.
func NewRequest ¶
func NewRequest(id string, limit int64, affinity NodeMask, options ...RequestOption) *Request
NewRequest returns a new request with the given parameters and options.
func PreservedContainer ¶
PreserveContainer is a convenience function to create an allocation request for a container with 'preserved' memory. Such a request has higher priority than other, ordinary requests. The allocator tries to avoid moving such allocations later when trying to satisfy subsequent requests.
func ReservedMemory ¶
func ReservedMemory(limit int64, nodes NodeMask, options ...RequestOption) *Request
ReservedMemory is a convenience function to create an allocation request for reserving memory from the allocator. Once memory has been successfully reserved, it is never moved by the allocator. ReservedMemory can be used to inform the allocator about external memory allocations which are beyond the control of the caller.
func SortRequests ¶
func SortRequests(requests map[string]*Request, f RequestFilter, s ...RequestSorter) []*Request
SortRequests filters the requests by a filter function into a slice, then sorts the slice by chaining the given sorting functions. A nil filter function picks all requests.
func (*Request) Affinity ¶
Affinity returns the node affinity of this request. The allocator will start with this set of nodes to fulfill the request.
type RequestFilter ¶
RequestFilter is a function to filter requests.
func RequestsWithMaxPriority ¶
func RequestsWithMaxPriority(limit Priority) RequestFilter
RequestsWithMaxPriority filters requests by maximum allowed priority.
type RequestOption ¶
type RequestOption func(*Request)
RequestOption is an opaque option which can be applied to a request.
func WithName ¶
func WithName(name string) RequestOption
WithName returns an option for setting a verbose name for the request.
func WithPreferredTypes ¶
func WithPreferredTypes(types TypeMask) RequestOption
WithPreferredTypes returns an option to set preferred memory types for a request.
func WithPriority ¶
func WithPriority(p Priority) RequestOption
WithPriority returns an option to set the priority of a request.
func WithQosClass ¶
func WithQosClass(qosClass string) RequestOption
WithQosClass returns an option to set the priority of a request based on a QoS class.
func WithStrictTypes ¶
func WithStrictTypes(types TypeMask) RequestOption
WithStrictTypes returns an option to set strict memory types for a request.
type RequestSorter ¶
RequestSorter is a function to compare requests for sorting.
type Type ¶
type Type int
Type represents known types of memory.
func MustParseType ¶
MustParseType parses the given string into a memory type. It panicks on failure.
func TypeForSysfs ¶
func TypeForSysfs(sysType sysfs.MemoryType) Type
TypeForSysfs returns the memory type for the given sysfs memory type.
func (Type) MarshalJSON ¶
MarshalJSON is the json.Marshaller for Type.
func (Type) Sysfs ¶
func (t Type) Sysfs() sysfs.MemoryType
Sysfs returns the sysfs memory type for the given memory type.
func (*Type) UnmarshalJSON ¶
UnmarshalJSON is the json.Unmarshaller for Type.
type TypeMask ¶
type TypeMask int
TypeMask represents a set of memory types as a bit mask.
func MustParseTypeMask ¶
MustParseTypeMask parses the given string into a TypeMask. It panicks on failure.
func NewTypeMask ¶
NewTypeMask returns a TypeMask containing the given memory types.
func NewTypeMaskForSysfs ¶
func NewTypeMaskForSysfs(sysTypes ...sysfs.MemoryType) TypeMask
NewTypeMaskForSysfs returns a TypeMask containing th given sysfs memory types.
func ParseTypeMask ¶
ParseTypeMask parses the given string into a TypeMask.
func (TypeMask) Contains ¶
Contains returns true if all the given types are present in the TypeMask.
func (TypeMask) ContainsAny ¶
ContainsAny returns true if any of the given types are present in the TypeMask.
func (TypeMask) Foreach ¶
Foreach calls the given function for each type present in the TypeMask until the function returns false, or ForeachDone. Iteration continues if the returned value is true, or ForeachMore.
func (TypeMask) MarshalJSON ¶
MarshalJSON is the json.Marshaller for TypeMask.
func (TypeMask) Or ¶
And returns a TypeMask with all IDs which are present at least in one of the masks.
func (*TypeMask) UnmarshalJSON ¶
UnmarshalJSON is the json.Unmarshaller for TypeMask.
type Zone ¶
type Zone struct {
// contains filtered or unexported fields
}
Zone is a collection of Nodes which is collectively used to fulfill one or more allocation requests.
type ZoneSorter ¶
ZoneSorter is a function to compare zones for sorting.