machine

package
v0.5.38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 37 Imported by: 29

Documentation

Index

Constants

View Source
const (
	DefaultNICNamespace = ""

	IPVersionV4 = 4
	IPVersionV6 = 6

	ContainerNetNSPrefix = "cni-"
)
View Source
const (
	SIOCETHTOOL       = 0x8946
	ETHTOOL_GCHANNELS = 0x0000003c
)

ioctl constants from <linux/sockios.h>, <linux/ethtool.h>

View Source
const (
	DefaultNetNSDir    = "/var/run/netns"
	DefaultNetNSSysDir = "/sys"
	TmpNetNSSysDir     = "/qrm_tmp_sys/net_ns_sysfs"
	ClassNetBasePath   = "class/net"
	ClassNetFulPath    = "/sys/class/net"
	VirtioNetDriver    = "virtio_net"
	IrqRootPath        = "/proc/irq"
	InterruptsFile     = "/proc/interrupts"
	NetDevProcFile     = "/proc/net/dev"
	SoftnetStatFile    = "/proc/net/softnet_stat"
	SoftIrqsFile       = "/proc/softirqs"
)
View Source
const (
	// L3CacheLevel represents the cache level for L3 cache
	L3CacheLevel = 3
	L3CacheType  = "Unified"
)
View Source
const (
	LargeNUMAsPoint = 16
)
View Source
const UnknownNumaNode = -1

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 ClearNicRxQueueRPS added in v0.5.32

func ClearNicRxQueueRPS(nic *NicBasicInfo, queue int) error

func ClearNicTxQueueXPS added in v0.5.35

func ClearNicTxQueueXPS(nic *NicBasicInfo, queue int) error

func CollectCpuStats added in v0.5.32

func CollectCpuStats() (map[int64]*CPUStat, error)

func CollectNetRxSoftirqStats added in v0.5.32

func CollectNetRxSoftirqStats() (map[int64]uint64, error)

func CollectSoftNetStats added in v0.5.32

func CollectSoftNetStats(onlineCpus map[int64]bool) (map[int64]*SoftNetStat, error)

func CompareNics added in v0.5.32

func CompareNics(a, b []*NicBasicInfo) bool

func ComparesHexBitmapStrings added in v0.5.32

func ComparesHexBitmapStrings(a string, b string) bool

func CountCPUAssignmentCPUs added in v0.2.0

func CountCPUAssignmentCPUs(assignment map[int]CPUSet) int

CountCPUAssignmentCPUs returns sum of cpus among all numas in assignment

func DeepcopyCPUAssignment added in v0.2.0

func DeepcopyCPUAssignment(assignment map[int]CPUSet) map[int]CPUSet

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 DoNetNS added in v0.5.22

func DoNetNS(nsName, netNSDirAbsPath string, cb func(sysFsDir string) error) error

DoNetNS executes a callback function within the specified network namespace. For the default namespace, runs callback in current namespace without modification. For other namespaces: 1. Locks OS thread to maintain namespace context 2. Creates temporary sysfs mount to isolate from host 3. Executes callback with isolated sysfs path 4. Cleans up mount and restores original namespace

func GenerateDummyMachineInfo

func GenerateDummyMachineInfo(numaNum int, memoryCapacityGB int) (*info.MachineInfo, error)

func GetCPUFlags added in v0.5.35

func GetCPUFlags() ([]string, error)

GetCPUFlags get cpu flags from proc fs.

func GetCPUOnlineStatus added in v0.5.32

func GetCPUOnlineStatus(cpuID int64) (bool, error)

func GetCPUPackageID added in v0.5.32

func GetCPUPackageID(cpuID int64) (int, error)

func GetCacheGroupCPUs added in v0.5.35

func GetCacheGroupCPUs(machineInfo *info.MachineInfo) map[int]sets.Int

func GetCoreNumReservedForReclaim added in v0.3.0

func GetCoreNumReservedForReclaim(numReservedCores, numNumaNodes int) map[int]int

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 1 1 1; 8 -> 2 2 2 2;

func GetIfIndex added in v0.5.32

func GetIfIndex(nicName string, nicSysPath string) (int, error)

