sysfs

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: Apache-2.0 Imports: 10 Imported by: 7

Documentation

Index

Constants

View Source
const (
	M = (int64(1) << 20)
	G = (int64(1) << 30)
	T = (int64(1) << 40)
)

unit multipliers

View Source
const (
	// SysfsRootPath is the mount path of sysfs.
	SysfsRootPath = "/sys"
)

Variables

This section is empty.

Functions

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 interface {
	ID() ID
	PackageID() ID
	DieID() ID
	NodeID() ID
	CoreID() ID
	ThreadCPUSet() cpuset.CPUSet
	BaseFrequency() uint64
	FrequencyRange() CPUFreq
	Online() bool
	Isolated() bool
	SetFrequencyLimits(min, max uint64) error
}

CPU is a CPU core.

type CPUFreq

type CPUFreq struct {
	// contains filtered or unexported fields
}

CPUFreq is a CPU frequency scaling range

type CPUPackage

type CPUPackage interface {
	ID() ID
	CPUSet() cpuset.CPUSet
	DieIDs() []ID
	NodeIDs() []ID
	DieNodeIDs(ID) []ID
	DieCPUSet(ID) cpuset.CPUSet
}

CPUPackage is a physical package (a collection of CPUs).

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache has details about cache.

type CacheType

type CacheType string

CacheType specifies a cache type.

const (
	// DataCache marks data cache.
	DataCache CacheType = "Data"
	// InstructionCache marks instruction cache.
	InstructionCache CacheType = "Instruction"
	// UnifiedCache marks a unified data/instruction cache.
	UnifiedCache CacheType = "Unified"
)

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

func FromCPUSet(cset cpuset.CPUSet) IDSet

FromCPUSet returns an id set corresponding to a cpuset.CPUSet.

func NewIDSet

func NewIDSet(ids ...ID) IDSet

NewIDSet creates a new unordered set of (integer) ids.

func NewIDSetFromIntSlice

func NewIDSetFromIntSlice(ids ...int) IDSet

NewIDSetFromIntSlice creates a new unordered set from an integer slice.

func (IDSet) Add

func (s IDSet) Add(ids ...ID)

Add adds the given ids into the set.

func (IDSet) CPUSet

func (s IDSet) CPUSet() cpuset.CPUSet

CPUSet returns a cpuset.CPUSet corresponding to an id set.

func (IDSet) Clone

func (s IDSet) Clone() IDSet

Clone returns a copy of this IdSet.

func (IDSet) Del

func (s IDSet) Del(ids ...ID)

Del deletes the given ids from the set.

func (IDSet) Has

func (s IDSet) Has(ids ...ID) bool

Has tests if all the ids are present in the set.

func (IDSet) MarshalJSON

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

MarshalJSON is the JSON marshaller for IDSet.

func (IDSet) Members

func (s IDSet) Members() []ID

Members returns all ids in the set as a randomly ordered slice.

func (IDSet) Size

func (s IDSet) Size() int

Size returns the number of ids in the set.

func (IDSet) SortedMembers

func (s IDSet) SortedMembers() []ID

SortedMembers returns all ids in the set as a sorted slice.

func (IDSet) String

func (s IDSet) String() string

String returns the set as a string.

func (IDSet) StringWithSeparator

func (s IDSet) StringWithSeparator(args ...string) string

StringWithSeparator returns the set as a string, separated with the given separator.

func (*IDSet) UnmarshalJSON

func (s *IDSet) UnmarshalJSON(data []byte) error

UnmarshalJSON is the JSON unmarshaller for IDSet.

type MemInfo

type MemInfo struct {
	MemTotal uint64
	MemFree  uint64
	MemUsed  uint64
}

MemInfo contains data read from a NUMA node meminfo file.

type MemoryType

type MemoryType int

MemoryType is an enum for the Node memory

const (
	// MemoryTypeDRAM means that the node has regular DRAM-type memory
	MemoryTypeDRAM MemoryType = iota
	// MemoryTypePMEM means that the node has persistent memory
	MemoryTypePMEM
	// MemoryTypeHBM means that the node has high bandwidth memory
	MemoryTypeHBM
)

type Node

type Node interface {
	ID() ID
	PackageID() ID
	CPUSet() cpuset.CPUSet
	Distance() []int
	DistanceFrom(id ID) int
	MemoryInfo() (*MemInfo, error)
	GetMemoryType() MemoryType
	HasNormalMemory() bool
}

Node represents a NUMA node.

type PickEntryFn

type PickEntryFn func(string) (string, string, error)

PickEntryFn picks a given input line apart into an entry of key and value.

type System

type System interface {
	Discover(flags DiscoveryFlag) error
	SetCpusOnline(online bool, cpus IDSet) (IDSet, error)
	SetCPUFrequencyLimits(min, max uint64, cpus IDSet) error
	PackageIDs() []ID
	NodeIDs() []ID
	CPUIDs() []ID
	PackageCount() int
	SocketCount() int
	CPUCount() int
	NUMANodeCount() int
	ThreadCount() int
	CPUSet() cpuset.CPUSet
	Package(id ID) CPUPackage
	Node(id ID) Node
	CPU(id ID) CPU
	Offlined() cpuset.CPUSet
	Isolated() cpuset.CPUSet
}

System devices

func DiscoverSystem

func DiscoverSystem(args ...DiscoveryFlag) (System, error)

DiscoverSystem performs discovery of the running systems details.

func DiscoverSystemAt

func DiscoverSystemAt(path string, args ...DiscoveryFlag) (System, error)

DiscoverSystemAt performs discovery of the running systems details from sysfs mounted at path.

Jump to

Keyboard shortcuts

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