sysfs

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: Apache-2.0 Imports: 13 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 (
	ISST_IF_GET_PHY_ID   = 0xc008fe01
	ISST_IF_IO_CMD       = 0x4008fe02
	ISST_IF_MBOX_COMMAND = 0xc008fe03
)
View Source
const (
	CONFIG_TDP                        = 0x7f
	CONFIG_TDP_GET_LEVELS_INFO        = 0x0
	CONFIG_TDP_GET_TDP_CONTROL        = 0x1
	CONFIG_TDP_SET_TDP_CONTROL        = 0x2
	CONFIG_TDP_GET_TDP_INFO           = 0x3
	CONFIG_TDP_GET_PWR_INFO           = 0x4
	CONFIG_TDP_GET_TJMAX_INFO         = 0x5
	CONFIG_TDP_GET_CORE_MASK          = 0x6
	CONFIG_TDP_GET_TURBO_LIMIT_RATIOS = 0x7
	CONFIG_TDP_SET_LEVEL              = 0x8
	CONFIG_TDP_GET_UNCORE_P0_P1_INFO  = 0x9
	CONFIG_TDP_GET_P1_INFO            = 0xa
	CONFIG_TDP_GET_MEM_FREQ           = 0xb

	CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES = 0x10
	CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS   = 0x11
	CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO       = 0x12

	CONFIG_TDP_PBF_GET_CORE_MASK_INFO = 0x20
	CONFIG_TDP_PBF_GET_P1HI_P1LO_INFO = 0x21
	CONFIG_TDP_PBF_GET_TJ_MAX_INFO    = 0x22
	CONFIG_TDP_PBF_GET_TDP_INFO       = 0x23

	CONFIG_CLOS        = 0xd0
	CLOS_PM_QOS_CONFIG = 0x2

	READ_PM_CONFIG  = 0x94
	WRITE_PM_CONFIG = 0x95
	PM_FEATURE      = 0x3

	PM_QOS_INFO_OFFSET   = 0x0
	PM_QOS_CONFIG_OFFSET = 0x4
	PM_CLOS_OFFSET       = 0x8
	PQR_ASSOC_OFFSET     = 0x20
)
View Source
const NumClos = 4

NumClos is the number of CLOSes suported by SST-CP

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.

func SstSupported added in v0.5.0

func SstSupported() bool

SstSupported returns true if Intel Speed Select Technologies (SST) is supported by the system and can be interfaced via the Linux kernel device

Types

type CPPriorityType added in v0.5.0

type CPPriorityType int

CPPriorityType denotes the type CLOS priority ordering used in SST-CP

const (
	Proportional CPPriorityType = 0
	Ordered      CPPriorityType = 1
)

type CPU

type CPU interface {
	ID() ID
	PackageID() ID
	DieID() ID
	NodeID() ID
	CoreID() ID
	ThreadCPUSet() cpuset.CPUSet
	BaseFrequency() uint64
	FrequencyRange() CPUFreq
	EPP() EPP
	Online() bool
	Isolated() bool
	SetFrequencyLimits(min, max uint64) error
	SstClos() int
}

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
	SstInfo() SstPackageInfo
}

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
	// DiscoverSst requests discovering details of Intel Speed Select Technology
	DiscoverSst
	// 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 | DiscoverSst)
)

type EPP added in v0.5.0

type EPP int

EPP represents the value of a CPU energy performance profile

const (
	EPPPerformance EPP = iota
	EPPBalancePerformance
	EPPBalancePower
	EPPPower
	EPPUnknown
)

func EPPFromString added in v0.5.0

func EPPFromString(s string) EPP

EPPFromString converts string to EPP value

func (EPP) String added in v0.5.0

func (e EPP) String() string

String returns EPP value as string

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
	DieID() 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 SstClosInfo added in v0.5.0

type SstClosInfo struct {
	EPP                  int
	ProportionalPriority int
	MinFreq              int
	MaxFreq              int
	DesiredFreq          int
}

SstClosInfo contains parameters of one CLOS of SST-CP

type SstPackageInfo added in v0.5.0

type SstPackageInfo struct {
	// Gereric PP info
	PPSupported    bool
	PPLocked       bool
	PPVersion      int
	PPCurrentLevel int
	PPMaxLevel     int

	// Information about the currently active PP level
	CPSupported bool
	CPEnabled   bool
	CPPriority  CPPriorityType
	BFSupported bool
	BFEnabled   bool
	BFCores     IDSet
	TFSupported bool
	TFEnabled   bool

	ClosInfo [NumClos]SstClosInfo
}

SstPackageInfo contains status of Intel Speed Select Technologies (SST) for one CPU package

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
	NodeDistance(from, to ID) int
	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