func GetIfIndexFromSys added in v0.5.32

func GetIfIndexFromSys(nicSysPath string) (int, error)

func GetIrqAffinityCPUs added in v0.5.32

func GetIrqAffinityCPUs(irq int) ([]int64, error)

func GetIrqsAffinityCPUs added in v0.5.32

func GetIrqsAffinityCPUs(irqs []int) (map[int][]int64, error)

GetIrqsAffinityCPUs before irq tuning initialization, one irq's smp_affinity_list may has multiple cpus after irq tuning initialization, one irq only affinity one cpu.

func GetLLCDomainCPUList added in v0.5.32

func GetLLCDomainCPUList(llcDomain *LLCDomain) []int64

func GetNetDevRxPackets added in v0.5.32

func GetNetDevRxPackets(nic *NicBasicInfo) (uint64, error)

func GetNicIrqs added in v0.5.32

func GetNicIrqs(nicSysPath string) ([]int, error)

GetNicIrqs get nic's all irqs, including rx-tx irqs, and some irqs used for control

func GetNicNumaNode added in v0.5.32

func GetNicNumaNode(nicSysPath string) (int, error)

GetNicNumaNode get nic's numa node, /sys/class/net/ethX/device/numa_node not exist, or contains negative value, then return -1 as unknown socket bind

func GetNicPCIAddr added in v0.5.32

func GetNicPCIAddr(nicSysPath string) (string, error)

func GetNicQueue2Irq added in v0.5.32

func GetNicQueue2Irq(nicInfo *NicBasicInfo) (map[int]int, map[int]int, error)

GetNicQueue2Irq get nic queue naming in /proc/interrrupts

func GetNicQueue2IrqWithQueueFilter added in v0.5.32

func GetNicQueue2IrqWithQueueFilter(nicInfo *NicBasicInfo, queueFilters []string, queueDelimeter string) (map[int]int, error)

GetNicQueue2IrqWithQueueFilter get the queue to irq map with queue filter the "same" queue may match multiple irqs, e.g., nics with the same name from different netns and sriov vfs queueFilters can not be empty.

func GetNicQueuesCount added in v0.5.35

func GetNicQueuesCount(nicName string) (int, error)

func GetNicRxQueuePackets added in v0.5.32

func GetNicRxQueuePackets(nic *NicBasicInfo) (map[int]uint64, error)

func GetNicRxQueueRpsConf added in v0.5.32

func GetNicRxQueueRpsConf(nic *NicBasicInfo, queue int) (string, error)

func GetNicRxQueuesRpsConf added in v0.5.32

func GetNicRxQueuesRpsConf(nic *NicBasicInfo) (map[int]string, error)

func GetNicTxQueuesXpsConf added in v0.5.35

func GetNicTxQueuesXpsConf(nic *NicBasicInfo) (map[int]string, error)

func GetNicVirtioName added in v0.5.32

func GetNicVirtioName(nicSysPath string) (string, error)

func GetNodeCount added in v0.5.32

func GetNodeCount() (int, error)

func GetNumaAwareAssignments

func GetNumaAwareAssignments(topology *CPUTopology, cset CPUSet) (map[int]CPUSet, error)

GetNumaAwareAssignments returns a mapping from NUMA id to cpu core

func GetNumaPackageID added in v0.5.32

func GetNumaPackageID(nodeID int) (int, error)

func GetSocketCount added in v0.5.32

func GetSocketCount() (int, error)

func GetThreadSiblingInfo added in v0.5.35

func GetThreadSiblingInfo(machineInfo *info.MachineInfo) map[int]int

func IsBondingNetDevice added in v0.5.32

func IsBondingNetDevice(nicSysPath string) bool

func IsContainerNetNS added in v0.5.35

func IsContainerNetNS(netnsName string) bool

func IsNetDevLinkUp added in v0.5.32

func IsNetDevLinkUp(nicSysPath string) bool

func IsPCIDevice added in v0.5.32

func IsPCIDevice(nicSysPath string) bool

nicSysPath like "/sys/class/net/eth0" N.B., bnx sriov vf dose not hava corresponding /sys/class/net/ethx_y/device file

