Documentation ¶
Index ¶
- Constants
- func CheckNUMACrossSockets(numaNodes []int, cpuTopology *CPUTopology) (bool, error)
- func CountCPUAssignmentCPUs(assignment map[int]CPUSet) int
- func DeepcopyCPUAssignment(assignment map[int]CPUSet) map[int]CPUSet
- func Discover(machineInfo *info.MachineInfo) (*CPUTopology, *MemoryTopology, error)
- func GenerateDummyMachineInfo(numaNum int, memoryCapacityGB int) (*info.MachineInfo, error)
- func GetCoreNumReservedForReclaim(numReservedCores, numNumaNodes int) map[int]int
- func GetNumaAwareAssignments(topology *CPUTopology, cset CPUSet) (map[int]CPUSet, error)
- func IterateBitMasks(bits []int, maxBits int, callback func(BitMask))
- func MaskToUInt64Array(mask BitMask) []uint64
- func ParseCPUAssignmentFormat(assignments map[int]CPUSet) map[uint64]string
- func ParseCPUAssignmentQuantityMap(csetMap map[string]map[int]CPUSet) map[string]map[int]int
- func StringToUint64(s string) uint64
- func TransformCPUAssignmentFormat(assignment map[uint64]string) map[int]CPUSet
- type BitMask
- type CPUDetails
- func (d CPUDetails) CPUs() CPUSet
- func (d CPUDetails) CPUsInCores(ids ...int) CPUSet
- func (d CPUDetails) CPUsInNUMANodes(ids ...int) CPUSet
- func (d CPUDetails) CPUsInSockets(ids ...int) CPUSet
- func (d CPUDetails) Cores() CPUSet
- func (d CPUDetails) CoresInNUMANodes(ids ...int) CPUSet
- func (d CPUDetails) CoresInSockets(ids ...int) CPUSet
- func (d CPUDetails) KeepOnly(cpus CPUSet) CPUDetails
- func (d CPUDetails) NUMANodes() CPUSet
- func (d CPUDetails) NUMANodesInSockets(ids ...int) CPUSet
- func (d CPUDetails) Sockets() CPUSet
- func (d CPUDetails) SocketsInNUMANodes(ids ...int) CPUSet
- type CPUInfo
- type CPUSet
- func (s CPUSet) Add(elems ...int)
- func (s CPUSet) AddUint64(elems ...uint64) error
- func (s CPUSet) Clone() CPUSet
- func (s CPUSet) Contains(cpu int) bool
- func (s CPUSet) Difference(s2 CPUSet) CPUSet
- func (s CPUSet) Equals(s2 CPUSet) bool
- func (s CPUSet) Filter(predicate func(int) bool) CPUSet
- func (s CPUSet) FilterNot(predicate func(int) bool) CPUSet
- func (s CPUSet) Intersection(s2 CPUSet) CPUSet
- func (s CPUSet) IsEmpty() bool
- func (s CPUSet) IsSubsetOf(s2 CPUSet) bool
- func (s CPUSet) MarshalJSON() ([]byte, error)
- func (s CPUSet) Size() int
- func (s CPUSet) String() string
- func (s CPUSet) ToSliceInt() []int
- func (s CPUSet) ToSliceInt64() []int64
- func (s CPUSet) ToSliceIntReversely() []int
- func (s CPUSet) ToSliceNoSortInt() []int
- func (s CPUSet) ToSliceNoSortInt64() []int64
- func (s CPUSet) ToSliceNoSortUInt64() []uint64
- func (s CPUSet) ToSliceUInt64() []uint64
- func (s CPUSet) Union(s2 CPUSet) CPUSet
- func (s CPUSet) UnionAll(s2 []CPUSet) CPUSet
- func (s *CPUSet) UnmarshalJSON(b []byte) error
- type CPUTopology
- type ExtraCPUInfo
- type ExtraNetworkInfo
- type ExtraTopologyInfo
- type IfaceAddr
- type InterfaceInfo
- type KatalystMachineInfo
- type MemoryDetails
- type MemoryTopology
- type NUMANodeInfo
- type NormalZoneInfo
- type NumaDistanceInfo
- type SiblingNumaInfo
Constants ¶
const ( DefaultNICNamespace = "" IPVersionV4 = 4 IPVersionV6 = 6 )
const ( LargeNUMAsPoint = 16 MBWNUMAsPoint = 8 )
Variables ¶
This section is empty.
Functions ¶
func CheckNUMACrossSockets ¶
func CheckNUMACrossSockets(numaNodes []int, cpuTopology *CPUTopology) (bool, error)
CheckNUMACrossSockets judges whether the given NUMA nodes are located in different sockets
func CountCPUAssignmentCPUs ¶ added in v0.2.0
CountCPUAssignmentCPUs returns sum of cpus among all numas in assignment
func DeepcopyCPUAssignment ¶ added in v0.2.0
DeepcopyCPUAssignment returns a deep-copied assignments for the given one
func Discover ¶
func Discover(machineInfo *info.MachineInfo) (*CPUTopology, *MemoryTopology, error)
Discover returns CPUTopology based on cadvisor node info
func GenerateDummyMachineInfo ¶
func GenerateDummyMachineInfo(numaNum int, memoryCapacityGB int) (*info.MachineInfo, error)
func GetCoreNumReservedForReclaim ¶ added in v0.3.0
GetCoreNumReservedForReclaim generates per numa reserved for reclaim resource value map. per numa reserved resource is taken in a fair way with even step, e.g. 4 -> 1 1 1 1; 2 -> 1 0 1 0
func GetNumaAwareAssignments ¶
func GetNumaAwareAssignments(topology *CPUTopology, cset CPUSet) (map[int]CPUSet, error)
GetNumaAwareAssignments returns a mapping from NUMA id to cpu core
func IterateBitMasks ¶ added in v0.5.8
IterateBitMasks iterates all possible masks from a list of bits, issuing a callback on each mask.
func MaskToUInt64Array ¶ added in v0.2.0
MaskToUInt64Array transforms bit mask to uint slices
func ParseCPUAssignmentFormat ¶ added in v0.2.0
ParseCPUAssignmentFormat parses the given assignments into string format
func ParseCPUAssignmentQuantityMap ¶ added in v0.3.0
ParseCPUAssignmentQuantityMap is used to generate cpu resource counting map based on the given CPUSet map
func StringToUint64 ¶ added in v0.5.9
Types ¶
type BitMask ¶ added in v0.5.8
type BitMask interface { Add(bits ...int) error Remove(bits ...int) error And(masks ...BitMask) Or(masks ...BitMask) Clear() Fill() IsEqual(mask BitMask) bool IsEmpty() bool IsSet(bit int) bool AnySet(bits []int) bool IsNarrowerThan(mask BitMask) bool String() string Count() int GetBits() []int }
BitMask interface allows hint providers to create BitMasks for TopologyHints
func NewBitMask ¶ added in v0.5.8
NewBitMask creates a new BitMask
func NewEmptyBitMask ¶ added in v0.5.8
func NewEmptyBitMask() BitMask
NewEmptyBitMask creates a new, empty BitMask
type CPUDetails ¶
CPUDetails is a map from CPU ID to Core ID, Socket ID, and NUMA ID.
func (CPUDetails) CPUs ¶
func (d CPUDetails) CPUs() CPUSet
CPUs returns all logical CPU IDs in this CPUDetails.
func (CPUDetails) CPUsInCores ¶
func (d CPUDetails) CPUsInCores(ids ...int) CPUSet
CPUsInCores returns all logical CPU IDs associated with the given core IDs in this CPUDetails.
func (CPUDetails) CPUsInNUMANodes ¶
func (d CPUDetails) CPUsInNUMANodes(ids ...int) CPUSet
CPUsInNUMANodes returns all logical CPU IDs associated with the given NUMANode IDs in this CPUDetails.
func (CPUDetails) CPUsInSockets ¶
func (d CPUDetails) CPUsInSockets(ids ...int) CPUSet
CPUsInSockets returns all logical CPU IDs associated with the given socket IDs in this CPUDetails.
func (CPUDetails) Cores ¶
func (d CPUDetails) Cores() CPUSet
Cores returns all core IDs associated with the CPUs in this CPUDetails.
func (CPUDetails) CoresInNUMANodes ¶
func (d CPUDetails) CoresInNUMANodes(ids ...int) CPUSet
CoresInNUMANodes returns all core IDs associated with the given NUMANode IDs in this CPUDetails.
func (CPUDetails) CoresInSockets ¶
func (d CPUDetails) CoresInSockets(ids ...int) CPUSet
CoresInSockets returns all core IDs associated with the given socket IDs in this CPUDetails.
func (CPUDetails) KeepOnly ¶
func (d CPUDetails) KeepOnly(cpus CPUSet) CPUDetails
KeepOnly returns a new CPUDetails object with only the supplied cpus.
func (CPUDetails) NUMANodes ¶
func (d CPUDetails) NUMANodes() CPUSet
NUMANodes returns all NUMANode IDs associated with the CPUs in this CPUDetails.
func (CPUDetails) NUMANodesInSockets ¶
func (d CPUDetails) NUMANodesInSockets(ids ...int) CPUSet
NUMANodesInSockets returns all logical NUMANode IDs associated with the given socket IDs in this CPUDetails.
func (CPUDetails) Sockets ¶
func (d CPUDetails) Sockets() CPUSet
Sockets returns all socket IDs associated with the CPUs in this CPUDetails.
func (CPUDetails) SocketsInNUMANodes ¶
func (d CPUDetails) SocketsInNUMANodes(ids ...int) CPUSet
SocketsInNUMANodes returns all logical Socket IDs associated with the given NUMANode IDs in this CPUDetails.
type CPUSet ¶
type CPUSet struct { // nil elems and empty elems both will be unmarshal to // empty elems, so we must use Initialed property to identify them Initialed bool // contains filtered or unexported fields }
func GetCPUAssignmentNUMAs ¶ added in v0.3.0
GetCPUAssignmentNUMAs returns memset for cpuset
func GetSiblingNUMAs ¶ added in v0.2.0
func GetSiblingNUMAs(numaID int, topology *CPUTopology) (CPUSet, error)
GetSiblingNUMAs returns numa IDs that lays in the socket with the given numa
func MustParse ¶
MustParse CPUSet constructs a new CPU set from a Linux CPU list formatted string. Unlike Parse, it does not return an error but rather panics if the input cannot be used to construct a CPU set.
func NewCPUSetUint64 ¶ added in v0.2.0
func Parse ¶
Parse CPUSet constructs a new CPU set from a Linux CPU list formatted string.
See: http://man7.org/linux/man-pages/man7/cpuset.7.html#FORMATS
func (CPUSet) AddUint64 ¶ added in v0.2.0
AddUint64 adds the supplied uint64 elements to the result.
func (CPUSet) Difference ¶
Difference returns a new CPU set that contains all of the elements that are present in this set and not the supplied set, without mutating either source set.
func (CPUSet) Equals ¶
Equals returns true if the supplied set contains exactly the same elements as this set (s IsSubsetOf s2 and s2 IsSubsetOf s).
func (CPUSet) Filter ¶
Filter returns a new CPU set that contains all elements from this set that match the supplied predicate, without mutating the source set.
func (CPUSet) FilterNot ¶
FilterNot returns a new CPU set that contains all elements from this set that do not match the supplied predicate, without mutating the source set.
func (CPUSet) Intersection ¶
Intersection returns a new CPU set that contains all of the elements that are present in both this set and the supplied set, without mutating either source set.
func (CPUSet) IsSubsetOf ¶
IsSubsetOf returns true if the supplied set contains all the elements
func (CPUSet) MarshalJSON ¶
func (CPUSet) String ¶
String returns a new string representation of the elements in this CPU set in canonical linux CPU list format.
See: http://man7.org/linux/man-pages/man7/cpuset.7.html#FORMATS
func (CPUSet) ToSliceInt ¶
ToSliceInt returns an ordered slice of int that contains all elements from this set
func (CPUSet) ToSliceInt64 ¶
ToSliceInt64 returns an ordered slice of int64 that contains all elements from this set
func (CPUSet) ToSliceIntReversely ¶ added in v0.5.5
ToSliceInt returns an resersely ordered slice of int that contains all elements from this set
func (CPUSet) ToSliceNoSortInt ¶
ToSliceNoSortInt returns an ordered slice of int that contains all elements from this set
func (CPUSet) ToSliceNoSortInt64 ¶
ToSliceNoSortInt64 returns an ordered slice of int64 that contains all elements from this set
func (CPUSet) ToSliceNoSortUInt64 ¶
ToSliceNoSortUInt64 returns an ordered slice of uint64 that contains all elements from this set
func (CPUSet) ToSliceUInt64 ¶
ToSliceUInt64 returns an ordered slice of uint64 that contains all elements from this set
func (CPUSet) Union ¶
Union returns a new CPU set that contains all elements from this set and all elements from the supplied set, without mutating either source set.
func (CPUSet) UnionAll ¶
UnionAll returns a new CPU set that contains all elements from this set and all elements from the supplied sets, without mutating either source set.
func (*CPUSet) UnmarshalJSON ¶
type CPUTopology ¶
type CPUTopology struct { NumCPUs int NumCores int NumSockets int NumNUMANodes int NUMANodeIDToSocketID map[int]int CPUDetails CPUDetails }
CPUTopology contains details of node cpu, where : CPU - logical CPU, cadvisor - thread Core - physical CPU, cadvisor - Core Socket - socket, cadvisor - Socket NUMA Node - NUMA cell, cadvisor - Node
func GenerateDummyCPUTopology ¶
func GenerateDummyCPUTopology(cpuNum, socketNum, numaNum int) (*CPUTopology, error)
func (*CPUTopology) CPUsPerCore ¶
func (topo *CPUTopology) CPUsPerCore() int
CPUsPerCore returns the number of logical CPUs associated with each core.
func (*CPUTopology) CPUsPerNuma ¶ added in v0.2.0
func (topo *CPUTopology) CPUsPerNuma() int
CPUsPerNuma returns the number of logical CPUs associated with each numa node.
func (*CPUTopology) CPUsPerSocket ¶
func (topo *CPUTopology) CPUsPerSocket() int
CPUsPerSocket returns the number of logical CPUs associated with each socket.
func (*CPUTopology) GetSocketTopology ¶
func (topo *CPUTopology) GetSocketTopology() map[int]string
GetSocketTopology parses the given CPUTopology to a mapping from socket id to cpu id lists
func (*CPUTopology) NUMAsPerSocket ¶
func (topo *CPUTopology) NUMAsPerSocket() (int, error)
NUMAsPerSocket returns the the number of NUMA are associated with each socket.
type ExtraCPUInfo ¶
type ExtraCPUInfo struct { // SupportInstructionSet instructions all cpus support. SupportInstructionSet sets.String }
func GetExtraCPUInfo ¶
func GetExtraCPUInfo() (*ExtraCPUInfo, error)
GetExtraCPUInfo get extend cpu info from proc system
type ExtraNetworkInfo ¶
type ExtraNetworkInfo struct { // Interface info list of all network interface. Interface []InterfaceInfo }
func GetExtraNetworkInfo ¶
func GetExtraNetworkInfo(conf *global.MachineInfoConfiguration) (*ExtraNetworkInfo, error)
GetExtraNetworkInfo get network info from /sys/class/net and system function net.Interfaces. if multiple network namespace is enabled, we should exec into all namespaces and parse nics for them.
type ExtraTopologyInfo ¶ added in v0.4.1
type ExtraTopologyInfo struct { NumaDistanceMap map[int][]NumaDistanceInfo *SiblingNumaInfo }
func GenerateDummyExtraTopology ¶ added in v0.4.1
func GenerateDummyExtraTopology(numaNum int) (*ExtraTopologyInfo, error)
func GetExtraTopologyInfo ¶ added in v0.4.1
func GetExtraTopologyInfo(conf *global.MachineInfoConfiguration) (*ExtraTopologyInfo, error)
type InterfaceInfo ¶
type InterfaceInfo struct { // Iface name of this interface. Iface string // Speed of this interface. Speed int // NumaNode numa node of this interface belongs to. NumaNode int // Enable whether enable this interface. Enable bool // Addr address of this interface, which includes ipv4 and ipv6. Addr *IfaceAddr // NSName indicates the namespace for this interface NSName string // NSAbsolutePath indicates the namespace path for this interface NSAbsolutePath string }
func (*InterfaceInfo) GetNICIPs ¶ added in v0.2.0
func (nic *InterfaceInfo) GetNICIPs(ipVersion int) []string
type KatalystMachineInfo ¶
type KatalystMachineInfo struct { *info.MachineInfo // actually, CPUTopology can be generated by info.MachineInfo, // but we still keep it since it construct topology info in a // more convenient way *CPUTopology *MemoryTopology // ExtraCPUInfo is extra cpu info not in MachineInfo, such as // supported instructions *ExtraCPUInfo // ExtraNetworkInfo is extra network info not in MachineInfo, // such as numa node of each interface *ExtraNetworkInfo // ExtraTopologyInfo is extra topology info not in MachineInfo, // such as numa node distance between each other *ExtraTopologyInfo }
KatalystMachineInfo is a combination of machine info generated by cadvisor, along with the extra info customized in katalyst environment
func GetKatalystMachineInfo ¶
func GetKatalystMachineInfo(conf *global.MachineInfoConfiguration) (*KatalystMachineInfo, error)
GetKatalystMachineInfo returns KatalystMachineInfo by collecting machine info actually, this function should be only called in initial processes
type MemoryDetails ¶ added in v0.3.0
func (MemoryDetails) Clone ¶ added in v0.4.0
func (d MemoryDetails) Clone() MemoryDetails
Clone creates a new MemoryDetails instance with the same content.
func (MemoryDetails) Equal ¶ added in v0.4.0
func (d MemoryDetails) Equal(want MemoryDetails) bool
Equal returns true if the MemoryDetails map is equal to the supplied MemoryDetails
func (MemoryDetails) FillNUMANodesWithZero ¶ added in v0.4.0
func (d MemoryDetails) FillNUMANodesWithZero(allNUMAs CPUSet) MemoryDetails
FillNUMANodesWithZero takes a CPUSet containing NUMA node IDs and ensures that each ID is present in MemoryDetails. If a NUMA node ID from the CPUSet is not present in the MemoryDetails map, it is added with a value of 0. The method returns an updated MemoryDetails map with these changes.
type MemoryTopology ¶ added in v0.3.0
type MemoryTopology struct {
MemoryDetails MemoryDetails
}
func GenerateDummyMemoryTopology ¶ added in v0.3.0
func GenerateDummyMemoryTopology(numaNum int, memoryCapacity uint64) (*MemoryTopology, error)
type NUMANodeInfo ¶
NUMANodeInfo is a map from NUMANode ID to a list of CPU IDs associated with that NUMANode.
type NormalZoneInfo ¶ added in v0.5.9
func GetNormalZoneInfo ¶ added in v0.5.9
func GetNormalZoneInfo(zoneInfoPath string) []NormalZoneInfo
type NumaDistanceInfo ¶ added in v0.4.1
type SiblingNumaInfo ¶ added in v0.5.1
type SiblingNumaInfo struct { SiblingNumaMap map[int]sets.Int // SiblingNumaAvgMBWAllocatableMap maps NUMA IDs to the allocatable memory bandwidth, // averaged across each NUMA node and its siblings. // SiblingNumaAvgMBWCapacityMap maps NUMA IDs to the capacity memory bandwidth, // averaged similarly. SiblingNumaAvgMBWAllocatableMap map[int]int64 SiblingNumaAvgMBWCapacityMap map[int]int64 }
func GetSiblingNumaInfo ¶ added in v0.5.1
func GetSiblingNumaInfo(conf *global.MachineInfoConfiguration, numaDistanceMap map[int][]NumaDistanceInfo, ) *SiblingNumaInfo