Documentation ¶
Index ¶
- Constants
- func FindSysFsDevice(dev string) (string, error)
- func ParseFileEntries(path string, values map[string]interface{}, pickFn PickEntryFn) error
- type CPU
- type CPUFreq
- type Cache
- type CacheType
- type DiscoveryFlag
- type ID
- type IDSet
- func (s IDSet) Add(ids ...ID)
- func (s IDSet) CPUSet() cpuset.CPUSet
- func (s IDSet) Clone() IDSet
- func (s IDSet) Del(ids ...ID)
- func (s IDSet) Has(ids ...ID) bool
- func (s IDSet) Members() []ID
- func (s IDSet) Size() int
- func (s IDSet) SortedMembers() []ID
- func (s IDSet) String() string
- func (s IDSet) StringWithSeparator(args ...string) string
- type MemInfo
- type Node
- type Package
- type PickEntryFn
- type System
- func (sys *System) CPU(id ID) *CPU
- func (sys *System) CPUCount() int
- func (sys *System) CPUIDs() []ID
- func (sys *System) CPUSet() cpuset.CPUSet
- func (sys *System) Discover(flags DiscoveryFlag) error
- func (sys *System) Isolated() cpuset.CPUSet
- func (sys *System) NUMANodeCount() int
- func (sys *System) Node(id ID) *Node
- func (sys *System) NodeIDs() []ID
- func (sys *System) Offlined() cpuset.CPUSet
- func (sys *System) Package(id ID) *Package
- func (sys *System) PackageCount() int
- func (sys *System) PackageIDs() []ID
- func (sys *System) SetCPUFrequencyLimits(min, max uint64, cpus IDSet) error
- func (sys *System) SetCpusOnline(online bool, cpus IDSet) (IDSet, error)
- func (sys *System) SocketCount() int
- func (sys *System) ThreadCount() int
- type TopologyHint
- type TopologyHints
Constants ¶
const ( M = (int64(1) << 20) G = (int64(1) << 30) T = (int64(1) << 40) )
unit multipliers
const ( // ProviderKubelet is a constant to distinguish that topology hint comes // from parameters passed to CRI create/update requests from Kubelet ProviderKubelet = "kubelet" )
const (
// SysfsRootPath is the mount path of sysfs.
SysfsRootPath = "/sys"
)
Variables ¶
This section is empty.
Functions ¶
func FindSysFsDevice ¶
FindSysFsDevice for given argument returns physical device where it is linked to. For device nodes it will return path for device itself. For regular files or directories this function returns physical device where this inode resides (storage device). If result device is a virtual one (e.g. tmpfs), error will be returned. For non-existing path, no error returned and path is empty.
func ParseFileEntries ¶
func ParseFileEntries(path string, values map[string]interface{}, pickFn PickEntryFn) error
ParseFileEntries parses a sysfs files for the given entries.
Types ¶
type CPU ¶
type CPU struct {
// contains filtered or unexported fields
}
CPU is a CPU core.
func (*CPU) FrequencyRange ¶
FrequencyRange returns the frequency range for this CPU.
func (*CPU) SetFrequencyLimits ¶
SetFrequencyLimits sets the frequency scaling limits for this CPU.
func (*CPU) ThreadCPUSet ¶
ThreadCPUSet returns the CPUSet for all threads in this core.
type CPUFreq ¶
type CPUFreq struct {
// contains filtered or unexported fields
}
CPUFreq is a CPU frequency scaling range
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache has details about cache.
type DiscoveryFlag ¶
type DiscoveryFlag uint
DiscoveryFlag controls what hardware details to discover.
const ( // DiscoverCPUTopology requests discovering CPU topology details. DiscoverCPUTopology DiscoveryFlag = 1 << iota // DiscoverMemTopology requests discovering memory topology details. DiscoverMemTopology // DiscoverCache requests discovering CPU cache details. DiscoverCache // DiscoverNone is the zero value for discovery flags. DiscoverNone DiscoveryFlag = 0 // DiscoverAll requests full supported discovery. DiscoverAll DiscoveryFlag = 0xffffffff // DiscoverDefault is the default set of discovery flags. DiscoverDefault DiscoveryFlag = (DiscoverCPUTopology | DiscoverMemTopology) )
type ID ¶
type ID int
ID is nn integer id, used to identify packages, CPUs, nodes, etc.
const ( // Unknown represents an unknown id. Unknown ID = -1 )
type IDSet ¶
type IDSet map[ID]struct{}
IDSet is an unordered set of integer ids.
func FromCPUSet ¶
FromCPUSet returns an id set corresponding to a cpuset.CPUSet.
func NewIDSetFromIntSlice ¶
NewIDSetFromIntSlice creates a new unordered set from an integer slice.
func (IDSet) SortedMembers ¶
SortedMembers returns all ids in the set as a sorted slice.
func (IDSet) StringWithSeparator ¶
StringWithSeparator returns the set as a string, separated with the given separator.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a NUMA node.
func (*Node) DistanceFrom ¶
DistanceFrom returns the distance of this and a given node.
func (*Node) MemoryInfo ¶
MemoryInfo memory info for the node (partial content from the meminfo sysfs entry).
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package is a physical package (a collection of CPUs).
type PickEntryFn ¶
PickEntryFn picks a given input line apart into an entry of key and value.
type System ¶
type System struct { logger.Logger // our logger instance // contains filtered or unexported fields }
System devices
func DiscoverSystem ¶
func DiscoverSystem(args ...DiscoveryFlag) (*System, error)
DiscoverSystem performs discovery of the running systems details.
func (*System) Discover ¶
func (sys *System) Discover(flags DiscoveryFlag) error
Discover performs system/hardware discovery.
func (*System) NUMANodeCount ¶
NUMANodeCount returns the number of discovered NUMA nodes.
func (*System) PackageCount ¶
PackageCount returns the number of discovered CPU packages (sockets).
func (*System) PackageIDs ¶
PackageIDs gets the ids of all packages present in the system.
func (*System) SetCPUFrequencyLimits ¶
SetCPUFrequencyLimits sets the CPU frequency scaling limits. Nil set implies all CPUs.
func (*System) SetCpusOnline ¶
SetCpusOnline puts a set of CPUs online. Return the toggled set. Nil set implies all CPUs.
func (*System) SocketCount ¶
SocketCount returns the number of discovered CPU packages (sockets).
func (*System) ThreadCount ¶
ThreadCount returns the number of threads per core discovered.
type TopologyHint ¶
TopologyHint represents various hints that can be detected from sysfs for the device
func (*TopologyHint) String ¶
func (h *TopologyHint) String() string
String returns the hints as a string.
type TopologyHints ¶
type TopologyHints map[string]TopologyHint
TopologyHints represents set of hints collected from multiple providers
func MergeTopologyHints ¶
func MergeTopologyHints(org, hints TopologyHints) (res TopologyHints)
MergeTopologyHints combines org and hints.
func NewTopologyHints ¶
func NewTopologyHints(devPath string) (hints TopologyHints, err error)
NewTopologyHints return array of hints for the device and its slaves (e.g. RAID).