func IsVirtioNetDevice added in v0.5.32

func IsVirtioNetDevice(nicSysPath string) bool

func IsZeroBitmap added in v0.5.32

func IsZeroBitmap(bitmapStr string) bool

func IterateBitMasks added in v0.5.8

func IterateBitMasks(bits []int, maxBits int, callback func(BitMask))

IterateBitMasks iterates all possible masks from a list of bits, issuing a callback on each mask.

func ListBondNetDevSlaves added in v0.5.32

func ListBondNetDevSlaves(nicSysPath string) ([]string, error)

func ListInterfacesWithIPAddr added in v0.5.32

func ListInterfacesWithIPAddr() ([]string, error)

ListInterfacesWithIPAddr list interfaces with ip address

func MaskToUInt64Array added in v0.2.0

func MaskToUInt64Array(mask BitMask) []uint64

MaskToUInt64Array transforms bit mask to uint slices

func NetNSExist added in v0.5.34

func NetNSExist(ns NetNSInfo) bool

func ParseCPUAssignmentFormat added in v0.2.0

func ParseCPUAssignmentFormat(assignments map[int]CPUSet) map[uint64]string

ParseCPUAssignmentFormat parses the given assignments into string format

func ParseCPUAssignmentQuantityMap added in v0.3.0

func ParseCPUAssignmentQuantityMap(csetMap map[string]map[int]CPUSet) map[string]map[int]int

ParseCPUAssignmentQuantityMap is used to generate cpu resource counting map based on the given CPUSet map

func SetIrqAffinity added in v0.5.32

func SetIrqAffinity(irq int, cpu int64) error

func SetIrqAffinityCPUs added in v0.5.32

func SetIrqAffinityCPUs(irq int, cpus []int64) error

func SetNicRxQueueRPS added in v0.5.32

func SetNicRxQueueRPS(nic *NicBasicInfo, queue int, destCpus []int64) error

func SetNicTxQueueXPS added in v0.5.35

func SetNicTxQueueXPS(nic *NicBasicInfo, queue int, destCpus []int64) error

func SmtActive added in v0.5.16

func SmtActive() bool

func StringToUint64 added in v0.5.9

func StringToUint64(s string) uint64

func TidyUpNicIrqsAffinityCPUs added in v0.5.32

func TidyUpNicIrqsAffinityCPUs(irq2CPUs map[int][]int64) (map[int]int64, error)

TidyUpNicIrqsAffinityCPUs re-configure irqs's affinity according to irq's cpu assignment(kernel apic_set_affinity -> irq_matrix_alloc -> matrix_find_best_cpu) to make one irq affinity only one cpu. TidyUpNicIrqsAffinityCPUs may change irqs's actual affinitied cpu, because we do not know these cpus's affinitied irqs of other devices, include irqs of other nics, it's corner case that need to tidy up irqs affinity.

func TransformCPUAssignmentFormat added in v0.2.0

func TransformCPUAssignmentFormat(assignment map[uint64]string) map[int]CPUSet

TransformCPUAssignmentFormat transforms cpu assignment string format to cpuset format

Types

type AMDNuma added in v0.5.32

type AMDNuma struct {
	CCDs []*LLCDomain
}

type AllocatableInterfaceSocketInfo added in v0.5.22

type AllocatableInterfaceSocketInfo struct {
	// IfIndex2Sockets maps allocatable network interface indexes to
	// the sockets they belong to.
	// Socket2IfIndexes maps sockets to the allocatable network interface indexes
	// they contain.
	IfIndex2Sockets  map[int][]int
	Socket2IfIndexes map[int][]int
}

func GetInterfaceSocketInfo added in v0.5.22

func GetInterfaceSocketInfo(nics []InterfaceInfo, sockets []int) (*AllocatableInterfaceSocketInfo, error)

GetInterfaceSocketInfo assigns network interfaces (NICs) to CPU sockets based on NUMA topology.

It takes a list of available network interfaces (`nics`) and a `cpuTopology` structure. The function attempts to distribute NICs evenly across sockets while considering NUMA affinity.

The resulting mappings are: - `IfIndex2Sockets`: Maps each NIC index to the socket(s) it is assigned to. - `Socket2IfIndexes`: Maps each socket to the NIC indices assigned to it.

The logic follows these steps: 1. If there are no sockets, return an error. 2. Retrieve available sockets from `cpuTopology`. 3. Initialize mappings and track socket usage. 4. Compute an ideal maximum number of NICs per socket to balance the distribution. 5. Assign NICs to sockets based on:

  • NUMA affinity when possible.
  • Least-used socket when NUMA binding is unavailable or overloaded.

6. Populate the mappings and return them.

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 And added in v0.5.8

func And(first BitMask, masks ...BitMask) BitMask

And is a package level implementation of 'and' between first and masks

func NewBitMask added in v0.5.8

func NewBitMask(bits ...int) (BitMask, error)

NewBitMask creates a new BitMask

func NewEmptyBitMask added in v0.5.8

func NewEmptyBitMask() BitMask

NewEmptyBitMask creates a new, empty BitMask

func Or added in v0.5.8

func Or(first BitMask, masks ...BitMask) BitMask

Or is a package level implementation of 'or' between first and masks

type CPUDetails

type CPUDetails map[int]CPUTopoInfo

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) CPUsInL3Caches added in v0.5.35

func (d CPUDetails) CPUsInL3Caches(ids ...int) CPUSet

CPUsInL3Caches returns all logical CPU IDs associated with the given l3Cache 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) L3Caches added in v0.5.35

func (d CPUDetails) L3Caches() CPUSet

L3Caches returns all l3Cache IDs associated with the CPUs in this CPUDetails.

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 CPUInfo

type CPUInfo struct {
	CPUVendor  cpuid.Vendor
	Sockets    map[int]*CPUSocket
	CPU2Socket map[int64]int  // cpu id as map key, socket id as map value
	CPUOnline  map[int64]bool // cpu id as map key, CPUOnline contains all online cpus, but not contains any offline cpu
}

CPUInfo is the cpu info, generally all cpus shown in below files are online, i.e. CPUInfo managed all CPUs are online, CPUOnline is needless, keep it temporarily * /sys/devices/system/node/node{nodeid}/cpulist * /sys/devices/system/cpu/cpu{cpuid}/topology/{thread_siblings_list,core_cpus_list,core_siblings_list,package_cpus_list} * /sys/devices/system/cpu/cpu{cpuid}/cache/index{0,1,2,3}/shared_cpu_list

func GetCPUInfoWithTopo added in v0.5.32

func GetCPUInfoWithTopo() (*CPUInfo, error)

GetCPUInfoWithTopo get cpu info with topo https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-devices-system-cpu

func (*CPUInfo) GetAMDNumaCCDs added in v0.5.32

func (c *CPUInfo) GetAMDNumaCCDs(nodeID int) ([]*LLCDomain, error)

func (*CPUInfo) GetNodeCPUList added in v0.5.32

func (c *CPUInfo) GetNodeCPUList(nodeID int) []int64

func (*CPUInfo) GetSocketPhysicalCores added in v0.5.32

func (c *CPUInfo) GetSocketPhysicalCores(socketID int) []PhyCore

func (*CPUInfo) GetSocketSlice added in v0.5.32

func (c *CPUInfo) GetSocketSlice() []int

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

func GetCPUAssignmentNUMAs(assignment map[int]CPUSet) CPUSet

GetCPUAssignmentNUMAs returns memset for cpuset

func GetNICAllocateNUMAs added in v0.5.22

func GetNICAllocateNUMAs(nic InterfaceInfo, info *KatalystMachineInfo) (CPUSet, error)

GetNICAllocateNUMAs returns numa nodes that are allocated to the given nic

func MustParse

func MustParse(s string) CPUSet

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 NewCPUSet

func NewCPUSet(cpus ...int) CPUSet

func NewCPUSetInt64 added in v0.5.32

func NewCPUSetInt64(cpus ...int64) (CPUSet, error)

func NewCPUSetUint64 added in v0.2.0

func NewCPUSetUint64(cpus ...uint64) (CPUSet, error)

func Parse

func Parse(s string) (CPUSet, error)

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) Add

func (s CPUSet) Add(elems ...int)

Add adds the supplied elements to the result.

func (CPUSet) AddInt64 added in v0.5.32

func (s CPUSet) AddInt64(elems ...int64) error

AddInt64 adds the supplied int64 elements to the result.

func (CPUSet) AddUint64 added in v0.2.0

func (s CPUSet) AddUint64(elems ...uint64) error

AddUint64 adds the supplied uint64 elements to the result.

func (CPUSet) Clone

func (s CPUSet) Clone() CPUSet

func (CPUSet) Contains

func (s CPUSet) Contains(cpu int) bool

Contains returns true if the supplied element is present in this set.

func (CPUSet) Difference

func (s CPUSet) Difference(s2 CPUSet) CPUSet

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

func (s CPUSet) Equals(s2 CPUSet) bool

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

func (s CPUSet) Filter(predicate func(int) bool) CPUSet

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

func (s CPUSet) FilterNot(predicate func(int) bool) CPUSet

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

func (s CPUSet) Intersection(s2 CPUSet) CPUSet

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) IsEmpty

func (s CPUSet) IsEmpty() bool

IsEmpty returns true if there are zero elements in this set.

func (CPUSet) IsSubsetOf

func (s CPUSet) IsSubsetOf(s2 CPUSet) bool

IsSubsetOf returns true if the supplied set contains all the elements

func (CPUSet) MarshalJSON

func (s CPUSet) MarshalJSON() ([]byte, error)

func (CPUSet) Size

func (s CPUSet) Size() int

Size returns the number of elements in this set.

func (CPUSet) String

func (s CPUSet) String() 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

func (s CPUSet) ToSliceInt() []int

ToSliceInt returns an ordered slice of int that contains all elements from this set

func (CPUSet) ToSliceInt64

func (s CPUSet) ToSliceInt64() []int64

ToSliceInt64 returns an ordered slice of int64 that contains all elements from this set

func (CPUSet) ToSliceIntReversely added in v0.5.5

func (s CPUSet) ToSliceIntReversely() []int

ToSliceIntReversely returns a reverse ordered slice of int that contains all elements from this set

func (CPUSet) ToSliceNoSortInt

func (s CPUSet) ToSliceNoSortInt() []int

ToSliceNoSortInt returns an ordered slice of int that contains all elements from this set

func (CPUSet) ToSliceNoSortInt64

func (s CPUSet) ToSliceNoSortInt64() []int64

ToSliceNoSortInt64 returns an ordered slice of int64 that contains all elements from this set

func (CPUSet) ToSliceNoSortUInt64

func (s CPUSet) ToSliceNoSortUInt64() []uint64

ToSliceNoSortUInt64 returns an ordered slice of uint64 that contains all elements from this set

func (CPUSet) ToSliceUInt64

func (s CPUSet) ToSliceUInt64() []uint64

ToSliceUInt64 returns an ordered slice of uint64 that contains all elements from this set

func (CPUSet) Union

func (s CPUSet) Union(s2 CPUSet) CPUSet

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

func (s CPUSet) UnionAll(s2 []CPUSet) CPUSet

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

func (s *CPUSet) UnmarshalJSON(b []byte) error

type CPUSocket added in v0.5.32

type CPUSocket struct {
	NumaIDs    []int
	CPUs       []int64
	IntelNumas map[int]*LLCDomain // numa id as map key
	AMDNumas   map[int]*AMDNuma   // numa id as map key
}

type CPUStat added in v0.5.32

type CPUStat struct {
	User      uint64
	Nice      uint64
	System    uint64
	Idle      uint64
	Iowait    uint64
	Irq       uint64
	Softirq   uint64
	Steal     uint64 // %steal time means vcpu corresponding vcpu thread's sched-wait time in host, so %steal has meaningful value only in VM
	Guest     uint64 // %guest means vcpu thread's running time after enter guest, so %guest have meagningful value only in host
	GuestNice uint64 // %guest_nice means vcpu thread's running time after enter niced guest, so %guest_nice have meagningful value only in host
}

CPUStat is the cpu stat info ActiveTime = %user + %nice + %system + %irq + %softirq + %steal + %guest + %guest_nice IrqTime = %irq + %softirq TotalTime = ActiveTime + %idle + %iowait cpu util = (ActiveTime diff) / (TotalTime diff) irq (hardirq + softirq) cpu util = (SoftirqTime diff) / (TotalTime diff)

type CPUTopoInfo added in v0.5.32

type CPUTopoInfo struct {
	NUMANodeID int
	SocketID   int
	CoreID     int
	L3CacheID  int
}

CPUTopoInfo contains the NUMA, socket, and core IDs associated with a CPU.

type CPUTopology

type CPUTopology struct {
	NumCPUs              int
	NumCores             int
	NumSockets           int
	NumNUMANodes         int
	NUMANodeIDToSocketID map[int]int
	NUMAToCPUs           NUMANodeInfo
	CPUDetails           CPUDetails
	CPUInfo              *CPUInfo
}

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) 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 number of NUMA are associated with each socket.

type EthtoolChannels added in v0.5.35

type EthtoolChannels struct {
	Cmd           uint32
	MaxRx         uint32
	MaxTx         uint32
	MaxOther      uint32
	MaxCombined   uint32
	RxCount       uint32
	TxCount       uint32
	OtherCount    uint32
	CombinedCount uint32
}

Equivalent to kernel struct ethtool_channels

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 collects network interface information from /sys/class/net and net.Interfaces. When multiple network namespaces are enabled, it executes in each namespace to gather NIC information. Returns ExtraNetworkInfo containing all discovered network interfaces and their attributes.

func (ExtraNetworkInfo) GetAllocatableNICs added in v0.5.22

func (e ExtraNetworkInfo) GetAllocatableNICs(conf *global.MachineInfoConfiguration) []InterfaceInfo

type ExtraTopologyInfo added in v0.4.1

type ExtraTopologyInfo struct {
	NumaDistanceMap map[int][]NumaDistanceInfo
	*SiblingNumaInfo
	*AllocatableInterfaceSocketInfo
}

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, cpuTopology *CPUTopology, extraNetworkInfo *ExtraNetworkInfo) (*ExtraTopologyInfo, error)

type IfaceAddr

type IfaceAddr struct {
	IPV4 []*net.IP
	IPV6 []*net.IP
}

func GetInterfaceAddr added in v0.5.22

func GetInterfaceAddr(iface net.Interface) (*IfaceAddr, error)

func (*IfaceAddr) GetNICIPs added in v0.5.22

func (addr *IfaceAddr) GetNICIPs(ipVersion int) []string

type Ifreq added in v0.5.35

type Ifreq struct {
	Name [syscall.IFNAMSIZ]byte
	Data uintptr
}

Equivalent to kernel struct ifreq

type InterfaceInfo

type InterfaceInfo struct {
	// net namespace of this interface
	NetNSInfo
	// Iface name of this interface.
	Name string
	// IfIndex is an index of network interface.
	IfIndex int
	// 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
	// pci address(BDF) of this interface
	PCIAddr string // used to locate nic's irq line in some special scnerios
}

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 LLCDomain added in v0.5.32

type LLCDomain struct {
	PhyCores []PhyCore
}

LLCDomain last level cache domain, subnuma/numa for Intel, CCD for AMD

type MemoryDetails added in v0.3.0

type MemoryDetails map[int]uint64

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
	PageSize      int
}

func GenerateDummyMemoryTopology added in v0.3.0

func GenerateDummyMemoryTopology(numaNum int, memoryCapacity uint64) (*MemoryTopology, error)

func (*MemoryTopology) AlignToPageSize added in v0.5.29

func (memTopo *MemoryTopology) AlignToPageSize(memBytes int64) int64

AlignToPageSize returns the page numbers from mem numbers.

type NUMANodeInfo

type NUMANodeInfo map[int]CPUSet

NUMANodeInfo is a map from NUMANode ID to a list of CPU IDs associated with that NUMANode.

func (NUMANodeInfo) CPUSizeInNUMAs added in v0.5.27

func (i NUMANodeInfo) CPUSizeInNUMAs(nodes ...int) int

CPUSizeInNUMAs returns the number of logical CPUs associated with each numa nodes.

type NetNSInfo added in v0.5.32

type NetNSInfo struct {
	NSName   string
	NSInode  uint64 // used to compare with container's process's /proc/net/ns/net linked inode to get process's nents
	NSAbsDir string
}

func ListNetNS added in v0.5.32

func ListNetNS(netNSDir string) ([]NetNSInfo, error)

func (NetNSInfo) GetNetNSAbsPath added in v0.5.32

func (ns NetNSInfo) GetNetNSAbsPath() string

type NicBasicInfo added in v0.5.32

type NicBasicInfo struct {
	InterfaceInfo
	Driver         NicDriver // used to filter queue stats of ethtool stats, different driver has different format
	IsVirtioNetDev bool
	VirtioNetName  string // used to filter virtio nic's irqs in /proc/interrupts
	Irqs           []int  // store nic's all irqs including rx irqs, Irqs is used to resolve conflicts when there 2 active nics with the same name in /proc/interrupts
	QueueNum       int
	Queue2Irq      map[int]int
	Irq2Queue      map[int]int
	TxQueue2Irq    map[int]int
	TxIrq2Queue    map[int]int
}

func ListActiveUplinkNics added in v0.5.32

func ListActiveUplinkNics(netNSDir string, ignoredNetNSNamePrefixes []string) ([]*NicBasicInfo, error)

func ListActiveUplinkNicsFromNetNS added in v0.5.32

func ListActiveUplinkNicsFromNetNS(netnsInfo NetNSInfo) ([]*NicBasicInfo, error)

func (*NicBasicInfo) Equal added in v0.5.32

func (n *NicBasicInfo) Equal(other *NicBasicInfo) bool

func (*NicBasicInfo) String added in v0.5.32

func (n *NicBasicInfo) String() string

func (*NicBasicInfo) UniqName added in v0.5.32

func (n *NicBasicInfo) UniqName() string

type NicDriver added in v0.5.32

type NicDriver string
const (
	NicDriverMLX       NicDriver = "mlx"
	NicDriverBNX       NicDriver = "bnxt"
	NicDriverVirtioNet NicDriver = "virtio_net"
	NicDriverI40E      NicDriver = "i40e"
	NicDriverIXGBE     NicDriver = "ixgbe"
	NicDriverUnknown   NicDriver = "unknown"
)

type NormalZoneInfo added in v0.5.9

type NormalZoneInfo struct {
	Node         int64
	Free         uint64
	Min          uint64
	Low          uint64
	High         uint64
	FileInactive uint64
}

func GetNormalZoneInfo added in v0.5.9

func GetNormalZoneInfo(zoneInfoPath string) []NormalZoneInfo

type NumaDistanceInfo added in v0.4.1

type NumaDistanceInfo struct {
	NumaID   int
	Distance int
}

type PhyCore added in v0.5.32

type PhyCore struct {
	CPUs []int64
}

PhyCore is the physical core, if contains only one hyper-thread, means another one offline threads sorted in ascending order some CPU arch's one physical core may has more than 2 hyper-threads

type SiblingNumaInfo added in v0.5.1

type SiblingNumaInfo struct {
	SiblingNumaMap map[int]sets.Int

	// SiblingNumaAvgMBWAllocatableRateMap maps cpu codename to the according memory bandwidth allocatable rate
	// SiblingNumaAvgMBWCapacityMap maps NUMA IDs to the capacity memory bandwidth,
	// averaged across each NUMA node and its siblings.
	SiblingNumaAvgMBWAllocatableRateMap  map[string]float64
	SiblingNumaAvgMBWCapacityMap         map[int]int64
	SiblingNumaDefaultMBWAllocatableRate float64
}

func GetSiblingNumaInfo added in v0.5.1

func GetSiblingNumaInfo(
	conf *global.MachineInfoConfiguration,
	numaDistanceMap map[int][]NumaDistanceInfo,
) *SiblingNumaInfo

type SoftNetStat added in v0.5.32

type SoftNetStat struct {
	ProcessedPackets   uint64 // /proc/net/softnet_stat 1st col
	TimeSqueezePackets uint64 // /proc/net/softnet_stat 3rd col
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL